[SEA] Fix GetCatalogsAsync to handle ADBC catalog patterns correctly (PECO-3018)#441
Open
eric-wang-1990 wants to merge 1 commit into
Open
[SEA] Fix GetCatalogsAsync to handle ADBC catalog patterns correctly (PECO-3018)#441eric-wang-1990 wants to merge 1 commit into
eric-wang-1990 wants to merge 1 commit into
Conversation
…(PECO-3018)
Root cause (D8 and related cases): GetCatalogsAsync passed the ADBC
catalogPattern directly to ShowCatalogsCommand which appended it as a
SQL LIKE clause via ConvertPattern(). This was wrong because:
- "comparator\_tests" → SHOW CATALOGS LIKE 'comparator_tests'
SQL _ is a wildcard, so the literal underscore was lost.
The literal catalog "comparator_tests" would technically still be
found, but so would "comparatorXtests" and any other single-char
variation (too broad).
- "%" → SHOW CATALOGS LIKE '*' — glob '*' is not valid SQL LIKE
syntax in all contexts.
- "" → SHOW CATALOGS LIKE '' — returns nothing; correct by accident
but handled explicitly now.
Fix: mirror the Thrift path (HiveServer2Connection.GetCatalogsAsync)
which fetches ALL catalogs and filters client-side using PatternToRegEx.
- null → SHOW CATALOGS, no filter (return all)
- "" → return empty list immediately (no server call)
- other → SHOW CATALOGS, filter results with CatalogPatternToRegex
Two new internal static helpers:
- ContainsUnescapedWildcard: detects % or _ not preceded by backslash
- CatalogPatternToRegex: converts ADBC/SQL pattern to a case-insensitive
anchored Regex: % → .*, _ → ., \_ → _, \% → %, \\ → \
Also skip Thrift-specific E2E tests when running against SEA-only endpoints
(CloseOperationE2ETest and SeaMetadataE2ETests).
Signed-off-by: Eric Wang <e.wang@databricks.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes the D8 bug case in
IGetObjectsDataProvider.GetCatalogsAsyncon the SEA (Statement Execution API) path.Root cause:
GetCatalogsAsyncpassed the ADBCcatalogPatterndirectly toShowCatalogsCommand, which converted it viaConvertPattern()and appended it as a SQLLIKEclause. This was wrong because:"comparator\_tests"→SHOW CATALOGS LIKE 'comparator_tests'SQL
_is a wildcard, so the escaped literal underscore was lost. The catalogcomparator_testswould be found but so wouldcomparatorXtests(too broad)."%"→SHOW CATALOGS LIKE '*'— glob*is not valid SQL LIKE syntax.""→SHOW CATALOGS LIKE ''— happened to return nothing, but by accident.Fix: Mirror the Thrift path (
HiveServer2Connection.GetCatalogsAsync) which fetches all catalogs via a bareSHOW CATALOGSrequest and filters results client-side using a pattern-to-regex conversion:catalogPatternnullSHOW CATALOGS, no filter — return all (JDBC spec: null = any)""SHOW CATALOGS, filter results withCatalogPatternToRegex(pattern)New helpers (analogous to
PatternToRegExin the Thrift layer):ContainsUnescapedWildcard: detects%or_not preceded by backslashCatalogPatternToRegex: converts ADBC/SQL pattern to anchored case-insensitiveRegex%→.*,_→.,\_→_,\%→%,\\→\Also includes minor E2E test fixes to skip Thrift-specific tests when running against SEA-only endpoints.
Note on hiveserver2: This fix is entirely within the Databricks-specific layer (
csharp/src/StatementExecution/). No changes were made tocsharp/hiveserver2/(the upstream submodule).Test plan
GetCatalogsAsyncTests.cscovering all pattern casesContainsUnescapedWildcard: 10 theory casesCatalogPatternToRegex: wildcard expansion, escaped literals, case-insensitivity, regex-char escapingcomparator\_tests,comparator_tests,%,compar%,"",nonexistentdotnet test --filter "FullyQualifiedName~StatementExecution"→ 174 passed, 29 skipped (E2E only)dotnet build AdbcDrivers.Databricks.csprojFixes #PECO-3018