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: Fixed data type casting not working in SET statement #1604

Merged
merged 2 commits into from
Oct 12, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions src/sqlfluff/dialects/dialect_ansi.py
Original file line number Diff line number Diff line change
Expand Up @@ -2719,6 +2719,7 @@ class SetClauseSegment(BaseSegment):
Ref("ColumnReferenceSegment"),
"DEFAULT",
),
AnyNumberOf(Ref("ShorthandCastSegment")),
)


Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
select '1'::int::boolean as bool;
select '1'::int::boolean as bool;

update table_name
set
col1 = CURRENT_TIMESTAMP::TIMESTAMP_TZ,
col2 = '1'::int::boolean
;
37 changes: 34 additions & 3 deletions test/fixtures/dialects/snowflake/multiple_shorthand_casts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
# computed by SQLFluff when running the tests. Please run
# `python test/generate_parse_fixture_yml.py` to generate them after adding or
# altering SQL files.
_hash: f0ae131c968b3bb8ac99c4439451208f030ae46b59235e46a52fb2aac57d0425
_hash: f1ee0fab94f2e2ade22759250f5e8ce286b26eab9f33624c98e1f781b606de25
file:
statement:
- statement:
select_statement:
select_clause:
keyword: select
Expand All @@ -23,4 +23,35 @@ file:
alias_expression:
keyword: as
identifier: bool
statement_terminator: ;
- statement_terminator: ;
- statement:
update_statement:
keyword: update
table_reference:
identifier: table_name
set_clause_list:
- keyword: set
- set_clause:
column_reference:
identifier: col1
comparison_operator: '='
bare_function: CURRENT_TIMESTAMP
cast_expression:
casting_operator: '::'
data_type:
data_type_identifier: TIMESTAMP_TZ
- comma: ','
- set_clause:
- column_reference:
identifier: col2
- comparison_operator: '='
- literal: "'1'"
- cast_expression:
casting_operator: '::'
data_type:
data_type_identifier: int
- cast_expression:
casting_operator: '::'
data_type:
data_type_identifier: boolean
- statement_terminator: ;