Skip to content

BigQuery dialect should escape backslashes in string literals#5094

Open
Samin061 wants to merge 1 commit into
apache:mainfrom
Samin061:bigquery-backslash-escape
Open

BigQuery dialect should escape backslashes in string literals#5094
Samin061 wants to merge 1 commit into
apache:mainfrom
Samin061:bigquery-backslash-escape

Conversation

@Samin061

Copy link
Copy Markdown

Jira Link

No Jira filed yet; happy to open one if preferred. This is a small escaping fix in the SQL generator.

Changes Proposed

BigQuerySqlDialect declares its escaped quote as \', but the base quoteStringLiteral only replaces the quote character, so a literal backslash in a string value reaches BigQuery unescaped. BigQuery treats backslash as an escape character inside string literals, so a pushed-down value such as x\ or \'; ... closes the literal early and the trailing characters are parsed as SQL rather than data. Override quoteStringLiteral to double backslashes before the base method escapes the enclosing quote, so backslash-containing values round-trip as data. Added a rel2sql regression test next to testCharLiteralForBigQuery.

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant