solontsev commented on code in PR #1928:
URL: 
https://github.com/apache/datafusion-sqlparser-rs/pull/1928#discussion_r2207480227


##########
tests/sqlparser_postgres.rs:
##########
@@ -2207,19 +2223,31 @@ fn parse_pg_like_match_ops() {
     ];
 
     for (str_op, op) in pg_like_match_ops {
-        let select = pg().verified_only_select(&format!("SELECT 'abc' {} 
'a_c%'", &str_op));
+        // Basic binary operator usage
+        let select = pg().verified_only_select(&format!("SELECT 'abc' {str_op} 
'a_c%'"));
         assert_eq!(
             SelectItem::UnnamedExpr(Expr::BinaryOp {
-                left: Box::new(Expr::Value(
-                    (Value::SingleQuotedString("abc".into())).with_empty_span()
-                )),
+                left: 
Box::new(Expr::Value(single_quoted_string("abc").with_empty_span(),)),
                 op: op.clone(),
-                right: Box::new(Expr::Value(
-                    
(Value::SingleQuotedString("a_c%".into())).with_empty_span()
-                )),
+                right: 
Box::new(Expr::Value(single_quoted_string("a_c%").with_empty_span(),)),
             }),
             select.projection[0]
         );
+
+        // Binary operator with ALL operator
+        let select =

Review Comment:
   > Are the added operators covered by the tests? if not could we add tests 
covering them?
   
   Yeah, I've added the tests as well. Maybe it was not the best to test 2 
cases during each cycle iteration, I've modified it a bit: a previous match 
against a single value, and added one more to test against an array of values. 
Does it look better now?
   
   Also, to wrap up: The problem now, is that before ANY, ALL or SOME 
functions, parser allows only 6 basic binary operators (gt, lt, gteq, lteq, eq, 
noteq). But those 8 additional are also valid. So the fix basically just adds 
them to the allowlist and tests for match and like operators are modified to 
make sure, parser doesn't return an error in a valid cases. I haven't added 
exhaustive test cases, just chose ANY function for match tests and ALL function 
for like 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: 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