cloud-fan commented on a change in pull request #35768:
URL: https://github.com/apache/spark/pull/35768#discussion_r830758070



##########
File path: 
sql/catalyst/src/main/java/org/apache/spark/sql/connector/util/V2ExpressionSQLBuilder.java
##########
@@ -103,12 +123,45 @@ protected String visitIsNotNull(String v) {
     return v + " IS NOT NULL";
   }
 
+  protected String visitStringPredicate(String name, GeneralScalarExpression 
strPredicate) {
+    String l = build(strPredicate.children()[0]);
+    String r = build(strPredicate.children()[1]);
+    String value = r.replaceAll("'", "");
+    switch (name) {
+      case "STARTS_WITH":
+        return l + " LIKE '" + value + "%'";
+      case "ENDS_WITH":
+        return l + " LIKE '%" + value + "'";
+      case "CONTAINS":
+        return l + " LIKE '%" + value + "%'";
+      default:
+        return visitUnexpectedExpr(strPredicate);
+    }
+  }
+
+  private String inputToSQL(Expression input) {
+    if (input.children().length > 1) {
+      return "(" + build(input) + ")";
+    } else {
+      return build(input);
+    }
+  }
+
   protected String visitBinaryComparison(String name, String l, String r) {
-    return "(" + l + ") " + name + " (" + r + ")";
+    switch (name) {
+      case "<=>":
+        return "(" + l + " = " + r + ") OR (" + l + " IS NULL AND " + r + " IS 
NULL)";
+      default:
+        return l + " " + name + " " + r;
+    }
+  }
+
+  private int childNum(Expression expr) {

Review comment:
       This is not used anywhere.




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