You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2020/09/11 07:15:00 UTC

[jira] [Created] (CALCITE-4246) When parsing SQL in BigQuery dialect, allow unquoted table names to contain hyphens

Julian Hyde created CALCITE-4246:
------------------------------------

             Summary: When parsing SQL in BigQuery dialect, allow unquoted table names to contain hyphens
                 Key: CALCITE-4246
                 URL: https://issues.apache.org/jira/browse/CALCITE-4246
             Project: Calcite
          Issue Type: Bug
          Components: babel
            Reporter: Julian Hyde


When parsing SQL in BigQuery dialect, allow unquoted table names to contain hyphens. This feature was [added in May 2020|https://www.reddit.com/r/bigquery/comments/fgk31y/new_in_bigquery_no_more_backticks_around_table/].

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}}.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)