-
Notifications
You must be signed in to change notification settings - Fork 0
SGA-13064: Query parsing failed due to casting to text(n) #3
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5010,3 +5010,52 @@ fn test_select_dollar_column_from_stage() { | |
| // With table function args, without alias | ||
| snowflake().verified_stmt("SELECT $1, $2 FROM @mystage1(file_format => 'myformat')"); | ||
| } | ||
|
|
||
| #[test] | ||
| fn test_parse_pg_style_cast_to_text_with_length() { | ||
|
||
| let select = snowflake().verified_only_select( | ||
| "SELECT _ID::TEXT(16777216) AS _ID FROM INCARE_ANALYTICS.USER_DETAILS", | ||
| ); | ||
| match only(&select.projection) { | ||
| SelectItem::ExprWithAlias { | ||
| expr: | ||
| Expr::Cast { | ||
| kind: CastKind::DoubleColon, | ||
| data_type, | ||
| .. | ||
| }, | ||
| alias, | ||
| } => { | ||
| assert_eq!(alias.value, "_ID"); | ||
| assert_eq!( | ||
| *data_type, | ||
| DataType::Custom( | ||
| ObjectName::from(vec![Ident::new("TEXT")]), | ||
| vec!["16777216".to_string()], | ||
| ) | ||
| ); | ||
| } | ||
| _ => unreachable!(), | ||
| } | ||
| } | ||
|
|
||
| #[test] | ||
|
||
| fn test_parse_cast_function_to_text_with_length() { | ||
| let select = snowflake().verified_only_select("SELECT CAST(_ID AS TEXT(42)) FROM USER_DETAILS"); | ||
| match expr_from_projection(only(&select.projection)) { | ||
| Expr::Cast { | ||
| kind: CastKind::Cast, | ||
| data_type, | ||
| .. | ||
| } => { | ||
| assert_eq!( | ||
| *data_type, | ||
| DataType::Custom( | ||
| ObjectName::from(vec![Ident::new("TEXT")]), | ||
| vec!["42".to_string()], | ||
| ) | ||
| ); | ||
| } | ||
| _ => unreachable!(), | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this condition, this code can run on all dialects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I addressed this feedback in 90a4ac6.
Summary: Committed the follow-up as
90a4ac6efd021f279cf4fcad8f102977f4cd8165on the current branch. Checklist: - [x] Feedback 1: removed the Snowflake-only condition soTEXT(<modifiers>)is handled for all dialects in src/parser/mod.rs. - [x] Feedback 2: renamed the remaining Snowflake cast regression test totest_parse_cast_to_text_with_lengthin tests/sqlparser_snowflake.rs. - [x] Feedback 3: removed the extra unit test the review calle...