@@ -3334,9 +3334,7 @@ impl<'a> Parser<'a> {
33343334 /// Syntax:
33353335 ///
33363336 /// ```sql
3337- /// -- BigQuery style
33383337 /// [field_name] field_type
3339- /// -- Databricks/Hive style (colon separator)
33403338 /// field_name: field_type
33413339 /// ```
33423340 ///
@@ -3348,17 +3346,13 @@ impl<'a> Parser<'a> {
33483346 ) -> Result<(StructField, MatchedTrailingBracket), ParserError> {
33493347 // Look beyond the next item to infer whether both field name
33503348 // and type are specified.
3351- // Supports both:
3352- // - `field_name field_type` (BigQuery style)
3353- // - `field_name: field_type` (Databricks/Hive style)
33543349 let is_named_field = matches!(
33553350 (self.peek_nth_token(0).token, self.peek_nth_token(1).token),
33563351 (Token::Word(_), Token::Word(_)) | (Token::Word(_), Token::Colon)
33573352 );
33583353
33593354 let field_name = if is_named_field {
33603355 let name = self.parse_identifier()?;
3361- // Consume optional colon separator (Databricks/Hive style)
33623356 let _ = self.consume_token(&Token::Colon);
33633357 Some(name)
33643358 } else {
@@ -7890,33 +7884,29 @@ impl<'a> Parser<'a> {
78907884 pub fn parse_hive_distribution(&mut self) -> Result<HiveDistributionStyle, ParserError> {
78917885 if self.parse_keywords(&[Keyword::PARTITIONED, Keyword::BY]) {
78927886 self.expect_token(&Token::LParen)?;
7893- let columns = self.parse_comma_separated(Parser::parse_column_def_for_partition )?;
7887+ let columns = self.parse_comma_separated(Parser::parse_partitioned_by_column_def )?;
78947888 self.expect_token(&Token::RParen)?;
78957889 Ok(HiveDistributionStyle::PARTITIONED { columns })
78967890 } else {
78977891 Ok(HiveDistributionStyle::NONE)
78987892 }
78997893 }
79007894
7901- /// Parse column definition for PARTITIONED BY clause.
7895+ /// Parse column definition for ` PARTITIONED BY` clause.
79027896 ///
7903- /// Databricks allows partition columns without types when referencing
7897+ /// Allows partition columns without types when referencing
79047898 /// columns already defined in the table specification:
79057899 /// ```sql
79067900 /// CREATE TABLE t (col1 STRING, col2 INT) PARTITIONED BY (col1)
79077901 /// CREATE TABLE t (col1 STRING) PARTITIONED BY (col2 INT)
79087902 /// ```
79097903 ///
7910- /// See [Databricks](https://docs.databricks.com/en/sql/language-manual/sql-ref-partition.html)
7911- fn parse_column_def_for_partition (&mut self) -> Result<ColumnDef, ParserError> {
7904+ /// [Databricks](https://docs.databricks.com/en/sql/language-manual/sql-ref-partition.html)
7905+ fn parse_partitioned_by_column_def (&mut self) -> Result<ColumnDef, ParserError> {
79127906 let name = self.parse_identifier()?;
7913-
7914- // Check if the next token indicates there's no type specified
7915- // (comma or closing paren means end of this column definition)
7916- let data_type = match self.peek_token().token {
7917- Token::Comma | Token::RParen => DataType::Unspecified,
7918- _ => self.parse_data_type()?,
7919- };
7907+ let data_type = self
7908+ .maybe_parse(|parser| parser.parse_data_type())?
7909+ .unwrap_or(DataType::Unspecified);
79207910
79217911 Ok(ColumnDef {
79227912 name,
@@ -18256,7 +18246,6 @@ impl<'a> Parser<'a> {
1825618246 /// ```
1825718247 /// [Databricks](https://docs.databricks.com/en/sql/language-manual/delta-optimize.html)
1825818248 pub fn parse_optimize_table(&mut self) -> Result<Statement, ParserError> {
18259- // Check for TABLE keyword (ClickHouse uses it, Databricks does not)
1826018249 let has_table_keyword = self.parse_keyword(Keyword::TABLE);
1826118250
1826218251 let name = self.parse_object_name(false)?;
0 commit comments