From 960a43841986dcc6be42dbc0cf81378fa22639ec Mon Sep 17 00:00:00 2001 From: "peco-engineer-bot[bot]" <3815206+peco-engineer-bot[bot]@users.noreply.github.com> Date: Thu, 30 Jul 2026 01:07:40 +0000 Subject: [PATCH 1/3] Metadata::list_tables treats empty table_types slice as match-none (should match all, like null) (#187) Signed-off-by: peco-engineer-bot[bot] <3815206+peco-engineer-bot[bot]@users.noreply.github.com> --- src/metadata/thrift_shape.rs | 27 +++++----- tests/v0_metadata_empty_types_e2e.rs | 81 ++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 15 deletions(-) create mode 100644 tests/v0_metadata_empty_types_e2e.rs diff --git a/src/metadata/thrift_shape.rs b/src/metadata/thrift_shape.rs index 97158ad5..07bdf1d8 100644 --- a/src/metadata/thrift_shape.rs +++ b/src/metadata/thrift_shape.rs @@ -516,17 +516,14 @@ pub(crate) fn reshape_tables( // Apply table_types filter, if requested. The JDBC `DatabaseMetaData. // getTables(...)` Javadoc specifies that `null` types returns all // types, but is silent on what an *explicit empty array* means. - // Two interpretations exist in the wild: - // - Empty == null (returns all rows). Convenient, but conflates - // "I didn't filter" with "I asked for nothing". - // - Empty == "filter accepting nothing" (returns zero rows). Literal - // reading of the filter contract. - // The Databricks Thrift backend follows the literal reading: zero - // rows on `types=[]`. We match Thrift here for cross-backend parity - // (verified via the python-comparator). Callers that want "all - // types" should pass `None`, not `Some(&[])`. + // Per the multi-language conformance spec (METADATA-035) and the C# + // ADBC driver, an explicit *empty* array is equivalent to `null`: + // it matches ALL table types, not none. Only a `Some` with at least + // one entry actually restricts the result set. This mirrors JDBC + // #1570 / hiveserver2 #72, which align the same way. let filtered = match table_types { None => reshaped, + Some([]) => reshaped, Some(types) => filter_tables_by_type(&reshaped, types)?, }; // Sort to match the JDBC driver's `getTables` row order @@ -1052,14 +1049,14 @@ mod tests { } #[test] - fn tables_empty_types_filter_returns_zero_rows() { - // Matches Thrift's behavior: explicit `Some(&[])` is a filter - // that accepts no table types, so the result is empty. - // `None` (caller didn't pass a type filter at all) is the - // separate "all types" path — see `tables_none_types_passes_all`. + fn tables_empty_types_matches_all() { + // Per the JDBC/ADBC contract (spec METADATA-035), an explicit + // empty `table_types` slice is equivalent to `None`: it matches + // ALL table types, not none. This is the same result as the + // `None` path — see `tables_none_types_passes_all`. let b = server_tables_full(); let out = reshape_tables(&b, Some("main"), Some(&[])).unwrap(); - assert_eq!(out.num_rows(), 0); + assert_eq!(out.num_rows(), 3); } #[test] diff --git a/tests/v0_metadata_empty_types_e2e.rs b/tests/v0_metadata_empty_types_e2e.rs new file mode 100644 index 00000000..23e60bba --- /dev/null +++ b/tests/v0_metadata_empty_types_e2e.rs @@ -0,0 +1,81 @@ +// Copyright (c) 2026 Databricks, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//! E2E repro for issue #187: `Metadata::list_tables` must treat an empty +//! `table_types` slice (`Some(&[])`) the same as `None` — match ALL table +//! types — per the JDBC/ADBC contract (spec METADATA-035), not "match none". +//! +//! Run with: +//! ```sh +//! cargo test --test v0_metadata_empty_types_e2e -- --ignored --nocapture +//! ``` + +mod common; + +use databricks_sql_kernel::{Identifier, LikePattern, ResultBatch, ResultStream}; + +async fn count_rows(mut stream: ResultStream) -> usize { + let mut rows = 0; + while let Some(rb) = stream.next_batch().await.expect("next_batch") { + let ResultBatch::Arrow(rb) = rb else { + panic!("expected Arrow batch in v0"); + }; + rows += rb.num_rows(); + } + rows +} + +#[tokio::test] +#[ignore] +async fn empty_table_types_matches_all_like_none() { + let session = common::live_session().await; + + // `samples.information_schema` is a UC-managed schema present in every + // workspace and exposes many objects (a mix of views), so both the + // `None` and `Some(&[])` calls should return a positive, equal count. + let catalog = || Some(Identifier::new("samples").unwrap()); + let schema = || Some(LikePattern::new("information_schema").unwrap()); + + let none_rows = count_rows( + session + .metadata() + .list_tables(catalog(), schema(), None, None) + .await + .expect("list_tables(None)"), + ) + .await; + + let empty_rows = count_rows( + session + .metadata() + .list_tables(catalog(), schema(), None, Some(&[])) + .await + .expect("list_tables(Some(&[]))"), + ) + .await; + + assert!( + none_rows > 0, + "precondition: samples.information_schema should expose tables via None filter; got 0" + ); + // The bug: with the unfixed kernel, `Some(&[])` drops every row → 0, + // while `None` returns `none_rows`. This assertion is red pre-fix. + assert_eq!( + empty_rows, none_rows, + "empty table_types slice must match all types (same as None): \ + None returned {none_rows} rows, Some(&[]) returned {empty_rows}" + ); + + session.close().await.expect("close"); +} From 80e99183a55caee4f5f5f76f0963b6d121239564 Mon Sep 17 00:00:00 2001 From: "peco-engineer-bot[bot]" Date: Thu, 30 Jul 2026 01:16:11 +0000 Subject: [PATCH 2/3] ai: apply changes for #201 (1 review thread) Addresses: - #3679159308 at src/metadata/thrift_shape.rs:519 Signed-off-by: peco-engineer-bot[bot] --- src/metadata/thrift_shape.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/metadata/thrift_shape.rs b/src/metadata/thrift_shape.rs index 07bdf1d8..12135fb2 100644 --- a/src/metadata/thrift_shape.rs +++ b/src/metadata/thrift_shape.rs @@ -467,9 +467,12 @@ pub(crate) fn reshape_schemas( /// when they're missing. /// /// `requested_catalog` fills `TABLE_CAT` rows for server responses -/// that omit it (single-catalog form). `table_types`, when `Some`, -/// filters rows to those whose `TABLE_TYPE` appears in the slice -/// (matches JDBC `DatabaseMetaData.getTables` behaviour). +/// that omit it (single-catalog form). `table_types`, when `Some` with +/// at least one entry, filters rows to those whose `TABLE_TYPE` appears +/// in the slice (matches JDBC `DatabaseMetaData.getTables` behaviour). +/// A `Some(&[])` (explicit empty slice) is treated like `None` and +/// matches all table types — see the inline note in the filter block +/// below (METADATA-035 conformance / C# ADBC parity). pub(crate) fn reshape_tables( batch: &RecordBatch, requested_catalog: Option<&str>, From 94590cffc96c9f071e2a350c1d9bf51833643eef Mon Sep 17 00:00:00 2001 From: Vikrant Puppala Date: Mon, 10 Aug 2026 05:27:11 +0000 Subject: [PATCH 3/3] test: fix list_tables signature in empty-types e2e after merge The #187 empty-table_types repro test called list_tables with an Identifier catalog argument, but main's wildcard-catalog fan-out changed the catalog parameter to Option. Update the test helper to build a LikePattern and drop the now-unused Identifier import. Signed-off-by: Vikrant Puppala --- tests/v0_metadata_empty_types_e2e.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/v0_metadata_empty_types_e2e.rs b/tests/v0_metadata_empty_types_e2e.rs index 23e60bba..f5b8d2f9 100644 --- a/tests/v0_metadata_empty_types_e2e.rs +++ b/tests/v0_metadata_empty_types_e2e.rs @@ -23,7 +23,7 @@ mod common; -use databricks_sql_kernel::{Identifier, LikePattern, ResultBatch, ResultStream}; +use databricks_sql_kernel::{LikePattern, ResultBatch, ResultStream}; async fn count_rows(mut stream: ResultStream) -> usize { let mut rows = 0; @@ -44,7 +44,7 @@ async fn empty_table_types_matches_all_like_none() { // `samples.information_schema` is a UC-managed schema present in every // workspace and exposes many objects (a mix of views), so both the // `None` and `Some(&[])` calls should return a positive, equal count. - let catalog = || Some(Identifier::new("samples").unwrap()); + let catalog = || Some(LikePattern::new("samples").unwrap()); let schema = || Some(LikePattern::new("information_schema").unwrap()); let none_rows = count_rows(