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

Snowflake parsing error when creating table with casted default column values #4141

Closed
2 of 3 tasks
rafal-dabrowski opened this issue Dec 7, 2022 · 2 comments · Fixed by #4192
Closed
2 of 3 tasks
Labels
bug Something isn't working snowflake Issues related to the Snowflake dialect

Comments

@rafal-dabrowski
Copy link

Search before asking

  • I searched the issues and found no similar issues.

What Happened

When i have a CREATE TABLE statement, that defines a default value with a explicit type casting - parsing error occurs.

Expected Behaviour

table is properly parsed

Observed Behaviour

== [bug.sql] FAIL
L: 1 | P: 32 | PRS | Line 1, Position 32: Found unparsable section: " (\n txt
| TEXT NOT NULL DEFAULT 'bug'::..."
WARNING: Parsing errors found and dialect is set to 'snowflake'. Have you configured your dialect correctly?

How to reproduce

create file bug.sql

CREATE OR REPLACE TABLE stg.bug (
txt TEXT NOT NULL DEFAULT 'bug'::text
)

sqlfluff lint bug.sql

Dialect

snowflake, with jinja templater

Version

sqlfluff --version
sqlfluff, version 1.4.2

Configuration

[sqlfluff]
templater = jinja
dialect = snowflake
sql_file_exts = .sql

rules = all

warnings = L016, L044, L057
exclude_rules = L031
output_line_length = 80

[sqlfluff:rules]
tab_space_size = 4
max_line_length = 120
indent_unit = space

[sqlfluff:rules:L010]
capitalisation_policy = upper

[sqlfluff:rules:L014]
extended_capitalisation_policy = lower
unquoted_identifiers_policy = all

[sqlfluff:rules:L028]
single_table_references = qualified

[sqlfluff:rules:L030]
extended_capitalisation_policy = lower

[sqlfluff:rules:L040]
capitalisation_policy = upper

[sqlfluff:rules:L063]
#data types capitalisation
extended_capitalisation_policy = upper

[sqlfluff:rules:L042]
forbid_subquery_in = both

[sqlfluff:rules:L054]
group_by_and_order_by_style = explicit

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

@rafal-dabrowski rafal-dabrowski added the bug Something isn't working label Dec 7, 2022
@github-actions github-actions bot added the snowflake Issues related to the Snowflake dialect label Dec 7, 2022
@NelsonTorres
Copy link
Contributor

I can issue a PR to fix this but I wonder if casting in the default is a good approach because the column already has the type

@rafal-dabrowski
Copy link
Author

I think that it is not a good practice, but i would exect to have a rule to check it rather than parsing error that stops everything :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working snowflake Issues related to the Snowflake dialect
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants