Metadata queries break on catalog, schema or table names containing a quote or backslash
I maintainer di solito rispondono entro 6 giorni
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
Direzione di ricerca
Start with the listed macros in relations/tags.sql, relations/components/, adapters/catalog.sql, adapters/metadata.sql, and materializations/clone/strategies.sql; compare their string literal handling with relations/components/comment.sql. Also inspect show_table_extended_sql and check_schema_exists_sql for the related LIKE pattern issue. Add unit cases for names containing both a quote and a backslash, and confirm the generated SQL escapes both correctly across the affected macros.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
Several metadata macros paste relation names straight into SQL string literals without escaping them. Unity Catalog allows a ' or \ in a catalog, schema or table name when the name is backtick-quoted, for example `orders'eu`. For such a relation, the generated query is invalid:
... WHERE table_catalog = 'main' AND table_schema = 'prod' AND table_name = 'orders'eu'
The query fails to parse, so the materialization or command that issued it fails before running any DDL. Identifier quoting in these macros is fine; only the string literals are affected.
Affected macros (all build = '{{ relation.<part>|lower }}' predicates):
relations/tags.sql:fetch_tags_sqlrelations/components/row_filter.sql:fetch_row_filters_sqlrelations/components/column_mask.sql:fetch_column_masks_sqlrelations/components/column_tags.sql:fetch_column_tags_sqlrelations/components/constraints.sql:fetch_non_null_constraint_columns_sql,fetch_primary_key_constraints_sql,fetch_foreign_key_constraints_sqladapters/catalog.sql:databricks__get_catalog_schemas_where_clause_sql,databricks__get_catalog_relations_where_clause_sqladapters/metadata.sql:get_relation_last_modified_sql,get_view_description_sql,get_uc_tables_sqlmaterializations/clone/strategies.sql:clone_source_policies_sql, added in #1745, which runs on everydbt cloneof a Unity Catalog table.
Related, but a different quoting problem: show_table_extended_sql and check_schema_exists_sql build LIKE '<name>' patterns from relation names. Those need both literal escaping and LIKE-pattern handling.
Steps To Reproduce
CREATE SCHEMA main.quote_probe;
CREATE TABLE main.quote_probe.`orders'eu` (id INT);
-- What fetch_row_filters_sql / clone_source_policies_sql generate today: fails to parse
SELECT 1 FROM main.information_schema.row_filters
WHERE table_catalog = 'main' AND table_schema = 'quote_probe' AND table_name = 'orders'eu';
-- Escaped: runs, and finds the filter once one is set
SELECT 1 FROM main.information_schema.row_filters
WHERE table_catalog = 'main' AND table_schema = 'quote_probe' AND table_name = 'orders\'eu';
In dbt, a model with alias: "orders'eu" hits this as soon as one of the macros above runs for it. Examples:
dbt cloneonce #1745 lands.- Tag or constraint diffs on a later
dbt run. dbt docs generate, which goes through the catalog macros.
Expected behavior
Every relation-name string literal in generated SQL is escaped, \ first and then ', the way relations/components/comment.sql already escapes comments: | replace("\\", "\\\\") | replace("'", "\\'"). A shared helper macro would keep the call sites consistent. Each fixed *_sql macro gets a unit case with a name containing ' and \.
System information
Reproduced on a Unity Catalog SQL warehouse against the 1.13.latest branch. The pattern is the same on main.
Additional context
Found while reviewing #1745. We agreed to fix all call sites together on the next .latest branch rather than in that PR.
- Lingua principale
- Python
- Stelle
- 391
- Fork
- 231
- Merge medio
- 9g 7h
- PR unite (30g)
- 29
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/dbt-databricks
-
persist_docs.columns triggers a full-plan probe query on views even when the model has no column docsForse già presa @DelorneN007 l’ha presa 59 giorni fa. Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
databricks/dbt-databricks#1680 · 1 commento ·
I maintainer di solito rispondono entro 6 giorni
-
bug
Difficoltà 2/5 Mezza giornata Idoneità per principianti 68/100
databricks/dbt-databricks#1003 · 1 commento ·
I maintainer di solito rispondono entro 6 giorni
-
Emit COMMENT and DEFAULT for function arguments and descriptions in CREATE FUNCTIONForse già presa @alvinism l’ha presa 7 giorni fa. Apertaenhancement
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
databricks/dbt-databricks#1764 ·
I maintainer di solito rispondono entro 6 giorni
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 46/100
databricks/dbt-databricks#1762 ·
I maintainer di solito rispondono entro 6 giorni
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
databricks/dbt-databricks#1761 ·
I maintainer di solito rispondono entro 6 giorni
Tutte le issue di databricks/dbt-databricks
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 67/100
FinanceFlash/unvibecode#699 ·
I maintainer di solito rispondono entro 1 giorno
-
enhancement Website
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
OWASP/OWASP-Hunting#96 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
micropython/micropython#19942 ·
I maintainer di solito rispondono entro 1 giorno
-
A rebuild posts "not part of this build" success to the commit's failed `nix-build` gate and effectsForse già presa @Padraic-O-Mhuiris l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
I maintainer di solito rispondono entro 1 giorno
-
`epoch.Integer` raises a raw OverflowError for integers too large to convert to a floatForse già presa @arindam77 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
pydantic/pydantic-extra-types#479 ·
I maintainer di solito rispondono entro 1 giorno