iffyio commented on code in PR #2403:
URL:
https://github.com/apache/datafusion-sqlparser-rs/pull/2403#discussion_r3703079612
##########
tests/sqlparser_databricks.rs:
##########
@@ -737,3 +737,34 @@ fn parse_cte_without_as() {
.parse_sql_statements("WITH cte (SELECT 1) SELECT * FROM cte")
.is_err());
}
+
+#[test]
+fn test_databricks_insert_by_name() {
+ match databricks_and_generic().verified_stmt("INSERT INTO target BY NAME
SELECT 1 AS a") {
Review Comment:
we can remove the AST assertion and rely on verified_stmt only for these,
(AST is already covered in common)
##########
src/parser/mod.rs:
##########
@@ -18404,7 +18404,9 @@ impl<'a> Parser<'a> {
let table = self.parse_keyword(Keyword::TABLE);
let table_object = self.parse_table_object()?;
+ // `BY NAME` is an INSERT clause, not a table alias.
let table_alias = if self.dialect.supports_insert_table_alias()
+ && !self.peek_keywords(&[Keyword::BY, Keyword::NAME])
Review Comment:
oh this pattern looks a bit odd, would it make more sense to do the
following?
``` rust
let mut by_name = self.peek_keywords(&[BY, NAME]);
let table_alias = if ... // unchanged
// ...
let partitioned = self.parse_insert_partition()?;
by_name = by_name || self.parse_keywords(&[Keyword::BY, Keyword::NAME]);
```
##########
tests/sqlparser_common.rs:
##########
@@ -19665,3 +19665,18 @@ fn
parse_function_arg_call_chain_no_exponential_blowup() {
rx.recv_timeout(Duration::from_secs(5))
.expect("parser should reject this quickly, not loop exponentially");
}
+
+#[test]
+fn parse_insert_by_name_in_all_dialects() {
+ verified_stmt("INSERT INTO target BY NAME SELECT 1 AS a");
Review Comment:
maybe we can also add some scenarios with table options that cover around
the new option to ensure that parsing `BY NAME` isn't conflicting with other
features that show up around it
##########
tests/sqlparser_common.rs:
##########
@@ -19665,3 +19665,18 @@ fn
parse_function_arg_call_chain_no_exponential_blowup() {
rx.recv_timeout(Duration::from_secs(5))
.expect("parser should reject this quickly, not loop exponentially");
}
+
+#[test]
+fn parse_insert_by_name_in_all_dialects() {
Review Comment:
```suggestion
fn parse_insert_by_name() {
```
--
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]