Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
2 of 3 tasks
keyem4251 opened this issue Jul 30, 2022 · 5 comments · Fixed by #3714 or #3719
Closed
2 of 3 tasks
Labels
bigquery Issues relating to the BigQuery dialect bug Something isn't working good first issue Good for newcomers

Comments

@keyem4251
Copy link
Contributor

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

@keyem4251 keyem4251 added the bug Something isn't working label Jul 30, 2022
@github-actions github-actions bot added the bigquery Issues relating to the BigQuery dialect label Jul 30, 2022
@tunetheweb tunetheweb added the good first issue Good for newcomers label Jul 30, 2022
@tunetheweb
Copy link
Member

BigQuery doesn’t have primary or foreign keys so we should reset these in this dialect allowing this keyword to be removed from the list:

PrimaryKeyGrammar=Nothing(),
ForeignKeyGrammar=Nothing(),

@keyem4251
Copy link
Contributor Author

Oh sorry. I read L029 again. Unreserved keyword「key」is to avoid where possible in best practice. So this linter fail seems to be correct.

BigQuery doesn’t have primary or foreign keys.
PrimaryKeyGrammar=Nothing(),
ForeignKeyGrammar=Nothing(),

But I guess this above settings should be correct too.

keyem4251 added a commit to keyem4251/sqlfluff that referenced this issue Aug 3, 2022
@keyem4251
Copy link
Contributor Author

@tunetheweb
Sorry, this linter fail seems to be correct.
#3696 (comment)

BigQuery doesn’t have primary or foreign keys.
PrimaryKeyGrammar=Nothing(),
ForeignKeyGrammar=Nothing(),

But this above settings seems to change dialect_bigquery.
Can I try this ?

@tunetheweb
Copy link
Member

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.

@tunetheweb tunetheweb changed the title L029: 「key」isn't recognized as unreserved word in the BigQuery dialect. L029: 「key」is recognized as keyword word in the BigQuery dialect when it shouldn't be Aug 7, 2022
@tunetheweb
Copy link
Member

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:

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bigquery Issues relating to the BigQuery dialect bug Something isn't working good first issue Good for newcomers
Projects
None yet
2 participants