funcpp commented on code in PR #2170:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2170#discussion_r2726119591
##########
src/parser/mod.rs:
##########
@@ -7907,14 +7890,41 @@ impl<'a> Parser<'a> {
pub fn parse_hive_distribution(&mut self) -> Result<HiveDistributionStyle,
ParserError> {
if self.parse_keywords(&[Keyword::PARTITIONED, Keyword::BY]) {
self.expect_token(&Token::LParen)?;
- let columns =
self.parse_comma_separated(Parser::parse_column_def)?;
+ let columns =
self.parse_comma_separated(Parser::parse_column_def_for_partition)?;
self.expect_token(&Token::RParen)?;
Ok(HiveDistributionStyle::PARTITIONED { columns })
} else {
Ok(HiveDistributionStyle::NONE)
}
}
+ /// Parse column definition for PARTITIONED BY clause.
+ ///
+ /// Databricks allows partition columns without types when referencing
+ /// columns already defined in the table specification:
+ /// ```sql
+ /// CREATE TABLE t (col1 STRING, col2 INT) PARTITIONED BY (col1)
+ /// CREATE TABLE t (col1 STRING) PARTITIONED BY (col2 INT)
+ /// ```
+ ///
+ /// See
[Databricks](https://docs.databricks.com/en/sql/language-manual/sql-ref-partition.html)
+ fn parse_column_def_for_partition(&mut self) -> Result<ColumnDef,
ParserError> {
Review Comment:
Since `DataType::Unspecified` already exists and is used by SQLite for
similar "type-less" scenarios, I thought reusing it would keep things simpler
without adding another AST type. Do two cases have different meaning?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]