Skip to content

Commit 542cc1b

Browse files
fix(rust): handle DDL statements with empty result schema (#371)
## Summary - DDL statements (CREATE TABLE, DROP TABLE, ALTER, etc.) return a manifest with `column_count: 0` and **omit the `columns` field entirely** from the JSON response - This caused deserialization to fail with `missing field 'columns'`, making all DDL statements unusable - Added `#[serde(default)]` to `ResultSchema.columns` so it defaults to an empty `Vec` when absent ## Test plan - [ ] Verified locally: CREATE TABLE, INSERT, UPDATE, DELETE, DROP TABLE all succeed - [ ] `cargo test` passes (unit + doc tests) - [ ] CI passes This pull request was AI-assisted by Isaac.
1 parent 8682f0b commit 542cc1b

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

rust/src/types/sea.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ pub struct ResultManifest {
8888
#[derive(Debug, Clone, Deserialize)]
8989
pub struct ResultSchema {
9090
pub column_count: i32,
91+
#[serde(default)]
9192
pub columns: Vec<ColumnInfo>,
9293
}
9394

@@ -443,6 +444,36 @@ mod tests {
443444
assert_eq!(col.type_interval_type, None);
444445
}
445446

447+
#[test]
448+
fn test_ddl_response_with_empty_schema() {
449+
// DDL statements (CREATE TABLE, DROP TABLE) return column_count: 0
450+
// with the columns field omitted entirely.
451+
let json = r#"{
452+
"statement_id": "01f12850-3b6a-123f-8e77-57d8d2fd960a",
453+
"status": {"state": "SUCCEEDED"},
454+
"manifest": {
455+
"format": "ARROW_STREAM",
456+
"schema": {"column_count": 0},
457+
"total_chunk_count": 0,
458+
"total_row_count": 0,
459+
"total_byte_count": 0,
460+
"truncated": false
461+
},
462+
"result": {}
463+
}"#;
464+
465+
let response: StatementExecutionResponse = serde_json::from_str(json).unwrap();
466+
assert_eq!(
467+
response.statement_id,
468+
"01f12850-3b6a-123f-8e77-57d8d2fd960a"
469+
);
470+
assert_eq!(response.status.state, StatementState::Succeeded);
471+
let manifest = response.manifest.unwrap();
472+
assert_eq!(manifest.schema.column_count, 0);
473+
assert!(manifest.schema.columns.is_empty());
474+
assert_eq!(manifest.total_row_count, Some(0));
475+
}
476+
446477
#[test]
447478
fn test_column_info_with_interval_type() {
448479
let json = r#"{

0 commit comments

Comments
 (0)