Skip to content

Commit b25da68

Browse files
fix(destination-bigquery): Add backticks to column names in SQL generation to prevent syntax errors (#67401)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: Edward Gao <[email protected]>
1 parent e9f6b3c commit b25da68

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

airbyte-integrations/connectors/destination-bigquery/metadata.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ data:
66
connectorSubtype: database
77
connectorType: destination
88
definitionId: 22f6c74f-5699-40ff-833c-4a879ea40133
9-
dockerImageTag: 3.0.15
9+
dockerImageTag: 3.0.16
1010
dockerRepository: airbyte/destination-bigquery
1111
documentationUrl: https://docs.airbyte.com/integrations/destinations/bigquery
1212
githubIssueLabel: destination-bigquery

airbyte-integrations/connectors/destination-bigquery/src/main/kotlin/io/airbyte/integrations/destination/bigquery/write/typing_deduping/direct_load_tables/BigqueryTableSchemaEvolutionClient.kt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -214,18 +214,18 @@ class BigqueryTableSchemaEvolutionClient(
214214
// but that seems like a weird enough situation that we shouldn't worry about it.
215215
return """
216216
CAST(
217-
CASE JSON_TYPE($columnName)
218-
WHEN 'object' THEN TO_JSON_STRING($columnName)
219-
WHEN 'array' THEN TO_JSON_STRING($columnName)
220-
ELSE JSON_VALUE($columnName)
217+
CASE JSON_TYPE(`$columnName`)
218+
WHEN 'object' THEN TO_JSON_STRING(`$columnName`)
219+
WHEN 'array' THEN TO_JSON_STRING(`$columnName`)
220+
ELSE JSON_VALUE(`$columnName`)
221221
END
222222
AS $newType
223223
)
224224
""".trimIndent()
225225
} else if (newType == StandardSQLTypeName.JSON) {
226-
return "TO_JSON($columnName)"
226+
return "TO_JSON(`$columnName`)"
227227
} else {
228-
return "CAST($columnName AS $newType)"
228+
return "CAST(`$columnName` AS $newType)"
229229
}
230230
}
231231

@@ -394,12 +394,12 @@ class BigqueryTableSchemaEvolutionClient(
394394
databaseHandler.executeWithRetries(
395395
"""
396396
ALTER TABLE $tableId
397-
RENAME COLUMN `$realColumnName` TO $backupColumnName,
398-
RENAME COLUMN `$tempColumnName` TO $realColumnName
397+
RENAME COLUMN `$realColumnName` TO `$backupColumnName`,
398+
RENAME COLUMN `$tempColumnName` TO `$realColumnName`
399399
""".trimIndent(),
400400
)
401401
databaseHandler.executeWithRetries(
402-
"""ALTER TABLE $tableId DROP COLUMN $backupColumnName""",
402+
"""ALTER TABLE $tableId DROP COLUMN `$backupColumnName`""",
403403
)
404404
}
405405
}

docs/integrations/destinations/bigquery.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ tutorials:
210210

211211
| Version | Date | Pull Request | Subject |
212212
|:------------|:-----------|:-----------------------------------------------------------|:----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
213+
| 3.0.16 | 2025-11-25 | [67401](https://github.com/airbytehq/airbyte/pull/67401) | Add backticks to column names in SQL generation to prevent syntax errors. |
213214
| 3.0.15 | 2025-11-12 | [69307](https://github.com/airbytehq/airbyte/pull/69307) | Handle out-of-range timestamps/times. |
214215
| 3.0.14 | 2025-11-11 | [69231](https://github.com/airbytehq/airbyte/pull/69231) | Upgrade to Bulk CDK 0.1.74. |
215216
| 3.0.13 | 2025-11-01 | [69126](https://github.com/airbytehq/airbyte/pull/69126) | Upgrade to Bulk CDK 0.1.61. |

0 commit comments

Comments
 (0)