feat: stream query result CSV/XLSX exports
* docs: add query result streaming export design * feat(core): stream query result exports * feat: expose query result streaming export APIs * feat(desktop): stream query result exports from grid * fix: route query result export cancellation through its command * fix: reduce query export batch size and cancel latency * opt: del local test files
This commit is contained in:
1 parent
849caf4b39
commit
588ba3352d
25 files changed
+1787
-47
No files matched your search
@@ -32,6 +32,8 @@ pub struct QueryPaginationExecutionPlanOptions {
|
||||
pub database_type: Option<DatabaseType>,
|
||||
pub pagination: QueryPagination,
|
||||
pub use_agent_cursor: bool,
|
||||
#[serde(default)]
|
||||
pub first_page_uses_actual_sql: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
@@ -128,7 +130,9 @@ pub fn build_query_pagination_execution_plan(
|
||||
}
|
||||
|
||||
if options.use_agent_cursor && options.pagination.offset == 0 {
|
||||
plan.sql_to_execute = options.query_base_sql;
|
||||
if !options.first_page_uses_actual_sql {
|
||||
plan.sql_to_execute = options.query_base_sql;
|
||||
}
|
||||
plan.page_limit = Some(options.pagination.limit);
|
||||
plan.page_offset = Some(options.pagination.offset);
|
||||
plan.use_agent_result_session = true;
|
||||
@@ -922,6 +926,7 @@ mod tests {
|
||||
database_type: Some(DatabaseType::SqlServer),
|
||||
pagination: QueryPagination { limit: 100, offset: 0, session_id: None },
|
||||
use_agent_cursor: false,
|
||||
first_page_uses_actual_sql: false,
|
||||
});
|
||||
|
||||
assert_eq!(plan.sql_to_execute, sql);
|
||||
@@ -1282,6 +1287,7 @@ WHERE u.id = picked.id;
|
||||
database_type: Some(DatabaseType::Oracle),
|
||||
pagination: QueryPagination { limit: 500, offset: 0, session_id: None },
|
||||
use_agent_cursor: true,
|
||||
first_page_uses_actual_sql: false,
|
||||
});
|
||||
|
||||
assert_eq!(plan.sql_to_execute, "SELECT * FROM events");
|
||||
@@ -1291,6 +1297,24 @@ WHERE u.id = picked.id;
|
||||
assert!(plan.use_agent_result_session);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn export_agent_cursor_first_page_keeps_actual_sorted_sql() {
|
||||
let plan = build_query_pagination_execution_plan(QueryPaginationExecutionPlanOptions {
|
||||
sql: "SELECT * FROM (SELECT * FROM events) t ORDER BY created_at DESC".to_string(),
|
||||
query_base_sql: "SELECT * FROM events".to_string(),
|
||||
database_type: Some(DatabaseType::Oracle),
|
||||
pagination: QueryPagination { limit: 500, offset: 0, session_id: None },
|
||||
use_agent_cursor: true,
|
||||
first_page_uses_actual_sql: true,
|
||||
});
|
||||
|
||||
assert_eq!(plan.sql_to_execute, "SELECT * FROM (SELECT * FROM events) t ORDER BY created_at DESC");
|
||||
assert_eq!(plan.page_limit, Some(500));
|
||||
assert_eq!(plan.page_offset, Some(0));
|
||||
assert!(plan.page_sql.is_none());
|
||||
assert!(plan.use_agent_result_session);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn builds_sorted_query_sql() {
|
||||
let result = build_sorted_query_sql(SortedQuerySqlOptions {
|
||||
|
||||
Reference in new issue
Block a user