sqlfluff: Parser incorrectly swaps BigQuery struct grammars when `parse_grammar` is not supplied.

Search before asking

  • I searched the issues and found no similar issues.

What Happened

When a STRUCT is used in conjunction with an AS alias, it’s columns are recognised as datatypes, which can trigger L063.

Expected Behaviour

STRUCT column names should not trigger L063.

Observed Behaviour

L:   3 | P:   9 | L063 | Datatypes must be upper case.
L:   4 | P:   9 | L063 | Datatypes must be upper case.

How to reproduce

Run sqlfluff lint on

SELECT
    STRUCT(
        some_field,
        some_other_field
    ) AS col,
    STRUCT(
        some_field,
        some_other_field
    )
FROM table

Dialect

bigquery

Version

0.13.1

Configuration

[sqlfluff]
templater = jinja
dialect = bigquery

[sqlfluff:rules:L063]
# Inconsistent capitalisation of datatypes
extended_capitalisation_policy = upper

Are you willing to work on and submit a PR to address the issue?

  • Yes I am willing to submit a PR!

Code of Conduct

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 28 (28 by maintainers)

Most upvoted comments

I’m still working on this - I’ve narrowed it down to a section of Bracketed where we’re assuming something is treated as immutable - but it’s very much not. I expect that I’ll have some more precise tests which come out of the fix when I find it.