Repository navigation
fix(warehouse): quote bigquery identifiers - #7366
Merged
Merged
Conversation
achettyiitr
force-pushed
the
harness/INT-6791-quote-bigquery-identifiers
branch
2 times, most recently
from
September 17, 2026 11:15
6ff9fb6 to
f0bec05
Compare
achettyiitr
marked this pull request as ready for review
September 17, 2026 12:15
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #7366 +/- ##
==========================================
- Coverage 83.79% 83.27% -0.53%
==========================================
Files 622 622
Lines 61979 61991 +12
==========================================
- Hits 51936 51621 -315
- Misses 10040 10367 +327
Partials 3 3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
1 task done
achettyiitr
force-pushed
the
harness/INT-6791-quote-bigquery-identifiers
branch
from
September 18, 2026 04:29
fec8b8e to
9e7b3db
Compare
achettyiitr
changed the base branch from
master
to
feature/int-6791-warehouse-identifier-utils
September 18, 2026 04:29
saikumarrs
approved these changes
Sep 21, 2026
achettyiitr
added a commit
that referenced
this pull request
Sep 23, 2026
… helpers (#7406) # Description The warehouse integrations each build SQL from schema, table and column names that originate from event payloads. Quoting those names correctly is dialect specific, and the rules were about to be duplicated in every integration package. This PR adds them once in `warehouse/utils/identifier.go`: **Identifiers** | Helper | Dialect | Escaping | | --- | --- | --- | | `DoubleQuoteIdentifier` | Postgres, Redshift, Snowflake | `"` doubled | | `BracketQuoteIdentifier` | MSSQL, Azure Synapse | `]` doubled | | `BacktickQuoteIdentifier` | Databricks (Spark SQL) | `` ` `` doubled | | `BigQueryQuoteIdentifier` | BigQuery (GoogleSQL) | `` ` `` and `\` backslash escaped | `QuoteQualifiedIdentifier`, `JoinQuotedIdentifiers` and `QuoteCommaSeparatedIdentifiers` take the dialect's quoting function, so composite partition keys and column lists are quoted per column. `BigQueryQuoteTablePath` quotes a dotted `project.dataset.table` path as a single identifier. **String literals** | Helper | Dialect | Escaping | | --- | --- | --- | | `SQLStringLiteral` / `UnicodeStringLiteral` | MSSQL, Azure Synapse | `'` doubled, `N'…'` variant | | `SQLStringLiteralBackslash` | Redshift, Snowflake | `\` escaped, `'` doubled | | `SparkSQLStringLiteral` | Databricks | `\` escaped, `'` escaped as `\'` | Redshift, Snowflake, BigQuery and Databricks all interpret backslash escape sequences inside string literals, so doubling the quote alone can be defeated by a value containing `\'`. This PR only adds the helpers. The integration PRs stacked on it switch their SQL over: - #7363 (Azure Synapse) - #7364 (MSSQL) - #7365 (Redshift) - #7366 (BigQuery) - #7367 (Snowflake) - #7368 (Deltalake) - #7405 (Postgres) ## Tests - `identifier_test.go`: per dialect identifier escaping (including breakout payloads and a trailing backslash), qualified identifiers, identifier lists, comma separated column lists, and the three string literal forms. Each escaper is also run over a value containing every delimiter and escape character (`"`, `` ` ``, `]`, `'`, `\`) to assert it escapes only its own. ## Linear Ticket Resolves INT-6791 ## Security - [x] The code changed/added as part of this pull request won't create any security issues with how the software is being used.
Base automatically changed from
feature/int-6791-warehouse-identifier-utils
to
master
September 23, 2026 06:45
achettyiitr
force-pushed
the
harness/INT-6791-quote-bigquery-identifiers
branch
from
September 23, 2026 11:40
9e7b3db to
34cc5e4
Compare
1 task done
achettyiitr
added a commit
that referenced
this pull request
Sep 24, 2026
…#7421) # Description `warehouse/utils` grew both a generic and a per dialect way to build the same SQL: ```go QuoteQualifiedIdentifier(DoubleQuoteIdentifier, ns, table) // generic DoubleQuoteQualifiedIdentifier(ns, table) // wrapper ``` The wrappers only restate the generic helper with the quoting function filled in, so this removes them: - `DoubleQuoteQualifiedIdentifier`, `BracketQuoteQualifiedIdentifier`, `BacktickQuoteQualifiedIdentifier` - `BracketQuoteAndJoinByComma`, `BacktickQuoteAndJoinByComma` Callers pass the dialect's quoting function to `QuoteQualifiedIdentifier` or `JoinQuotedIdentifiers` instead, which is how `QuoteCommaSeparatedIdentifiers` already works. What stays: - the dialect escapers (`DoubleQuoteIdentifier`, `BracketQuoteIdentifier`, `BacktickQuoteIdentifier`, `BigQueryQuoteIdentifier`), which is where the dialects genuinely differ - `BigQueryQuoteTablePath`, which quotes a dotted path as one identifier rather than part by part, so it is not the generic helper with an argument filled in - `DoubleQuoteAndJoinByComma`, which predates this work and is used across the warehouse integrations Nothing on master used the removed wrappers; the INT-6791 integration PRs (#7363, #7364, #7365, #7366, #7367, #7368, #7405, #7420) have been updated to call the generic helpers, so they are unaffected whichever order these merge in. ## Tests - `identifier_test.go`: the dialect assertions now go through `QuoteQualifiedIdentifier` and `JoinQuotedIdentifiers`, covering the same escaping. ## Linear Ticket Related to INT-6791 ## Security - [x] The code changed/added as part of this pull request won't create any security issues with how the software is being used.
Address review feedback from #7249: - escape backslash as well as backtick in quoted identifiers, closing the trailing-backslash breakout - bind INFORMATION_SCHEMA filters as query parameters instead of string literals, whose escaping differs in GoogleSQL - extract the users merge SQL into usersMergeQuery and cover it with tests - drop the unused quoteIdentifiers helper that failed lint Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> 🔒 Scanned for secrets using gitleaks 8.29.1
Add unit tests asserting that a table name containing a backtick breakout cannot escape the backtick-quoted table path in the deduplication view and in quoteTablePath. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> 🔒 Scanned for secrets using gitleaks 8.29.1
BigQuery rejects backticks, backslashes and other breakout characters in table and column names at the API level, so the live test uses names that BigQuery accepts but that are only valid SQL when quoted (spaces, dashes and flexible column name characters). It creates a control table and a table with such names, and asserts the deduplication view is created, DeleteBy succeeds, the names round-trip verbatim through FetchSchema and DropTable only drops the targeted table. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> 🔒 Scanned for secrets using gitleaks 8.29.1
DownloadIdentityRules built `null as anonymous_id", user_id` for tables that have user_id but no anonymous_id, which is invalid SQL. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> 🔒 Scanned for secrets using gitleaks 8.29.1
Run the identifier and string literal escapers over a value containing every
delimiter and escape character (" ` ] ' \) to assert the dialect escapes
only its own delimiters and handles backslashes correctly.
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
🔒 Scanned for secrets using gitleaks 8.29.1
Replace the package local quoting helpers with the shared ones from warehouse/utils so the escaping rules live in one place. The generated SQL is unchanged; the escaping is covered by the helper tests. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> 🔒 Scanned for secrets using gitleaks 8.29.1
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> 🔒 Scanned for secrets using gitleaks 8.29.1
achettyiitr
force-pushed
the
harness/INT-6791-quote-bigquery-identifiers
branch
from
September 24, 2026 05:40
5ba9cd8 to
6be6588
Compare
The branch deleted its own identifier test, which left the composite partition key and the loaded_at ordering unasserted. Cover both, and that the _PARTITIONTIME pseudo column stays unquoted. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]> 🔒 Scanned for secrets using gitleaks 8.29.1
This was referenced Sep 28, 2026
Merged
itsmihir
pushed a commit
that referenced
this pull request
Sep 28, 2026
🤖 I have created a release *beep* *boop* --- ## [1.89.0-rc.1](v1.88.0...v1.89.0-rc.1) (2026-09-28) ### Features * **warehouse:** add shared SQL identifier and string literal quoting helpers ([#7406](#7406)) ([814f6db](814f6db)) ### Bug Fixes * **warehouse:** quote azure synapse identifiers ([#7363](#7363)) ([d399fd1](d399fd1)) * **warehouse:** quote bigquery identifiers ([#7366](#7366)) ([89de526](89de526)) * **warehouse:** quote clickhouse identifiers ([#7420](#7420)) ([490c097](490c097)) * **warehouse:** quote deltalake identifiers ([#7368](#7368)) ([08f2f1e](08f2f1e)) * **warehouse:** quote mssql identifiers ([#7364](#7364)) ([695b881](695b881)) * **warehouse:** quote postgres load column list and bind schema existence check ([#7405](#7405)) ([2ff81c1](2ff81c1)) * **warehouse:** quote redshift identifiers ([#7365](#7365)) ([a3e2a3c](a3e2a3c)) * **warehouse:** quote snowflake identifiers ([#7367](#7367)) ([53d4891](53d4891)) ### Miscellaneous * sync release v1.88.0 to main branch ([#7415](#7415)) ([130bdd3](130bdd3)) * **warehouse:** drop the per dialect identifier quoting wrappers ([#7421](#7421)) ([ec0cf52](ec0cf52)) * **warehouse:** drop the v2 suffix now v1 is gone ([#7418](#7418)) ([b759c33](b759c33)) * **warehouse:** move back to upstream clickhouse-go ([#7419](#7419)) ([1a7e776](1a7e776)) * **warehouse:** remove the ClickHouse v1 driver ([#7417](#7417)) ([bd14179](bd14179)) * **warehouse:** replace dead clickhouse blockSize with commitEvery ([#7427](#7427)) ([0806478](0806478)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.com>
itsmihir
pushed a commit
that referenced
this pull request
Sep 29, 2026
🤖 I have created a release *beep* *boop* --- ## [1.89.0](v1.88.0...v1.89.0) (2026-09-28) ### Features * **warehouse:** add shared SQL identifier and string literal quoting helpers ([#7406](#7406)) ([814f6db](814f6db)) ### Bug Fixes * **warehouse:** quote azure synapse identifiers ([#7363](#7363)) ([d399fd1](d399fd1)) * **warehouse:** quote bigquery identifiers ([#7366](#7366)) ([89de526](89de526)) * **warehouse:** quote clickhouse identifiers ([#7420](#7420)) ([490c097](490c097)) * **warehouse:** quote deltalake identifiers ([#7368](#7368)) ([08f2f1e](08f2f1e)) * **warehouse:** quote mssql identifiers ([#7364](#7364)) ([695b881](695b881)) * **warehouse:** quote postgres load column list and bind schema existence check ([#7405](#7405)) ([2ff81c1](2ff81c1)) * **warehouse:** quote redshift identifiers ([#7365](#7365)) ([a3e2a3c](a3e2a3c)) * **warehouse:** quote snowflake identifiers ([#7367](#7367)) ([53d4891](53d4891)) ### Miscellaneous * sync release v1.88.0 to main branch ([#7415](#7415)) ([130bdd3](130bdd3)) * **warehouse:** drop the per dialect identifier quoting wrappers ([#7421](#7421)) ([ec0cf52](ec0cf52)) * **warehouse:** drop the v2 suffix now v1 is gone ([#7418](#7418)) ([b759c33](b759c33)) * **warehouse:** move back to upstream clickhouse-go ([#7419](#7419)) ([1a7e776](1a7e776)) * **warehouse:** remove the ClickHouse v1 driver ([#7417](#7417)) ([bd14179](bd14179)) * **warehouse:** replace dead clickhouse blockSize with commitEvery ([#7427](#7427)) ([0806478](0806478)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: rudderstack-github-actions[bot] <236995729+rudderstack-github-actions[bot]@users.noreply.github.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.
Description
Stacked on #7406, which adds the shared helpers; this PR targets that branch and will retarget to
masteronce it merges.BigQuery DDL (
CreateTable,AddColumns,DropTable) goes through the typed Go client API, where names are struct fields rather than SQL. The remaining raw-SQL paths interpolated dataset, table and column names without escaping: the dedup view,DeleteBy, the users merge,FetchSchema, dangling staging-table cleanup and identity-rule downloads.This PR routes those paths through the shared quoting helpers added in #7406 (
warehouse/utils/identifier.go):BigQueryQuoteIdentifierwraps names in backticks. GoogleSQL quoted identifiers use the same escape sequences as string literals, so both\and`are escaped with a backslash; escaping only the backtick would still allow a name ending in\to break out.BigQueryQuoteTablePathquotes aproject.dataset.tablepath as a single backtick-quoted identifier.QuoteCommaSeparatedIdentifierssplits composite partition keys into individually quoted columns.Changes:
createTableView/deduplicationQuery): view name, source table path, partition columns,ORDER BY loaded_atand the partition filter column are quoted.LoadUserTables: the merge SQL is extracted intousersMergeQuery, with every column,id,received_atand the staging table quoted. Columns are emitted in sorted order so the query is deterministic.DeleteByandDownloadIdentityRules: table paths are quoted.DownloadIdentityRulesalso fixes a stray"in the select list used for tables that haveuser_idbut noanonymous_id(null as anonymous_id", user_id), which produced invalid SQL.FetchSchemaanddropDanglingStagingTables: the dataset qualifier is quoted (`dataset`.INFORMATION_SCHEMA.TABLES), and thetable_schema/LIKEfilters are passed as query parameters instead of string literals.Tests
deduplicationQueryoutput for a dataset and table containing backticks.usersMergeQuerywith column names containing backticks, backslashes and SQL fragments.bigquery_quoting_internal_test.go: a table name with a backtick breakout payload stays inside the backtick-quoted table path, both in the deduplication view and inBigQueryQuoteTablePath.TestIntegration→ "prevents SQL injection via malicious identifiers": BigQuery rejects backticks, backslashes,",;and parentheses in names at the API level, so the test uses names BigQuery accepts but that are only valid SQL when correctly quoted (spaces, dashes, and flexible column name characters such as',=,#and|). It creates a control table and a table with such names, then verifies the deduplication view is created,DeleteByruns, the names round-trip verbatim throughFetchSchema(INFORMATION_SCHEMAwith query parameters), andDropTabledrops only the targeted table.Linear Ticket
Resolves INT-6791
Security