Repository navigation
Escape _ in metadata catalog_name by default (behavior change) - #1029
vuanhphung wants to merge 4 commits into
Conversation
Behavior change: escape_catalog_name now defaults to True, so `_` in catalog_name is no longer a single-character wildcard for Thrift schemas()/tables()/columns() or kernel tables(). `%` still works, and escape_catalog_name=False restores the old behavior. This follows the JDBC/ODBC metadata spec (catalog is an exact name) and the Databricks JDBC driver's default since v3.3.1. The server treats Thrift catalogName as a LIKE pattern, so an unescaped `_` returned rows from other catalogs (comparator-tests for comparator_tests) and made the server scan every catalog (~170 ms per call on underscore catalogs). Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
Verdict: 2 Low
Looks good, with two low-severity points. The new default is applied the same way at all three sites (Thrift, kernel client, session forwarding), and the unit and e2e tests cover the default, opt-out and opt-in cases. The two findings are an opt-out check that a string like "false" doesn't actually disable, and a tables() docstring that is less precise than the others.
Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
Verdict: 1 Medium
The default flip itself looks right: all three default sites (Thrift, kernel client, session forwarding) are updated together, and the docs and tests agree with the new default. I have one medium concern. The new e2e test skips hive_metastore, which is the most common catalog name with _, so nothing checks that escaping it by default doesn't break metadata calls on that catalog.
…g names Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
There was a problem hiding this comment.
Verdict: 1 Low · 1 Nit
The default flip looks correct, and docs, CHANGELOG and tests were all updated consistently. I found two low-severity issues: an explicit escape_catalog_name=None (or a string value) now resolves differently from the new default, and the spark_catalog e2e assertion can't fail on the improvement the PR claims. A nit outside this diff: the regex in escape_metadata_catalog_name uses a one-character lookbehind (it ignores whether the preceding backslash run is even or odd), and that approximation now runs on every catalog name by default.
Other findings
- ⚪ Nit — The PR description says escaping now makes Thrift
schemas(catalog_name="spark_catalog")resolve tohive_metastore, where before it returned nothing. This assertion (rows(raw, ...) <= rows(escaped, ...)) passes trivially when both sides are empty. It also passes if escaping still returns nothing forspark_catalog, so it never checks the improvement the PR claims. If that behavior is meant to be guaranteed, also assert that the escaped result is non-empty (skip whenhive_metastore.defaultisn't visible, as the earlier block already does).
An explicit None (e.g. from a wrapper forwarding unset options) used to match the old False default; keep it meaning "not set" now that the default is True. Also assert that escaped spark_catalog resolves. Signed-off-by: Vu Anh Phung <vu.phung@databricks.com> Co-authored-by: Isaac <no-reply@databricks.com>
|
Review-body nits from the round on ed49b2e:
|
What type of PR is this?
Description
Behavior change:
escape_catalog_name(added opt-in in #985) now defaults toTrue._incatalog_nameis no longer a single-character wildcard in Thriftschemas()/tables()/columns()or in kerneltables().%still works as a wildcard, andescape_catalog_name=Falserestores the old behavior. The JDBC/ODBC metadata spec treats the catalog as an exact name, not a pattern, and the Databricks JDBC driver has escaped_by default since v3.3.1 (TreatMetadataCatalogNameAsPattern=0). Kernelschemas()/columns()and SEA already match the exact name, so this makes all backends agree by default.Correctness: the server treats Thrift
catalogNameas a LIKE pattern, so today an unescaped_can return rows from other catalogs. On our test workspace,cursor.columns(catalog_name="comparator_tests")returns 631 rows fromcomparator_testsplus 488 rows fromcomparator-tests. With this change it returns only the 631.hive_metastorereturns identical rows with and without escaping on both backends.spark_catalogimproves: on Thrift,schemas(catalog_name="spark_catalog")used to return nothing, because the unescaped pattern matches no listed catalog. Escaped, it resolves tohive_metastore, as kernel already does.Latency: the same pattern makes the server scan every catalog. That is the ~200 ms Thrift-vs-kernel gap in the nightly metadata benchmark, whose fixture catalog is
jdbcbenchmarkingcatalog_<id>. The client side is already minimal: each call is one RPC with full direct results and 1–2 ms of client CPU. Query History shows 215–263 ms of server time unescaped vs 38–92 ms with\_.tables()showed no gap only because kerneltables()sent the same pattern.Median (p95) ms on a live serverless Medium warehouse, catalog
jacky_test(3 schemas), nightly-suite arguments. Fresh processes ranmainand this branch interleaved, 6 runs × 5 calls per side. Row counts are identical.schemas(cat, "%")schemas(cat, "def%")tables(cat, "default", "%")columns(cat, "default", "customer", "%")columns(cat, "%", "%", "%")schemas("peco", "def%"), no_How is this tested?
The unit tests now state the expected default explicitly, and the backend-level forwarding tests assert the escaped name. The full unit suite and
-m realkernelpass. New e2e tests run on Thrift and kernel:syste_matches nothing by default and matchessystemwith the opt-out.\_.hive_metastoreschemas()/tables()(Thrift) andtables()(kernel) return the same rows with and without escaping, andspark_catalogloses no rows.The new e2e tests fail on
mainand pass here. The existing Thrift and kernel metadata e2e tests also pass on the live warehouse.Related Tickets & Documents
#985
This pull request and its description were written by Isaac.