File tree Expand file tree Collapse file tree 2 files changed +46
-1
lines changed
Expand file tree Collapse file tree 2 files changed +46
-1
lines changed Original file line number Diff line number Diff line change @@ -11909,6 +11909,7 @@ impl<'a> Parser<'a> {
1190911909 self.advance_token();
1191011910 let next_token = self.get_current_token();
1191111911 let next_token_index = self.get_current_index();
11912+ let next_token_span = next_token.span;
1191211913
1191311914 let mut trailing_bracket: MatchedTrailingBracket = false.into();
1191411915 let mut data = match &next_token.token {
@@ -12170,7 +12171,14 @@ impl<'a> Parser<'a> {
1217012171 self.expect_token(&Token::RParen)?;
1217112172 Ok(DataType::FixedString(character_length))
1217212173 }
12173- Keyword::TEXT => Ok(DataType::Text),
12174+ Keyword::TEXT => {
12175+ let type_name = w.to_ident(next_token_span);
12176+ if let Some(modifiers) = self.parse_optional_type_modifiers()? {
12177+ Ok(DataType::Custom(type_name.into(), modifiers))
12178+ } else {
12179+ Ok(DataType::Text)
12180+ }
12181+ }
1217412182 Keyword::TINYTEXT => Ok(DataType::TinyText),
1217512183 Keyword::MEDIUMTEXT => Ok(DataType::MediumText),
1217612184 Keyword::LONGTEXT => Ok(DataType::LongText),
Original file line number Diff line number Diff line change @@ -5010,3 +5010,40 @@ fn test_select_dollar_column_from_stage() {
50105010 // With table function args, without alias
50115011 snowflake ( ) . verified_stmt ( "SELECT $1, $2 FROM @mystage1(file_format => 'myformat')" ) ;
50125012}
5013+
5014+ #[ test]
5015+ fn test_text_cast_with_length_modifier ( ) {
5016+ let select = snowflake ( ) . verified_only_select ( "SELECT col::TEXT(16777216) AS col FROM t" ) ;
5017+
5018+ match & select. projection [ 0 ] {
5019+ SelectItem :: ExprWithAlias {
5020+ expr : Expr :: Cast { data_type, .. } ,
5021+ alias,
5022+ } => {
5023+ assert_eq ! ( alias, & Ident :: new( "col" ) ) ;
5024+ assert_eq ! (
5025+ data_type,
5026+ & DataType :: Custom (
5027+ ObjectName :: from( vec![ Ident :: new( "TEXT" ) ] ) ,
5028+ vec![ "16777216" . to_string( ) ] ,
5029+ )
5030+ ) ;
5031+ }
5032+ _ => unreachable ! ( ) ,
5033+ }
5034+
5035+ snowflake ( ) . one_statement_parses_to (
5036+ "SELECT col::TEXT(16777216) AS col FROM t" ,
5037+ "SELECT col::TEXT(16777216) AS col FROM t" ,
5038+ ) ;
5039+ }
5040+
5041+ #[ test]
5042+ fn test_plain_text_data_type_still_parses_as_text ( ) {
5043+ match snowflake ( ) . verified_stmt ( "CREATE TABLE t (c TEXT)" ) {
5044+ Statement :: CreateTable ( CreateTable { columns, .. } ) => {
5045+ assert_eq ! ( columns[ 0 ] . data_type, DataType :: Text ) ;
5046+ }
5047+ _ => unreachable ! ( ) ,
5048+ }
5049+ }
You can’t perform that action at this time.
0 commit comments