Skip to content

Bigquery: Parsing error when declaring arrays #3663

@karirogg

Description

@karirogg

Search before asking

  • I searched the issues and found no similar issues.

What Happened

When writing SQL code with the bigquery dialect, the following statement gives an unparsable error:

DECLARE my_array ARRAY<STRING(50)>;

Expected Behaviour

This is (to my best knowledge) completely legal SQL code and should not be unparsable.

Observed Behaviour

The error message is as follows:

L:   1 | P:  49 |  PRS | Line 1, Position 49: Found unparsable section: | '<STRING(50)>'

It seems as though SQLFluff does not recognize the <> part of the statement.

How to reproduce

Declare an array in your SQL file as follows:

DECLARE my_array ARRAY<STRING(50)>

and lint it using sqlfluff lint <path_to_file>

Dialect

BigQuery

Version

1.0.0

Configuration

# Configuration for SQLFluff code formatting. The rules referenced can be found on
# https://docs.sqlfluff.com/en/stable/rules.html

[sqlfluff]
dialect = bigquery
exclude_rules = L051, L046, L036, L034, L032, L031

[sqlfluff:templater:jinja:context]
# This is done to get rid of jinja parsing errors
project_id = EMPTY
safe_zone_project_id = EMPTY

[sqlfluff:rules]
tab_space_size = 2

[sqlfluff:indentation]
indented_joins = False
indented_using_on = False

[sqlfluff:rules:L006]
# Operators should be surrounded by a single whitespace.

[sqlfluff:rules:L010]
# Inconsistent capitalisation of keywords.
capitalisation_policy = upper

[sqlfluff:rules:L011]
# Implicit/explicit aliasing of table.
aliasing = explicit

[sqlfluff:rules:L012]
# Implicit/explicit aliasing of columns.
allow_scalar = False

[sqlfluff:rules:L014]
# Inconsistent capitalisation of unquoted identifiers.
extended_capitalization_policy = lower 

[sqlfluff:rules:L016]
# Line is too long.
max_line_length = 150

[sqlfluff:rules:L030]
# Inconsistent capitalisation of function names.
extended_capitalization_policy = upper 

[sqlfluff:rules:L038]
# Trailing commas within select clause.
select_clause_trailing_comma = forbid 

[sqlfluff:rules:L040]
# Inconsistent capitalisation of boolean/null literal.
capitalisation_policy = upper 

[sqlfluff:rules:L042]
# Join/From clauses should not contain subqueries. Use CTEs instead.
forbid_subquery_in = both

[sqlfluff:rules:L052]
# Statements must end with a semi-colon.
require_final_semicolon = False 

[sqlfluff:rules:L054]
# Inconsistent column references in GROUP BY/ORDER BY clauses.
group_by_order_and_style = consistent

[sqlfluff:rules:L063]
# Inconsistent capitalisation of datatypes.
extended_capitalization_policy = consistent

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bigqueryIssues relating to the BigQuery dialectbugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions