finchxxia commented on code in PR #2403:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/2403#discussion_r3869439160


##########
tests/sqlparser_postgres.rs:
##########
@@ -9663,3 +9666,22 @@ fn parse_right_deep_join_chain() {
     // NATURAL JOIN followed by a constrained join must stay left-associative.
     pg().verified_stmt("SELECT * FROM t0 NATURAL JOIN t1 INNER JOIN t2 ON 
true");
 }
+
+#[test]
+fn parse_insert_by_name_keywords_as_table_and_alias() {
+    // Without a table name, `BY NAME` is not an INSERT BY NAME clause. 
PostgreSQL
+    // treats `BY` as the table name and `NAME` as its implicit table alias.
+    match pg().verified_stmt("INSERT INTO BY NAME SELECT 1 AS a") {

Review Comment:
   > is this test case specific to postgres? I would imagine that its part of 
the parse_insert_by_name test in common and that all dialects have the same 
behavior? (i.e. a table_name is required in order for `BY NAME` to be accepted 
as a clause so the grammar seems dialect agnostic from what I can tell from the 
databricks docs)
   
   @iffyio  I agree that the requirement for table_name is dialect-agnostic. 
However, the fallback parse is not identical across all dialects in sqlparser: 
BY is parsed as the table name and NAME as an implicit alias only for dialects 
that support INSERT table aliases, currently PostgreSQL and Oracle. I think I 
can move the test into the common parse_insert_by_name coverage and restrict it 
to those dialects.



-- 
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]

Reply via email to