Yifeng-Wang commented on code in PR #9107:
URL: https://github.com/apache/incubator-gluten/pull/9107#discussion_r2453798522


##########
gluten-substrait/src/main/scala/org/apache/gluten/expression/ExpressionConverter.scala:
##########
@@ -144,6 +144,66 @@ object ExpressionConverter extends SQLConfHelper with 
Logging {
     DecimalArithmeticExpressionTransformer(substraitName, leftChild, 
rightChild, resultType, b)
   }
 
+  private def replaceStaticInvokeWithExpressionTransformer(
+      i: StaticInvoke,
+      attributeSeq: Seq[Attribute],
+      expressionsMap: Map[Class[_], String]): ExpressionTransformer = {
+    def validateAndTransform(
+        exprName: String,
+        childTransformers: => Seq[ExpressionTransformer]): 
ExpressionTransformer = {
+      if (!BackendsApiManager.getValidatorApiInstance.doExprValidate(exprName, 
i)) {
+        throw new GlutenNotSupportException(
+          s"Not supported to map current ${i.getClass} call on function: 
${i.functionName}.")
+      }
+      GenericExpressionTransformer(exprName, childTransformers, i)
+    }
+
+    i.functionName match {
+      case "encode" | "decode" if i.objectName.endsWith("UrlCodec") =>
+        validateAndTransform(
+          "url_" + i.functionName,
+          Seq(replaceWithExpressionTransformer0(i.arguments.head, 
attributeSeq, expressionsMap))
+        )
+
+      case "isLuhnNumber" =>
+        validateAndTransform(
+          ExpressionNames.LUHN_CHECK,
+          Seq(replaceWithExpressionTransformer0(i.arguments.head, 
attributeSeq, expressionsMap))
+        )
+
+      case "encode" | "decode" if i.objectName.endsWith("Base64") =>
+        if 
(!BackendsApiManager.getValidatorApiInstance.doExprValidate(ExpressionNames.BASE64,
 i)) {
+          throw new GlutenNotSupportException(
+            s"Not supported to map current ${i.getClass} call on function: 
${i.functionName}.")
+        }

Review Comment:
   Hi rui-mo, thanks for mentioning this. Apologize for such a long context 
within this PR.
   This `doExprValidate` call on validator instance was added deliberately to 
ensure backend actually supports.
   Technically this was from my earlier findings (if you scroll up a bit, on 
Mar 26) , and currently it ensures that:
   - An explicit call on `doExprValidate`.
   - `CH_BLACKLIST_SCALAR_FUNCTION` is looked through during e.g., 
CHValidatorApi::doExprValidate so that the functions which are only supported 
at Velox side, won't cause  "Unknown function parser" for clickhouse BE(in CI 
tests).
   - Intercept at Gluten with `GlutenNotSupportException`, instead of sending 
to actual unsupported (ClickHouse) backend.
   



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