Description
When parsing SQL in BigQuery dialect, allow unquoted table names to contain hyphens. This feature was added in May 2020.
For these purposes, "table names" are considered to be the first identifier after FROM, JOIN, INSERT, UPDATE, DELETE, TABLE without an intervening SELECT or SET. (Yeah, the rules are rather rigid, but to implement it we have to shift lexical states in the parser, and we can only do that based on what tokens we've seen. Hopefully the rules will suffice.)
Valid identifiers with hyphens:
- select * from bigquery-public-data.foo
- insert into bigquery-public-data.foo values (1)
- delete from bigquery-public-data.foo
- select * from dept cross join bigquery-public-data.foo
Invalid identifiers with hyphens:
- select foo-bar from dept # column names cannot have hyphens
- select * from dept as foo-bar # table aliases cannot have hyphens
- select foo-bar.deptno from dept as `foo-bar` # ditto
- select * from foo.bar-baz.bump # only first part of table name
In all of the above 'invalid' cases, you can solve by enclosing the identifier with back-ticks, e.g. select `foo-bar` from dept.
To control this feature, in interface SqlConformance, add method boolean allowHyphenInUnquotedTableName().
Attachments
Issue Links
- is related to
-
CALCITE-4230 When parsing SQL in BigQuery dialect, split quoted table names that contain dots
- Closed