gustavodemorais commented on code in PR #26474:
URL: https://github.com/apache/flink/pull/26474#discussion_r2057881368


##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/JsonGenerateUtils.scala:
##########
@@ -227,6 +227,23 @@ object JsonGenerateUtils {
     }
   }
 
+  /**
+   * Determines if the parameter index is % 2, which means checking that we 
only allow JSON calls
+   * for the VALUE parameter of a JSON_OBJECT call.
+   */
+  def inValuesParamOfJsonObject(i: Int): Boolean = {
+    (i % 2) == 0
+  }
+
+  /**
+   * Determines whether a JSON function is allowed in the current context. 
JSON functions are
+   * allowed as values in JSON_ARRAY calls or as value parameters in 
JSON_OBJECT calls.
+   */
+  def isSupportedJsonOperand(operand: RexNode, call: RexNode, i: Int): Boolean 
= {
+    isJsonFunctionOperand(operand) &&
+    (isJsonArrayOperand(call) || isJsonObjectOperand(call) && 
inValuesParamOfJsonObject(i))
+  }

Review Comment:
   IMO `inValuesParamOfJsonObject` is more readable than `i % 2 == 0`? Just 
reading the function, the user might ask itself, what is `i` here? Why does it 
has to pass this condition? I think the extra function makes it easier to 
understand. Wdyt?
   



-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to