Skip to content

feat(metadata): request native Thrift result routing - #353

Merged
vuanhphung merged 1 commit into
mainfrom
feat/native-thrift-metadata-routing
Sep 23, 2026
Merged

vuanhphung merged 1 commit into
mainfrom
feat/native-thrift-metadata-routing

Conversation

@vuanhphung

@vuanhphung vuanhphung commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator

First PR in the native metadata stack.

Stack: #353 (this) → #354 → #355 → #336.

Send SEA metadata operation/native-result headers, honor manifest.is_native_metadata_result, and bypass SQL-result reshaping while retaining legacy fallbacks and client-side filters.

Testing: cargo +stable fmt --all, cargo clippy --all-targets -- -D warnings, cargo test.

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

Verdict: 1 High

Solid, well-tested refactor to route native Thrift metadata results and bypass SQL-result reshaping. One high concern: process_native_tables filters the catalog case-sensitively (==) while every sibling filter (including the filter_cross_reference_by_parent added in this same PR) uses eq_ignore_ascii_case, which can silently drop all rows for mixed-case catalog names against canonically-cased native results.

Comment thread src/metadata/thrift_shape.rs Resolved
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>

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

Verdict: 2 Low

Looks good — the native-metadata routing is coherent: both native and legacy paths converge on the kernel's canonical JDBC column names/order, the wildcard fan-out still enumerates catalogs via TABLE_CAT regardless of path, and applying filter_cross_reference_by_parent to the legacy foreign-keys path too is a genuine correctness improvement (the SHOW grammar ignores parent identifiers server-side). Two Low notes: the positional schema reattachment trusts server column order for all-Utf8 schemas (silent-mislabel risk if the contract is ever violated), and the native bypass routing lacks wire-level test coverage beyond catalogs.

Comment thread src/metadata_v0.rs
/// Reattach the kernel's public schema so empty and non-empty responses expose
/// the same stable Arrow contract, while deliberately skipping the SQL-result
/// reshape.
fn normalize_native_metadata_batch(

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Low — normalize_native_metadata_batch reattaches the kernel's public schema to the native columns purely by position: RecordBatch::try_new(schema, batch.columns().to_vec()). try_new validates column count and DataType, but several native schemas are entirely Utf8 (e.g. GET_TABLES_SCHEMA's 10 columns, GET_CATALOGS_SCHEMA's single column). If the native backend ever returns those columns in a different order, the mismatch is invisible to the type check and the kernel would silently mislabel columns (e.g. TABLE_SCHEM values under TABLE_NAME).

This rests entirely on the server-contract invariant that native results are already in canonical Thrift column order. That's a reasonable assumption for this PR, but since the failure mode is silent data corruption rather than a loud error, consider asserting the incoming column names match the target schema (or at least documenting the invariant at the call sites) before trusting the order.

Comment thread src/metadata_v0.rs
Some(catalog.as_str()),
types_ref.as_deref(),
)?);
out.push(if native {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔵 Low — The native-result bypass is wired into list_tables, list_columns, list_schemas, foreign_keys, list_catalogs, etc., but the only wire-level (wiremock) coverage added is native_catalogs_header_and_result_bypass_show_reshape. The new unit tests exercise the filter helpers (process_native_tables, filter_cross_reference_by_parent) directly, but nothing drives a native is_native_metadata_result: true manifest through the list_tables / list_columns / foreign_keys routing where process_native_tables and filter_cross_reference_by_parent are actually invoked from the reshape closure. A regression in that routing (e.g. the native branch calling the wrong helper, or the parent-filter being dropped) would pass CI. Consider adding wiremock tests mirroring the catalogs one for at least the tables and cross-reference native paths.

@jay-xiao446 jay-xiao446 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

lgtm

@vuanhphung
vuanhphung added this pull request to the merge queue Sep 23, 2026
Merged via the queue into main with commit 8cb9b2d Sep 23, 2026
26 checks passed

This branch was previously deployed

1 inactive deployment
azure-prod — ace712d8 Deployed Sep 23, 2026 by oss-reviewer-bot[bot] via followup #1519
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.

2 participants