[SEA] Fix list_schemas to return empty rowset instead of throwing on non-matching catalog patterns (PECO-3017)#443
Open
eric-wang-1990 wants to merge 1 commit into
Open
Conversation
Previously, GetSchemasAsync passed the catalogPattern argument directly to ShowSchemasCommand as a literal backtick-quoted identifier. This caused server errors for any pattern that wasn't an exact existing catalog name: - "%" → SHOW SCHEMAS IN `%` (invalid) - "compar%" → SHOW SCHEMAS IN `compar%` (invalid) - "comparator\_tests" → SHOW SCHEMAS IN `comparator\_tests` (wrong catalog) - "" (empty string) → SHOW SCHEMAS IN `` (invalid) - "nonexistent" → server error if catalog doesn't exist Fix: classify the catalogPattern and route accordingly: - null → SHOW SCHEMAS IN ALL CATALOGS (unchanged) - "" → return empty rowset immediately - pattern with unescaped % or _ → SHOW SCHEMAS IN ALL CATALOGS, filter rows by catalog regex built from the ADBC pattern (client-side) - literal name (may contain \_ or \% escapes) → decode escapes, try SHOW SCHEMAS IN `catalog`, catch AdbcException → return empty rowset Three new internal static helpers power the fix: - ContainsUnescapedWildcard: detects % or _ not preceded by backslash - CatalogPatternToRegex: converts ADBC/SQL pattern to a case-insensitive Regex, mapping % → .*, _ → ., \_ → _, \% → %, \\ → \ - DecodeLiteralPattern: strips ADBC escape sequences from literal patterns Add 29 unit tests in GetSchemasAsyncTests covering all six bug-report cases plus edge cases for each helper. 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
GetObjects(depth=DbSchemas)threwDatabricksExceptionfor any catalog argument that was not an exact-match against an existing catalog name, instead of returning an empty rowset.%,compar%,comparator\_tests,"","nonexistent". Additionallycomparator_tests(unescaped_) returned empty instead of matching via wildcard semantics.GetSchemasAsync()passed the catalog pattern verbatim as a backtick-quoted SQL identifier, generating invalid SQL (e.g.SHOW SCHEMAS IN \%``) that the server rejected.GetSchemasAsync()now classifies the catalog pattern and routes accordingly:null→SHOW SCHEMAS IN ALL CATALOGS(unchanged)%or_→SHOW SCHEMAS IN ALL CATALOGSthen filter rows client-side using a regex built from the ADBC pattern\_/\%escapes) → decode escapes, executeSHOW SCHEMAS IN \catalog`, catchAdbcException` and return empty rowset for nonexistent catalogsTest plan
GetSchemasAsyncTests.cscovering all six bug-report scenarios and helper methodsdotnet buildpasses — 0 errorsFixes PECO-3017
🤖 Generated with Claude Code