beliefer commented on code in PR #36330:
URL: https://github.com/apache/spark/pull/36330#discussion_r876791321


##########
sql/catalyst/src/main/java/org/apache/spark/sql/connector/util/V2ExpressionSQLBuilder.java:
##########
@@ -228,4 +244,18 @@ protected String visitSQLFunction(String funcName, 
String[] inputs) {
   protected String visitUnexpectedExpr(Expression expr) throws 
IllegalArgumentException {
     throw new IllegalArgumentException("Unexpected V2 expression: " + expr);
   }
+
+  protected String visitOverlay(String[] inputs) {
+    throw new UnsupportedOperationException("Function: OVERLAY does not 
support ");
+  }
+
+  protected String visitTrim(String direction, String[] inputs) {
+    if (inputs.length == 1) {
+      return "TRIM(" + direction + " FROM " + inputs[0] + ")";
+    } else if (inputs.length == 2) {
+      return "TRIM(" + direction + " " + inputs[1] + " FROM " + inputs[0] + 
")";
+    } else {
+      throw new IllegalStateException("Unexpected V2 function: TRIM");
+    }

Review Comment:
   ```
        if (inputs.length == 1) {
          return "TRIM(" + direction + " FROM " + inputs[0] + ")";
        } else {
          return "TRIM(" + direction + " " + inputs[1] + " FROM " + inputs[0] + 
")";
        }
   ```



##########
sql/core/src/main/scala/org/apache/spark/sql/jdbc/JdbcDialects.scala:
##########
@@ -251,6 +251,30 @@ abstract class JdbcDialect extends Serializable with 
Logging{
           s"${this.getClass.getSimpleName} does not support function: 
$funcName")
       }
     }
+
+    override def visitOverlay(inputs: Array[String]): String = {
+      if (isSupportedFunction("OVERLAY")) {
+        if (inputs.length == 3) {
+          "OVERLAY(" + inputs(0) + " PLACING " + inputs(1) + " FROM " + 
inputs(2) + ")";
+        } else if (inputs.length == 4) {
+          "OVERLAY(" + inputs(0) + " PLACING " + inputs(1) + " FROM " + 
inputs(2) +
+            " FOR " + inputs(3) + ")";
+        } else {
+          throw new IllegalStateException("Unexpected V2 function: OVERLAY");
+        }

Review Comment:
   ```
            if (inputs.length == 3) {
              "OVERLAY(" + inputs(0) + " PLACING " + inputs(1) + " FROM " + 
inputs(2) + ")";
            } else {
              "OVERLAY(" + inputs(0) + " PLACING " + inputs(1) + " FROM " + 
inputs(2) +
                " FOR " + inputs(3) + ")";
            }
   ```



##########
sql/catalyst/src/main/java/org/apache/spark/sql/connector/util/V2ExpressionSQLBuilder.java:
##########
@@ -228,4 +244,18 @@ protected String visitSQLFunction(String funcName, 
String[] inputs) {
   protected String visitUnexpectedExpr(Expression expr) throws 
IllegalArgumentException {
     throw new IllegalArgumentException("Unexpected V2 expression: " + expr);
   }
+
+  protected String visitOverlay(String[] inputs) {
+    throw new UnsupportedOperationException("Function: OVERLAY does not 
support ");

Review Comment:
   ```suggestion
       throw new UnsupportedOperationException(s"${this.getClass.getSimpleName} 
does not support function: OVERLAY");
   ```



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