Repository navigation
fix(metadata): empty table_types slice matches NONE, not all (hiveserver2 #83) - #246
Conversation
…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>
There was a problem hiding this comment.
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_tablesdocstring documents theSome(non-empty)case but is silent on the two cases this PR is precisely about:None= match all,Some(&[])= match none. The internalreshape_tablesdoc 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 passSome(&[])through as match-none. Since an inconsistent reading of exactly this contract caused the nightly regression, a one-line note here (e.g. "Nonematches all types; an explicit empty slice matches none") would prevent a future caller/maintainer from re-merging the two. Non-blocking.
|
Kernel integration tests triggered. View status. Results post back here as the "Kernel Integration Tests" check. |
65fcc16 to
be910c9
Compare
|
Integration test approval reset New commits were pushed to this PR. The A maintainer must re-review the changes and re-add the label to trigger tests again. Latest commit: be910c9 |
What
Fixes the kernel nightly (red on both the normal and reyden legs): the live E2E test
get_tables_empty_table_types_filter_matches_nonedemanded zero rows for an emptytable_typesfilter, but the driver returned all rows.Realigns
Metadata::list_tables/reshape_tableswith the canonical cross-driver contract from adbc-drivers/hiveserver2 #83: an explicit emptytable_typesslice (Some(&[])) matches NONE (zero rows), not all. OnlyNonemeans "all types".Why this regressed
Two changes landed with opposite readings of the same spec:
table_types#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
listTableshas 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:
Option<&[&str]>, also napi/pyo3) follows JDBC/ADBC:None= all,Some(&[])= none.SQLTablesCSV) follows the ODBC spec: an emptyTableTypemeans "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 isskippedfor ODBC). Source: Microsoft ODBCSQLTables— "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 emptyTableTypereturn zero tables — a regression. So the C-ABI must collapse an empty CSV back toNone. Both changes are required together; shipping only the kernel-typed fix would trade the nightly failure for an ODBCSQLTablesregression.Changes
thrift_shape.rs: drop theSome([]) => reshapedarm so an empty slice flows throughfilter_tables_by_type(whosetypes.iter().any(..)isfalsefor every row → a correctly-typed empty batch). Rewrote inline + doc comments (they cited the reversed feat(reader): comparator parity — re-land of #64 (intervals_as_string, empty-result schema, composite types, TIMESTAMP tz, metadata reshape, named params) #72 reading). Flipped unit testtables_empty_types_matches_all→tables_empty_types_matches_none(asserts 0 rows).c_abi/metadata.rs: re-add the empty-CSV →Nonecollapse that refactor(c_abi): simplify table_types empty-CSV handling post-#201 #223 removed, extracted into a testableparse_table_types_filterhelper (keeps refactor(c_abi): simplify table_types empty-CSV handling post-#201 #223'ssplit_table_types_csvsplit helper). Added unit testparse_table_types_filter_collapses_empty_to_nonelocking: null arg AND""/" "/",,"→None(match-all); a CSV with real types →Some. The napi/pyo3 typed surfaces intentionally passSome(&[])through (match-none) — no change there.Testing
cargo test --lib: 767 passed, 0 failed (incl. flippedtables_empty_types_matches_noneand newparse_table_types_filter_collapses_empty_to_none).cargo fmt --check+cargo clippy --lib: clean.get_tables_empty_table_types_filter_matches_none(the nightly-red test) passes against a real warehouse viaDATABRICKS_KERNEL_PATH→ this branch,--proxy-mode passthrough.Related
KERNEL_REPO_TAGpin picks this up on the next routine bump; ODBCSQLTablesbehavior is unchanged (empty CSV still → match-all via the restored collapse).This pull request and its description were written by Isaac.