iffyio commented on code in PR #1780:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/1780#discussion_r2062522304


##########
src/parser/mod.rs:
##########
@@ -15375,6 +15391,17 @@ impl<'a> Parser<'a> {
     }
 }
 
+fn prefixed_expr(expr: Expr, prefix: Option<Ident>) -> Expr {

Review Comment:
   ```suggestion
   fn maybe_prefixed_expr(expr: Expr, prefix: Option<Ident>) -> Expr {
   ```
   thinking in order to flag that the prefixing is optional



##########
tests/sqlparser_snowflake.rs:
##########
@@ -3983,3 +3983,38 @@ fn test_nested_join_without_parentheses() {
         }],
     );
 }
+
+#[test]
+fn parse_connect_by_root_operator() {
+    let sql = "SELECT CONNECT_BY_ROOT name AS root_name FROM Tbl1";
+
+    match snowflake().verified_stmt(sql) {
+        Statement::Query(query) => {
+            assert_eq!(
+                query.body.as_select().unwrap().projection[0],
+                SelectItem::ExprWithAlias {
+                    expr: Expr::Prefixed {
+                        prefix: Ident::new("CONNECT_BY_ROOT"),
+                        value: Box::new(Expr::Identifier(Ident::new("name")))
+                    },
+                    alias: Ident::new("root_name"),
+                }
+            );
+        }
+        _ => unreachable!(),
+    }
+
+    let sql = "SELECT CONNECT_BY_ROOT name FROM Tbl2";
+    match snowflake().verified_stmt(sql) {
+        Statement::Query(query) => {
+            assert_eq!(
+                query.body.as_select().unwrap().projection[0],
+                SelectItem::UnnamedExpr(Expr::Prefixed {
+                    prefix: Ident::new("CONNECT_BY_ROOT"),
+                    value: Box::new(Expr::Identifier(Ident::new("name")))
+                })
+            );
+        }
+        _ => unreachable!(),

Review Comment:
   can we add a test case for e.g. `SELECT connect_by_root FROM T`? i.e. one 
that uses the keyword as the projected column 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: github-unsubscr...@datafusion.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org
For additional commands, e-mail: github-h...@datafusion.apache.org

Reply via email to