Skip to content

fix(csharp): treat catalog as a literal name on the Thrift metadata path (#525)#574

Open
eric-wang-1990 wants to merge 1 commit into
mainfrom
fix/thrift-catalog-literal-525
Open

fix(csharp): treat catalog as a literal name on the Thrift metadata path (#525)#574
eric-wang-1990 wants to merge 1 commit into
mainfrom
fix/thrift-catalog-literal-525

Conversation

@eric-wang-1990

Copy link
Copy Markdown
Collaborator

Summary

Makes the Thrift metadata path treat the catalog argument of GetSchemas/GetTables/GetColumns as an exact-name identifier, not a SQL-LIKE pattern — matching the SEA path and PR #536.

Today the catalog is sent to the server's Thrift GetSchemas/GetTables/GetColumns RPC as a pattern, so _/% act as wildcards and over-match. Per the JDBC/ODBC contract (catalog is an exact name; only schema/table/column are patterns) and for Thrift↔SEA parity, catalog should match literally.

Change

DatabricksStatement normalizes the catalog after SPARK handling and before the base RPC call (NormalizeCatalogForThrift):

The AdbcDrivers.HiveServer2 submodule is not modified; the change lives entirely in the Databricks-owned DatabricksStatement overrides.

Evidence (live Thrift warehouse)

Verified against a live Thrift SQL warehouse via GetSchemas:

catalog arg matched
None / % / * all catalogs
comparator_tests (unescaped _) comparator-tests AND comparator_tests (over-match)
comparator\_tests (escaped) comparator_tests only (literal)

So escaping produces the correct literal match, and %/* still return all catalogs.

Test plan

  • Unit: DatabricksStatementUnitTests.NormalizeCatalogForThrift_NormalizesAndEscapesCatalog — 11 cases: %/*/null→null, plain name unchanged, _/% escaped (flag off), no double-escape (flag on).
  • CI runs unit + E2E (the change targets net10.0 via the submodule; couldn't build locally on SDK 9.0 — will validate in CI).

Notes

This pull request and its description were written by Isaac.

…ath (#525)

On the Thrift metadata path (GetSchemas/GetTables/GetColumns) the catalog
argument was sent to the server's GetSchemas/GetTables/GetColumns RPC as a
SQL-LIKE pattern, so `_`/`%` acted as wildcards and over-matched — e.g.
catalog "comparator_tests" also matched "comparator-tests". Per the JDBC/ODBC
contract (and the SEA path), catalog is an exact-name identifier, not a
pattern.

DatabricksStatement now normalizes the catalog before the base RPC call:
- a bare match-all wildcard ("%"/"*") becomes null ("all catalogs"), mirroring
  the SEA path (StatementExecutionStatement.EffectiveCatalog) / PR #536;
- any other catalog name has its "_"/"%" escaped so the server matches it
  literally (the Thrift server honors the "\_"/"\%" escape — verified against a
  live warehouse). When escape_pattern_wildcards is already enabled the base
  class escapes catalog itself, so we skip here to avoid double-escaping.

Adds a unit test covering the transform (bare wildcard -> null, escaping with
the flag off, and no double-escape with the flag on).

Co-authored-by: Isaac
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.

1 participant