Skip to content

Report no columns for Thrift statements without output - #651

Open
vuanhphung wants to merge 2 commits into
mainfrom
fix/thrift-ddl-empty-schema
Open

vuanhphung wants to merge 2 commits into
mainfrom
fix/thrift-ddl-empty-schema

Conversation

@vuanhphung

Copy link
Copy Markdown
Collaborator

Fixes #309. For DDL such as CREATE TABLE, the Thrift server returns a placeholder schema (one Result STRING column) with hasResultSet: true and no rows, which is indistinguishable from SELECT 'sample' AS Result WHERE 1 = 0. The Arrow schema in the same response has no fields, so getSchema() and getResultMetadata() now report no columns in that case. This matches the kernel backend, which already returns an empty schema for DDL. The deprecated getMetadata() still returns the wire response.

No API signature changes. On Thrift, getSchema() for DDL now returns { columns: [] } instead of the placeholder. With arrowEnabled: false the two responses are identical on the wire, so the placeholder is kept.

Verified on a live warehouse: the new tests/e2e/ddl_schema.test.ts passes on Thrift and kernel, and its Thrift case fails without this change.

Driver DDL vs. empty SELECT
JDBC Supported via SQL text: execute() decides by regex (DatabricksStatement.shouldReturnResultSet); the server's hasResultSet is unused
Python Partial: SEA description is [] for DDL; Thrift shows the Result placeholder with Arrow on or off (verified live on 4.9.0)
Go Not supported: RowsAffected is 0 for both; Exec/Query is the caller's choice
Kernel Supported: returns the SEA schema, which is empty for DDL
Node Kernel supported; Thrift supported with Arrow after this PR

No driver exposes a statement type and neither Thrift nor SEA carries one, so this PR doesn't add one.

This pull request and its description were written by Isaac.


This PR was created with GitHub MCP.

For DDL the Thrift server sends a placeholder `Result STRING` column, which
can't be told apart from `SELECT 'x' AS Result WHERE 1 = 0`. The Arrow schema
in the same response has no fields, so getSchema() and getResultMetadata()
now report no columns, matching the kernel backend. getMetadata() still
returns the wire response. Without Arrow results the wire is identical and
the placeholder is kept.

Fixes #309

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Vu Anh Phung <[email protected]>

@oss-reviewer-bot oss-reviewer-bot Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔀 Cross-reviewed: two independent reviews (Claude Opus 5.5 · GPT-6.1 Sol), checked by a judge model (Claude Sonnet 5.5).

✅ No issues identified.

Decode the Arrow schema once per operation and hand the normalized
metadata to the result handlers, so DDL results skip FetchResults.
getSchema() goes through an optional IOperationBackend.getSchema()
instead of an instanceof check and still works without resultFormat.
Tolerate Thrift schemas missing required fields, close operations and
the session even when e2e assertions fail, and add a changelog entry.

Co-authored-by: Isaac <[email protected]>
Signed-off-by: Vu Anh Phung <[email protected]>

This branch was successfully deployed

1 active (outdated) deployment
azure-prod — 3e136463 Deployed Nov 26, 2026 by vuanhphung via e2e-test (24.22.1, 24_22_1) #2240
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DDL Statement vs Select statement identical results

1 participant