[BUG] SEA metadata SHOW ... LIKE under-escapes backslashes; schema/table names containing '\' never match
I maintainer di solito rispondono entro 1 giorno
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 72/100
Direzione di ricerca
Iniziate in CommandBuilder.java, in corrispondenza delle chiamate a jdbcPatternToHive alle righe 52, 58 e 64, quindi esaminate i punti di interpolazione di LIKE_SQL, SCHEMA_LIKE_SQL e TABLE_LIKE_SQL indicati nell’issue. Riproducete la ricerca dei metadati SEA con un nome di schema o di tabella contenente una barra rovesciata letterale e confermate che tutte le chiamate ai metadati interessate la restituiscano con l’escaping SQL corretto.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
The SEA (Statement Execution API) metadata path under-escapes backslashes when
building SHOW ... LIKE '<pattern>', so a schema/table/column whose name
literally contains a backslash can never be matched via getSchemas /
getTables / getColumns. Escaping the pattern with the JDBC escape char does
not help.
Root cause
CommandBuilder sets the pattern via WildcardUtil.jdbcPatternToHive(pattern)
(CommandBuilder.java:52/58/64) and then interpolates the result directly into
" LIKE '%s'" (LIKE_SQL, CommandBuilder.java:93/113/116/136/144). Only the
catalog identifier is escaped (escapeSqlIdentifier); the LIKE pattern value is not.
The glob is embedded in a single-quoted SQL string literal, so on the server
the SQL string-literal parser consumes one backslash layer before the
SHOW ... LIKE matcher (a regex; StringUtils.filterPattern, only *→.*
substituted) sees the pattern. jdbcPatternToHive emits \\ for an escaped
backslash, but that becomes a single \ after the string-literal parse, which the
regex then consumes as an escape — so the literal backslash is lost and nothing matches.
To match a literal backslash the LIKE string needs the backslash quadrupled
(survives string-literal halving → then regex halving); the driver only doubles it.
To Reproduce
- Create a schema whose name contains a backslash:
CREATE SCHEMA `some_catalog`.`a\b`; - Connect with the SEA path (e.g.
usethriftclient=0/ SEA-enabled connection). - Call
connection.getMetaData().getSchemas("some_catalog", "a\\b")(JDBC pattern
a\b— a literal backslash escaped for Java is"a\\b").
Expected behavior
Returns the schema a\b.
Actual behavior
Returns an empty result set. The driver emits
SHOW SCHEMAS IN some_catalog LIKE 'a\\b'; after the server's string-literal
parse this becomes regex a\b where \b is a word boundary, so nothing matches.
(Correct SQL would be LIKE 'a\\\\b'.)
Direct SQL confirmation (same warehouse, run manually):
SHOW SCHEMAS IN <cat> LIKE 'a\\b'→[](what the driver sends today)SHOW SCHEMAS IN <cat> LIKE 'a\\\\b'→a\b(correct — 4 backslashes)
Suggested fix
Escape backslashes for the SQL string literal at the LIKE '%s' interpolation
(e.g. schemaPattern.replace("\\", "\\\\") after jdbcPatternToHive), leaving
jdbcPatternToHive itself unchanged. Apply to all LIKE_SQL / SCHEMA_LIKE_SQL
/ TABLE_LIKE_SQL sites in CommandBuilder.
Additional context
Found while aligning the ADBC C# Databricks driver's SEA metadata behavior; ADBC
shares the identical jdbcPatternToHive→LIKE '%s' construction and had the same
bug. Verified live against schemas named a_b, a\b, a\_b, a\\b. Backslashes
in identifiers are rare, so real-world impact is low, but the SEA vs Thrift behavior
differs here (Thrift has its own separate server-side exact-match issue with
backslash names). Filing for parity/tracking.
- Driver Version: main (SEA metadata path)
- Lingua principale
- Java
- Stelle
- 41
- Fork
- 49
- Merge medio
- 1g 7h
- PR unite (30g)
- 27
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di databricks/databricks-jdbc
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
databricks/databricks-jdbc#1782 ·
I maintainer di solito rispondono entro 1 giorno
-
engineer-bot
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
databricks/databricks-jdbc#1568 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
[FEATURE] Lossless java.time support in getObject(col, Class) for DATE/TIMESTAMP (BC and pre-1582 values)Forse già presa @cathleeny l’ha presa oggi. Aperta
Difficoltà 5/5 Più di una settimana Idoneità per principianti 25/100
databricks/databricks-jdbc#1779 · 2 commenti ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 68/100
databricks/databricks-jdbc#1770 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
databricks/databricks-jdbc#1763 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di databricks/databricks-jdbc
Issue simili
-
Type: Bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 83/100
MovingBlocks/Terasology#5415 ·
-
type: possible bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
-
面渣逆袭Spring事务传播机制勘误Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
itwanger/toBeBetterJavaer#218 ·
-
Markdown and Astro language servers do not start when the project path contains a non-ASCII character or a spaceForse già presa @RoiSoleil l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
eclipse-wildwebdeveloper/wildwebdeveloper#2277 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
openrewrite/rewrite-spring#1286 ·
I maintainer di solito rispondono entro 1 giorno