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

Reshift dialect doesn't understand CONVERT function #3651

Closed
3 tasks done
pdebelak opened this issue Jul 22, 2022 · 1 comment
Closed
3 tasks done

Reshift dialect doesn't understand CONVERT function #3651

pdebelak opened this issue Jul 22, 2022 · 1 comment
Labels
bug Something isn't working redshift Issues relating to Amazon Redshift dialect

Comments

@pdebelak
Copy link
Contributor

Search before asking

  • I searched the issues and found no similar issues.

What Happened

The redshift dialect thinks the data type identifier in the CONVERT function (see CAST and CONVERT docs) is a column identifier which can cause spurious lint errors.

Expected Behaviour

The CONVERT function is correctly parsed with a data type identifier and a column identifier.

Observed Behaviour

The CONVERT function is parsed as having two column identifier arguments.

How to reproduce

You can see the L027 rule failure is due to integer being parsed as a column identifier, not a data type identifier.

$ echo 'SELECT
    sellers.name,
    CONVERT(integer, sales.pricepaid) AS price
FROM sales
LEFT JOIN sellers ON sales.sellerid = sellers.sellerid
WHERE sales.salesid = 100;' | sqlfluff lint --dialect redshift -
== [stdin] FAIL                                                                                                                            
L:   3 | P:  13 | L027 | Unqualified reference 'integer' found in select with
                       | more than one referenced table/view.
All Finished 📜 🎉!

Dialect

Redshift

Version

sqlfluff, version 1.1.0
Python 3.9.13

Configuration

None

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

@pdebelak pdebelak added the bug Something isn't working label Jul 22, 2022
pdebelak added a commit to pdebelak/sqlfluff that referenced this issue Jul 22, 2022
Fixes issue sqlfluff#3651.

Previously, the first argument to the `convert` redshift function was
interpreted as a column reference rather than a data type. This could
cause rule L027 to fail since the data type wasn't qualified with a
table name even though that doesn't make sense. This adds explicit
handling for `convert` to eliminate that issue.
pdebelak added a commit to pdebelak/sqlfluff that referenced this issue Jul 22, 2022
Fixes issue sqlfluff#3651.

Previously, the first argument to the `convert` redshift function was
interpreted as a column reference rather than a data type. This could
cause rule L027 to fail since the data type wasn't qualified with a
table name even though that doesn't make sense. This adds explicit
handling for `convert` to eliminate that issue.
pdebelak added a commit to pdebelak/sqlfluff that referenced this issue Jul 23, 2022
Fixes issue sqlfluff#3651.

Previously, the first argument to the `convert` redshift function was
interpreted as a column reference rather than a data type. This could
cause rule L027 to fail since the data type wasn't qualified with a
table name even though that doesn't make sense. This adds explicit
handling for `convert` to eliminate that issue.
tunetheweb pushed a commit that referenced this issue Jul 23, 2022
Fixes issue #3651.

Previously, the first argument to the `convert` redshift function was
interpreted as a column reference rather than a data type. This could
cause rule L027 to fail since the data type wasn't qualified with a
table name even though that doesn't make sense. This adds explicit
handling for `convert` to eliminate that issue.
@greg-finley greg-finley added the redshift Issues relating to Amazon Redshift dialect label Jul 25, 2022
@pdebelak
Copy link
Contributor Author

Fixed in #3653

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working redshift Issues relating to Amazon Redshift dialect
Projects
None yet
Development

No branches or pull requests

2 participants