Repository navigation
fix(metadata): handle empty catalog filters - #301
Conversation
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
There was a problem hiding this comment.
Verdict: 1 Low
Looks good — the empty-catalog → empty-pattern routing is consistent with the existing LikePattern::new("") "match nothing" convention (src/metadata_v0.rs:237-262), the short-circuits sit before any wire call, and the change is well-covered by unit, wiremock, and pyo3 tests. One low note: the helper discards (and no longer validates) the supplied pattern in the empty-catalog branch.
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
There was a problem hiding this comment.
Verdict: 1 Low
Looks good — clean, well-tested fix. Empty catalogs are mapped to an empty pattern that short-circuits to a typed empty result before any wire call, which is correct (empty LIKE matches nothing, matching JDBC parity) and consistent with the existing list_tables empty-pattern handling. Lifetimes, resource lifecycle, and error paths all check out; one minor test-coverage note for the napi binding is inline.
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
There was a problem hiding this comment.
Verdict: 1 Low
Looks good — clean, well-scoped fix. Empty catalog is correctly encoded onto the schema-pattern dimension via exact_catalog_and_pattern, and the empty-pattern short-circuit is correctly placed before any wire call in both list_schemas and list_columns (the helper doc comment explicitly documents this ordering invariant). Schema constants (GET_SCHEMAS_SCHEMA/GET_COLUMNS_SCHEMA) and EmptyReader all exist and match the tests. One low-severity coverage note inline about the untested table/column empty-pattern branches.
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com>
There was a problem hiding this comment.
Verdict: 2 Low
Looks good — a clean, well-tested change. Empty catalog is routed to an empty LikePattern that the kernel short-circuits before any wire call, consistent with the existing list_tables empty-catalog semantics, and covered by wiremock + unit tests across all three surfaces. Two low-severity notes: a #[cfg(test)] runtime-handle divergence in the napi binding that leaves the production get_handle() path unexercised by these tests, and relaxed pattern validation when the catalog is empty.
| // that global and race the cold-cache runtime test. | ||
| #[cfg(not(test))] | ||
| let handle = crate::runtime::get_handle().clone(); | ||
| #[cfg(test)] |
There was a problem hiding this comment.
🔵 Low — The run_on_blocking handle acquisition now diverges between build profiles: production uses crate::runtime::get_handle(), but #[cfg(test)] builds use tokio::runtime::Handle::current(). This is a reasonable way to keep the new in-crate wiremock test from mutating/racing the process-global runtime cache, but it means the napi crate's own tests (including the new empty_catalog_metadata_calls_return_empty_without_statement_request) never exercise the production get_handle() path. A regression in the global-handle capture would not be caught by these tests. The tradeoff is documented in the comment, so this is only a coverage note — consider a separate test that specifically covers the get_handle() path if it isn't covered elsewhere.
| /// to match nothing rather than fail validation. Encode that case as an empty | ||
| /// [`LikePattern`] on the accompanying pattern dimension; metadata methods | ||
| /// short-circuit empty patterns to a typed empty result before any wire call. | ||
| pub fn exact_catalog_and_pattern<'a>( |
There was a problem hiding this comment.
🔵 Low — When catalog == Some(""), exact_catalog_and_pattern returns early with (None, Some(LikePattern::new(""))) and never validates the caller-supplied pattern. Previously (LikePattern::from_opt(&schema_pattern)?) a whitespace-only / NUL / oversized schema pattern paired with an empty catalog would surface as InvalidArgument; now it is silently accepted and the call returns an empty result. This is arguably fine since an empty catalog matches nothing regardless of the pattern, but it is a behavior change in input validation strictness worth being intentional about. No action needed if the relaxed validation is the intent (the empty-catalog result is empty either way).
Treat empty catalog strings passed to
list_schemasandlist_columnsas empty metadata patterns, returning typed empty results without a wire call. Non-empty catalog names remain exact identifiers, and the C ABI's existing empty-as-unset behavior is unchanged.This supports databricks/databricks-sql-python#933 without weakening identifier validation globally.
Validated with the full Rust, PyO3, and N-API test suites, plus clippy and formatting checks.
This PR was created with GitHub MCP.