Skip to content

Fix Arrow schema initialization without direct results - #565

Open
vuanhphung wants to merge 1 commit into
mainfrom
fix/issue-312-arrow-schema
Open

vuanhphung wants to merge 1 commit into
mainfrom
fix/issue-312-arrow-schema

Conversation

@vuanhphung

@vuanhphung vuanhphung commented Nov 14, 2026 •

Copy link
Copy Markdown
Collaborator

Cold/empty Arrow results without direct metadata previously had no schema. Both existing iterators now use cached rows/page metadata or one lazy GetResultSetMetadata RPC, preferring ArrowSchema and otherwise the unchanged Thrift conversion. Schema access does not fetch data, mutate shared rows metadata, or discard pending fetch errors. Explicit non-Arrow/non-URL result formats retain the existing driver error.

#351 / ES-1804970 is unchanged from main: CloudFetch retains the constructor's schemaBytes override, including its Thrift fallback, across pages. Only schemas newly inferred by this PR's loader/inline conversion omit the override. The pre-existing direct-CloudFetch timezone panic and raw IPC files' omission of Spark field metadata remain out of scope.

Verified: lint (0 issues), 1,938 unit cases (11 ordinary credential-gated skips), root/rows race (rows shuffled), kernel-tagged build/tests, nine live Thrift cases and six kernel suites without skips. The format cases fail at 7cafaa4; disabling the inferred-schema guard panics in four real CloudFetch cases (Etc/UTC vs UTC), and removing inline conversion fails all eight Next-before-Schema cases. D41 adds only 31 net test lines (+43/-12) and three production lines. Same three untouched generated Thrift gofmt exceptions as main. Extra metadata RPC: 65.0ms median (5 calls, 53.7–91.9ms) on the shared warehouse.

Fresh-process benchmarks against main (alternating build order, n=6): inline no-direct fetch+schema 5.141→5.202µs (p=.310), direct 6.489→6.326µs (p=.732), cached Columns() 5.206→5.307µs (p=.240). No significant timing change; no-direct/cached paths add one 112-byte loader allocation, direct unchanged. Total test additions: 766 lines; total PR +883/-11 in the same 10 files. Harness/results stay outside the PR.

Cross-driver state

Driver State Notes
JDBC Supported Eager first-page metadata; DatabricksThriftAccessor.java:244, ArrowUtil.java:67,131 @0ad7a49.
Python Supported Execute-time metadata RPC; thrift_backend.py:870,902 @75a0d5d.
Go Not supported → Supported Lazy metadata RPC; native decimal=false/timestamp=true defaults and #351 override unchanged.
Node.js Supported Lazy single-flight metadata RPC; ThriftOperationBackend.ts:321, ArrowResultHandler.ts:26 @abedbbf.
Kernel Not applicable (IPC); Supported (batches) Reader schema, result_stream.rs:600,690 @8d88cce; unchanged.

Adversarial review: D39/D40 findings resolved; accepted D41 format/coverage findings fixed and mutation-tested. Bot APPROVED 16f9e44 with no findings; final-head required CI green and zero unresolved threads.

Fixes #312.

This pull request and its description were written by Isaac.

@vuanhphung
vuanhphung marked this pull request as ready for review November 14, 2026 07:58

@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.

✅ No issues identified by the review bot.

@vuanhphung
vuanhphung force-pushed the fix/issue-312-arrow-schema branch from fc55d81 to 22fc232 Compare November 20, 2026 00:59

@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).

Verdict: 2 Low

Looks good, with one low concern: the new live E2E tests aren't added to the nightly filter. Nit: the variadic schemaErrors ...error / detectEmbeddedSchema ...bool params quietly ignore any extra values; a plain or named parameter would be clearer.

This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.

Comment thread internal/rows/arrowbased/arrowRows.go Resolved
Comment thread driver_e2e_test.go Resolved
@vuanhphung
vuanhphung force-pushed the fix/issue-312-arrow-schema branch from b5776eb to bd9cd41 Compare November 20, 2026 01:58

@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).

Verdict: 1 Medium · 2 Low

Looks good, with 1 low concern. I traced lazy schema initialization, the pending first page, the CloudFetch header replacement and the deferred-iterator error handling, and found no correctness defects. A nit: the new schemaErrors ...error and detectEmbeddedSchema ...bool variadics are used as optional parameters, which hides call-site intent.

This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.

Comment thread driver_e2e_test.go Resolved
Comment thread internal/rows/arrowbased/arrowRows.go Resolved
Comment thread internal/rows/rows.go Resolved
@vuanhphung

Copy link
Copy Markdown
Collaborator Author

Regarding the optional-parameter nit: keeping the variadics preserves existing internal constructor call signatures; new callers pass named schemaErr/detectEmbeddedSchema state, and no caller supplies extra values. Public Rows interfaces remain unchanged.


This comment was generated with GitHub MCP.

@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).

Verdict: 1 Medium

Mostly solid: 1 medium concern. Multi-page Next() over inline batches that embed their own schema stops detecting those schemas after the first page. Nit: the CHANGELOG says IPC headers match the accessor schema's field metadata, but headers whose column names already match are passed through unchanged.

Comment thread internal/rows/arrowbased/arrowRows.go Resolved
@vuanhphung

Copy link
Copy Markdown
Collaborator Author

The changelog wording nit is fixed in dc69425: unchanged-name CloudFetch files preserve their original types and field metadata; only stale top-level names trigger a schema rewrite.


This comment was generated with GitHub MCP.

@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).

Verdict: 1 Low

Looks good: one low concern. Deferred schema initialization, the CloudFetch header splicing and the empty-page metadata paths are consistent and well tested. Pre-existing gap for follow-up: on main, a failed metadata RPC during a plain Next also loses the fetched page.

Comment thread internal/rows/rows.go Resolved

@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).

Verdict: 2 Low

Looks good: no blocking issues. I traced deferred initialization, retrying a pending page, header splicing and reader interfaces for cached CloudFetch files, metadata locking, and the EOF path for empty results, and found no regression. Nit: the test files arrow_review_test.go and arrow_final_review_test.go are named after the review rounds, not after what they test.

This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.

Comment thread internal/rows/arrowbased/schema.go Resolved
Comment thread internal/rows/arrowbased/deferred.go Resolved
@vuanhphung

Copy link
Copy Markdown
Collaborator Author

The test-file naming nit is fixed in 1ba993c: the suites are now arrow_schema_fallback_test.go and arrow_schema_state_test.go, with unchanged test behavior.


This comment was generated with GitHub MCP.

@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).

Verdict: 1 Low

Looks good: no blocking issues found. I traced deferred initialization, CloudFetch header splicing, how cloudIPCReader keeps the reader interfaces, retrying pending pages, and Close behaviour against main. The IPC iterator's Close still leaves the page iterator open, which matches main. Scanning still uses fixed Timestamp_us, so the Etc/UTC change only affects the reported schema.

This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.

Comment thread internal/rows/arrowbased/schema.go Resolved

@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).

Verdict: 1 Low

Looks reasonable, with 1 low concern about cleanup after a failed lazy init. Follow-up, not caused by this PR: fetchResultPage still drops a page that was fetched by ordinary Next() when makeRowScanner fails; only the Arrow path keeps it as pendingArrowPage. Nit: the edited comment URLs in driver_e2e_test.go now point to .../databricks-sql-go/v2/issues/506, which is a broken link.

Comment thread internal/rows/arrowbased/deferred.go Resolved
@vuanhphung
vuanhphung force-pushed the fix/issue-312-arrow-schema branch from b9957f2 to 8d53ba5 Compare November 24, 2026 00:06
@vuanhphung

Copy link
Copy Markdown
Collaborator Author

The issue-506 URL nit is fixed in 8d53ba5: both comments again use #506. The scalar retry follow-up remains unchanged from main; pendingArrowPage was removed with the minimal-loader rewrite.


This comment was generated with GitHub MCP.

@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).

Verdict: 1 Medium · 1 Low

Mostly solid, with 1 medium and 1 low concern. The lazy schema loader is a good fit, but it now runs during iteration as well, which can block CloudFetch results that main could decode, and one new metadata access is not nil-safe.

@vuanhphung
vuanhphung force-pushed the fix/issue-312-arrow-schema branch from 8d53ba5 to a4a3a7d Compare November 24, 2026 00:19

@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).

Verdict: 1 Medium · 1 Low

Looks good apart from one medium concern: the lazy schema loader skips the record iterator's finished/closed guard. In the paths I traced, the CloudFetch override guard and the Nullable fallback behave correctly.

This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.

@vuanhphung
vuanhphung force-pushed the fix/issue-312-arrow-schema branch from a4a3a7d to b2b800d Compare November 24, 2026 00:29

@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).

Verdict: 1 Medium · 2 Low

Looks good, with 1 low concern. The lazy first-page schema loading is sound and well tested on both accessors. The only issue is that the IPC iterator recovers from a failed schema conversion differently than the batch iterator does.

This overview is Claude Opus 5.5's initial take; GPT-6.1 Sol added findings it doesn't mention — see the findings below.

Comment thread internal/rows/rows.go Resolved
@vuanhphung
vuanhphung force-pushed the fix/issue-312-arrow-schema branch from b2b800d to 17f45a9 Compare November 24, 2026 00:44

@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.

@vuanhphung
vuanhphung force-pushed the fix/issue-312-arrow-schema branch from 17f45a9 to 003e72a Compare November 24, 2026 06:57
@vuanhphung

vuanhphung commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator Author

Addressed maintainer Findings 2–4 in 1b321df (D37, amended into the original signed-off commit).

  • 2: Schema access uses cached metadata or GetResultSetMetadata, never FetchResults. Live metadata RPCs include ArrowSchema, and CloudFetch batch Schema().Equal(record.Schema()) passes. The PR body documents the no-ArrowSchema inference caveat. Raw IPC files' missing Spark field metadata also reproduces on main and is unchanged.
  • 3: Removed accessor Close-on-conversion-error; regression coverage proves a pending page-fetch error reaches Next() once, then EOF.
  • 4: RPC response stays local; no writes to shared rows metadata/schema. Concurrent Close/ResultFormat regression races on the previous head and passes here.

Lint, unit, root/rows race, kernel-tagged build/tests pass; 22 live Thrift schema cases and six kernel suites pass without skips. Extra metadata RPC: 55.7ms median (14 calls, shared warehouse). Alternating fresh-process benchmarks find no significant timing change; detailed numbers are in the updated description. Production/API-doc diff shrank from +106/-13 to +99/-13; independent D37 review found no introduced defects.

@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).

Verdict: 1 Low

Looks good, with 1 low concern. Lazy metadata loading, the reused page-metadata cache and pending-error handling look correct, and both iterators have thorough unit coverage. One new E2E test is missing from the nightly filter.

Comment thread .github/workflows/nightly-e2e.yml Resolved
@vuanhphung
vuanhphung force-pushed the fix/issue-312-arrow-schema branch from 003e72a to 1b321df Compare November 24, 2026 07:04

@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).

Verdict: 1 Low

Looks good, with 1 low concern. Lazy metadata loading, preserved pending errors and the nullable Thrift fallback look correct and are well covered by unit and E2E tests. The low concern is an edge case where the CloudFetch override schema can come from an inferred schema.

This overview is Claude Opus 5.5's initial take; some of its points were set aside by the cross-check judge and GPT-6.1 Sol added findings it doesn't mention — see the findings below.

🔀 1 finding considered and dismissed by the judge
  • 🔵 Low internal/rows/arrowbased/arrowRecordIterator.go:233 — If Schema() builds its schema from Thrift metadata first (the metadata RPC had no ArrowSchema), ri.arrowSchemaBytes keeps that inferred schema. A later Clou
    Judge's evidence: if len(fr.ResultSetMetadata.ArrowSchema) == 0 { schemaBytes = nil }

Comment thread internal/rows/arrowbased/arrowRows.go Resolved
@vuanhphung
vuanhphung force-pushed the fix/issue-312-arrow-schema branch from 1b321df to 4afea30 Compare November 24, 2026 07:42

@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).

Verdict: 1 Low

Looks good, with 1 low concern. The lazy metadata loader, pending-error preservation and Close-before-use handling look correct and are well covered. The only gap is a new nil dereference on later CloudFetch pages.

@vuanhphung
vuanhphung force-pushed the fix/issue-312-arrow-schema branch from 4afea30 to dadf5f0 Compare November 24, 2026 18:01

@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).

Verdict: 1 Low

Looks good, with one low concern. The lazy loader reuses cached metadata, keeps its state local and leaves #351's override in place. Nit: the loader captures r.resultSetMetadata when the iterator is created, so calling Columns() after GetArrowBatches can cost a second metadata RPC.

@vuanhphung

Copy link
Copy Markdown
Collaborator Author

Re the review-body nit: Columns() after iterator construction can still make two metadata RPCs, as on 4afea30. D39 explicitly requires a construction-time snapshot so the loader never reads shared rows fields later. The ordinary status-only DirectResults and Columns-before-iterator cases now each make exactly one RPC in both accessors, covered by TestArrowSchemaBeforeFetching; no additional shared-state read is planned.


This comment was generated with GitHub MCP.

@vuanhphung
vuanhphung force-pushed the fix/issue-312-arrow-schema branch 2 times, most recently from 0c34f1e to 4fdac91 Compare November 24, 2026 19:10

@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).

Verdict: 1 Low

Looks good, with 1 low concern. The lazy metadata loader, the pending-error preservation and the CloudFetch override handling look correct and are well tested. The nullable change in the shared Thrift→Arrow conversion also affects direct-results paths, and the PR doesn't say so.

Comment thread internal/rows/arrowbased/arrowRows.go Resolved
@vuanhphung
vuanhphung force-pushed the fix/issue-312-arrow-schema branch from 4fdac91 to 7cafaa4 Compare November 24, 2026 20:48

@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).

Verdict: 2 Nit

Looks good — no blocking issues. I traced both iterators: the loader leaves shared rows metadata untouched, only schemas the PR itself infers drop the #351 CloudFetch override, and pending fetch errors are kept. Two test nits only.

Other findings

  • ⚪ Nit — The test loop calls require.Empty(result.ResultFormat()) in a tight loop with a default: branch, so it busy-spins until the goroutine finishes. Add a short sleep or yield in the default branch, or check once after finished. (Found by Claude Opus 5.5 · confirmed by the judge)
  • ⚪ Nit — The inner if count > 0 is redundant inside if cloud && count > 0. The cloud=true/rows=0 subtests also run the same path as cloud=false. Drop the inner check and skip or rename the duplicate cases. (Found by Claude Opus 5.5 · confirmed by the judge)

@vuanhphung

Copy link
Copy Markdown
Collaborator Author

Re the test nits: retaining the deadline-bounded ResultFormat loop to exercise concurrent metadata reads under -race; checking only after finished would weaken that regression. The redundant guard/empty CloudFetch variants are unchanged by D40 and test-only cleanup, so I’m leaving them rather than widening this inference-compatibility revert.


This comment was generated with GitHub MCP.

Load schemas lazily from cached metadata or GetResultSetMetadata in both
Arrow iterators, with the unchanged Thrift fallback. Schema access
does not fetch data or mutate shared rows metadata, and leaves pending
page-fetch errors for Next. Reuse rows-held metadata and preserve the
CloudFetch schema override unless this loader inferred the schema.
Reject explicit non-Arrow formats and cover schema provenance and
Next-before-Schema inline conversion.

Fixes #312

Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Co-authored-by: Isaac <no-reply@databricks.com>
@vuanhphung
vuanhphung force-pushed the fix/issue-312-arrow-schema branch from 7cafaa4 to 16f9e44 Compare November 24, 2026 23:51

@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.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ArrowIPCStreamIterator.SchemaBytes() returns zero bytes after a cold start

1 participant