You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When trying to parse a BigQuery statement that has an error, the returned error info's start_context and highlight are off by one when the query quotes the identifiers.
Fully reproducible code snippet
import sqlglot
sql = "SELECT * FROM `TableA` UNION `TableB`"
try:
parse = sqlglot.parse_one(sql, read="bigquery")
except Exception as e:
error = e.errors[0]
print(f'With quotes: Start context: {error["start_context"]}; Highlight: {error["highlight"]}')
sql = "SELECT * FROM TableA UNION TableB"
try:
parse = sqlglot.parse_one(sql, read="bigquery")
except Exception as e:
error = e.errors[0]
print(f'Without quotes: Start context: {error["start_context"]}; Highlight: {error["highlight"]}')
Expected output:
With quotes: Start context: SELECT * FROM TableA UNION ; Highlight: TableB
Without quotes: Start context: SELECT * FROM TableA UNION ; Highlight: TableB
Actual output:
With quotes: Start context: SELECT * FROM `TableA` UNION `T; Highlight: ableB`
Without quotes: Start context: SELECT * FROM TableA UNION ; Highlight: TableB
The text was updated successfully, but these errors were encountered:
When trying to parse a BigQuery statement that has an error, the returned error info's
start_context
andhighlight
are off by one when the query quotes the identifiers.Fully reproducible code snippet
Expected output:
Actual output:
The text was updated successfully, but these errors were encountered: