jiwen624 commented on code in PR #60564:
URL: https://github.com/apache/spark/pull/60564#discussion_r4604796702


##########
sql/catalyst/src/main/java/org/apache/spark/sql/connector/util/V2ExpressionSQLBuilder.java:
##########
@@ -131,9 +132,20 @@ public String build(Expression expr) {
         }
         case "IS_NULL" -> visitIsNull(visitIsNullOperand(e.children()[0]));
         case "IS_NOT_NULL" -> 
visitIsNotNull(visitIsNullOperand(e.children()[0]));
-        case "STARTS_WITH" -> visitStartsWith(build(e.children()[0]), 
build(e.children()[1]));
-        case "ENDS_WITH" -> visitEndsWith(build(e.children()[0]), 
build(e.children()[1]));
-        case "CONTAINS" -> visitContains(build(e.children()[0]), 
build(e.children()[1]));
+        case "STARTS_WITH", "ENDS_WITH", "CONTAINS" -> {
+          // The LIKE pattern is built from the value of the pattern argument, 
so it must be a
+          // string literal. Any other pattern, such as a column, is not 
supported.
+          if (!isNonNullStringLiteral(e.children()[1])) {

Review Comment:
   This check runs before `visitStartsWith`/`visitEndsWith`/`visitContains`, so 
a subclass that overrides them to emit a native function may get an exception 
for a non-literal pattern instead of its own SQL.



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