question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

L029: 「key」is recognized as keyword word in the BigQuery dialect when it shouldn't be

See original GitHub issue

Search before asking

  • I searched the issues and found no similar issues.

What Happened

I try this command to sample.sql.

$ sqlfluff lint --dialect bigquery sample.sql

↓ sample.sql

SELECT
    a AS key,
    b
FROM
    my_table;

「key」is in bigquery_unreserved_keywords but SQLFluff lint result is fail.

== [sample.sql] FAIL                                                                                                                                                               
L:   2 | P:  10 | L029 | Keywords should not be used as identifiers.
All Finished 📜 🎉!

Expected Behaviour

「key」does not fail in SQLFluff lint because set in bigquery_unreserved_keywords

Observed Behaviour

SQLFluff lint is failed.

$ sqlfluff lint --dialect bigquery sample.sql
== [sample.sql] FAIL                                                                                                                                                               
L:   2 | P:  10 | L029 | Keywords should not be used as identifiers.
All Finished 📜 🎉!

↓ sample.sql

SELECT
    a AS key,
    b
FROM
    my_table;

How to reproduce

SQLFluff version 1.2.1 and try Observed Behavior command, create file.

Dialect

BigQuery

Version

$ sqlfluff --version
sqlfluff, version 1.2.1

Configuration

Don’t configure .sqlfluff and .sqlfluffignore.

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

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
tunethewebcommented, Aug 4, 2022

I’m not sure it is correct since I’m not sure key is an unreserved word in BigQuery. So yes feel free to submit a fix PR.

0reactions
tunethewebcommented, Aug 7, 2022

Reopening this. the fix was made in #3714 so that BigQuery should now no longer need to have KEY listed as an unreserved word. However, that same PR did not actually remove KEY as an unreserved word:

https://github.com/sqlfluff/sqlfluff/blob/f687e82b1d0073e41b4fb7feb59b47c2cf6c817a/src/sqlfluff/dialects/dialect_bigquery_keywords.py#L174

Meaning the initial query still flags as a linting error when it shouldn’t.

@sabrikaragonen or @keyem4251 do you want to do that final step so we can close this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Rules Reference — SQLFluff 1.4.5 documentation
Keywords should not be used as identifiers. Although unreserved keywords can be used as identifiers, and reserved words can be used as quoted...
Read more >
Lexical structure and syntax | BigQuery - Google Cloud
Keywords are a group of tokens that have special meaning in the Google Standard SQL language, and have the following characteristics: Keywords cannot...
Read more >
sqlfluff/CHANGELOG.md at main - GitHub
A modular SQL linter and auto-formatter with support for multiple dialects and templated code. - sqlfluff/CHANGELOG.md at main · sqlfluff/sqlfluff.
Read more >
sqlfluff Changelog - pyup.io
Enable parsing of CLONE keyword in bigquery dialect [3984](https://github.com/sqlfluff/sqlfluff/pull/3984) [realLyans](https://github.com/realLyans)
Read more >
L029: 「key」is recognized as keyword word in the BigQuery ...
$ sqlfluff lint --dialect bigquery sample.sql == [sample.sql] FAIL L: 2 | P: 10 | L029 | Keywords should not be used as...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found