Skip to content

fix(metadata): empty table_types slice matches NONE, not all (hiveserver2 #83) - #246

Merged
eric-wang-1990 merged 2 commits into
mainfrom
eric-wang-1990/fix-empty-tabletypes-match-none
Aug 14, 2026
Merged

eric-wang-1990 merged 2 commits into
mainfrom
eric-wang-1990/fix-empty-tabletypes-match-none

Conversation

@eric-wang-1990

Copy link
Copy Markdown
Collaborator

What

Fixes the kernel nightly (red on both the normal and reyden legs): the live E2E test get_tables_empty_table_types_filter_matches_none demanded zero rows for an empty table_types filter, but the driver returned all rows.

Realigns Metadata::list_tables / reshape_tables with the canonical cross-driver contract from adbc-drivers/hiveserver2 #83: an explicit empty table_types slice (Some(&[])) matches NONE (zero rows), not all. Only None means "all types".

Why this regressed

Two changes landed with opposite readings of the same spec:

Date Change Empty table_types
2026-08-06 driver-test #1121 (per hiveserver2 #83) flipped METADATA-035 → match NONE
2026-08-10 kernel #201 (fix for #187) → match ALL

#201 implemented #187's "empty should match all like null" premise — but #83 had already reversed that premise 4 days earlier (establishing that databricks-jdbc's listTables has always short-circuited an empty array to "return nothing", making the earlier #72 reading wrong). Driver and conformance test ended up on opposite sides. Replay masked it (recording predates the split); only the live nightly caught it.

The two surfaces (why both files change)

The typed API and the ODBC C-ABI have different empty-type contracts, and they're coupled:

  • Typed Rust API (Option<&[&str]>, also napi/pyo3) follows JDBC/ADBC: None = all, Some(&[]) = none.
  • ODBC C-ABI (SQLTables CSV) follows the ODBC spec: an empty TableType means "type not used to restrict the search" = all types. ODBC has no way to express a non-null empty list (which is why driver-test's METADATA-035 is skipped for ODBC). Source: Microsoft ODBC SQLTables — "If TableType is not an empty string, it must contain a list of comma-separated values…".

Because the C-ABI previously relied on Some(&[]) == None == match-all (true post-#201), flipping the typed API to match-none would make an ODBC empty TableType return zero tables — a regression. So the C-ABI must collapse an empty CSV back to None. Both changes are required together; shipping only the kernel-typed fix would trade the nightly failure for an ODBC SQLTables regression.

Changes

Testing

  • cargo test --lib: 767 passed, 0 failed (incl. flipped tables_empty_types_matches_none and new parse_table_types_filter_collapses_empty_to_none).
  • cargo fmt --check + cargo clippy --lib: clean.
  • Live E2E: get_tables_empty_table_types_filter_matches_none (the nightly-red test) passes against a real warehouse via DATABRICKS_KERNEL_PATH → this branch, --proxy-mode passthrough.

Related

This pull request and its description were written by Isaac.

…ver2 #83)

`reshape_tables` special-cased `Some(&[])` (explicit empty table_types
slice) as match-ALL, equivalent to `None` — added in #201 (fix for #187)
and relied on by #223's C-ABI cleanup. That premise was reversed by
adbc-drivers/hiveserver2 #83: an empty type filter matches NOTHING (zero
rows), matching databricks-jdbc's long-standing `listTables` short-circuit,
and driver-test's METADATA-035 conformance test was flipped to expect
match-none on 2026-08-06. The kernel driver landed the opposite behavior on
2026-08-10, so the live nightly (get_tables_empty_table_types_filter_matches_none,
both normal and reyden legs) went red: the test demands 0 rows, the driver
returned all rows.

Realign the driver with the canonical (#83) contract:

- thrift_shape.rs: drop the `Some([]) => reshaped` arm so an empty slice
  flows through `filter_tables_by_type`, whose `types.iter().any(..)` is
  false for every row → a correctly-typed empty batch. Only `None` now
  means match-all. Rewrote the inline + doc comments (they cited the
  reversed #72 reading).
- thrift_shape.rs unit test: tables_empty_types_matches_all →
  tables_empty_types_matches_none (asserts 0 rows).
- c_abi/metadata.rs: re-add the empty-CSV → `None` collapse that #223
  removed. ODBC passes "" / whitespace / comma-only junk for "no type
  filter" (match-all); now that `Some(&[])` means match-none again on the
  Rust surface, the C-ABI boundary must collapse an empty parse back to
  `None` to preserve ODBC's empty→"all types" convention. Keeps #223's
  `split_table_types_csv` helper; restores the pre-#223 guard via
  `.filter(|t| !t.is_empty())`. The napi/pyo3 typed surfaces intentionally
  pass `Some(&[])` through (match-none), consistent with the Rust API.

Validated: 766 lib unit tests pass; fmt + clippy clean; the live E2E
get_tables_empty_table_types_filter_matches_none passes against a real
warehouse (was red in the nightly). Reopens/supersedes #187 (its match-all
premise is overturned by #83).

Co-authored-by: Isaac

Signed-off-by: eric-wang-1990 <e.wang@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: 1 Low

Looks good — the fix is correct and internally consistent. An empty table_types slice now flows through filter_tables_by_type, which yields a correctly-typed empty batch (all-false mask, no panic/error), and the C-ABI restores the ODBC empty-CSV→None collapse via a testable helper with locking unit tests. Both the flipped unit test and the new collapse test align with the hiveserver2 #83 contract. One low-severity doc note on the public list_tables method.

Other findings

  • 🔵 Low — The public list_tables docstring documents the Some(non-empty) case but is silent on the two cases this PR is precisely about: None = match all, Some(&[]) = match none. The internal reshape_tables doc and the C-ABI helper now spell this out, but this is the method the typed napi/pyo3 surfaces call — and per the PR those surfaces intentionally pass Some(&[]) through as match-none. Since an inconsistent reading of exactly this contract caused the nightly regression, a one-line note here (e.g. "None matches all types; an explicit empty slice matches none") would prevent a future caller/maintainer from re-merging the two. Non-blocking.

@eric-wang-1990 eric-wang-1990 added the integration-test Maintainer-only: triggers cross-repo integration tests. Auto-removed on push for re-review. label Aug 13, 2026
@github-actions

Copy link
Copy Markdown

Kernel integration tests triggered. View status. Results post back here as the "Kernel Integration Tests" check.

@eric-wang-1990
eric-wang-1990 force-pushed the eric-wang-1990/fix-empty-tabletypes-match-none branch from 65fcc16 to be910c9 Compare August 14, 2026 00:17
@github-actions github-actions Bot removed the integration-test Maintainer-only: triggers cross-repo integration tests. Auto-removed on push for re-review. label Aug 14, 2026
@github-actions

Copy link
Copy Markdown

Integration test approval reset

New commits were pushed to this PR. The integration-test label has been automatically removed for security.

A maintainer must re-review the changes and re-add the label to trigger tests again.

Latest commit: be910c9

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

@eric-wang-1990
eric-wang-1990 added this pull request to the merge queue Aug 14, 2026
Merged via the queue into main with commit a79b8cf Aug 14, 2026
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