-
Notifications
You must be signed in to change notification settings - Fork 769
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
BigQuery raw string support has regressed #1691
Comments
I can take a look shortly, thanks for the report. |
Here's a possible fix: It feels a little clunky to me though |
i'm working on something @pmsanford appreciate the attempt |
tobymao
added a commit
that referenced
this issue
May 25, 2023
tobymao
added a commit
that referenced
this issue
May 25, 2023
tobymao
added a commit
that referenced
this issue
May 25, 2023
adrianisk
pushed a commit
to adrianisk/sqlglot
that referenced
this issue
Jun 21, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This issue is present on the current release and on main.
In the following:
SELECT r'\s'
is not the same asSELECT '\s'
- ther
prefix indicates the following is a "raw string," mostly used in REGEXP_REPLACE/REGEXP_EXTRACT (the docs say it is also referred to as a "regex string")It looks like this was addressed in #218, but it appears to have regressed in d2377e0
The test here in test_bigquery.py is now incorrect:
The query string
R"""/\*.*\*/"""
starts withR"
, so if the leading R is removed, all the backslashes in the resulting strings should be double escaped.I'm working on wrapping my head around the tokenizer to see if I can fix this, but I thought I'd post an issue in the interim in case I'm called away from working on this before I can get to a PR.
Fully reproducible code snippet
assert sqlglot.parse_one(r"SELECT r'\s'", "bigquery").sql("bigquery") == r"SELECT '\\s'"
Official Documentation
https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#quoted_literals
The text was updated successfully, but these errors were encountered: