iffyio commented on code in PR #2403:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2403#discussion_r3655813031
##########
src/dialect/mod.rs:
##########
@@ -1353,6 +1353,13 @@ pub trait Dialect: Debug + Any {
false
}
+ /// Returns true if this dialect supports `INSERT INTO ... BY NAME ...`.
+ ///
+ /// Databricks:
<https://docs.databricks.com/aws/en/sql/language-manual/sql-ref-syntax-dml-insert-into>
+ fn supports_insert_by_name(&self) -> bool {
+ false
+ }
Review Comment:
unless the syntax conflicts with other dialects (doesn't seem to be the
case?) I think we can skip the dialect method and let the parser be permissive?
##########
src/parser/mod.rs:
##########
@@ -18348,6 +18349,9 @@ impl<'a> Parser<'a> {
self.parse_parenthesized_qualified_column_list(Optional, is_mysql)?;
let partitioned = self.parse_insert_partition()?;
+ by_name = columns.is_empty()
+ && self.dialect.supports_insert_by_name()
Review Comment:
```suggestion
by_name = by_name.is_none()
&& self.dialect.supports_insert_by_name()
```
I think we can drop the columns check? its not clear why it would be needed
at this layer, if the implication is something semantic then that can be left
up to the consumer to validate. Relatedly, I assume we need to only set the
name if we don't already have one (can we cover that scenario in the tests)?
--
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]