Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-4246

When parsing SQL in BigQuery dialect, allow unquoted table names to contain hyphens

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.26.0
    • babel
    • None

    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

          Activity

            People

              julianhyde Julian Hyde
              julianhyde Julian Hyde
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: