snuyanzin commented on code in PR #28113:
URL: https://github.com/apache/flink/pull/28113#discussion_r3195135990


##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/ExprCodeGenerator.scala:
##########
@@ -462,21 +513,27 @@ class ExprCodeGenerator(ctx: CodeGeneratorContext, 
nullableInput: Boolean)
     val resultType = FlinkTypeFactory.toLogicalType(call.getType)
 
     // throw exception if json function is called outside JSON_OBJECT or 
JSON_ARRAY function
-    if (isJsonFunctionOperand(call)) {
+    if (isJsonFunctionOperand(call, if (rexProgram == null) null else 
rexProgram.getExprList)) {
       throw new ValidationException(
         "The JSON() function is currently only supported inside JSON_ARRAY() 
or as the VALUE param" +
           " of JSON_OBJECT(). Example: JSON_OBJECT('a', JSON('{\"key\": 
\"value\"}')) or " +
           "JSON_ARRAY(JSON('{\"key\": \"value\"}')).")
     }
 
     if (call.getKind == SqlKind.SEARCH) {
-      return generateSearch(
-        ctx,
-        generateExpression(call.getOperands.get(0)),
-        call.getOperands.get(1).asInstanceOf[RexLiteral])
+      val sargLiteral =
+        if (rexProgram != null && 
call.getOperands.get(1).isInstanceOf[RexLocalRef]) {
+          rexProgram.getExprList
+            .get(call.getOperands.get(1).asInstanceOf[RexLocalRef].getIndex)
+            .asInstanceOf[RexLiteral]
+        } else {
+          call.getOperands.get(1).asInstanceOf[RexLiteral]
+        }

Review Comment:
   moved



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

Reply via email to