twalthr commented on code in PR #29636:
URL: https://github.com/apache/flink/pull/29636#discussion_r4389862200


##########
flink-table/flink-table-planner/src/test/java/org/apache/flink/table/planner/plan/nodes/exec/stream/VariantSemanticTest.java:
##########
@@ -610,6 +655,7 @@ public List<TableTestProgram> programs() {
                 VARIANT_ARRAY_ACCESS,
                 VARIANT_ARRAY_ACCESS_WITH_DIFFERENT_INDEX_TYPES,
                 VARIANT_OBJECT_ACCESS,
+                VARIANT_OBJECT_ACCESS_WITH_NON_LITERAL_KEY,

Review Comment:
   can we also add a test for array access without index literals



##########
flink-table/flink-table-planner/src/main/scala/org/apache/flink/table/planner/codegen/calls/ScalarOperatorGens.scala:
##########
@@ -1747,11 +1747,18 @@ object ScalarOperatorGens {
         tmpValue
       )
     } else if (isCharacterString(keyType)) {
-      val fieldName = key.literalValue.get.toString
+      val fieldAccess = key.literalValue match {
+        case Some(fieldName) if fieldName != null =>
+          val getterTerm =
+            ctx.addReusableObject(new VariantFieldGetter(fieldName.toString), 
"variantFieldGetter")
+          s"$getterTerm.getField($variantTerm)"
+        // A key that is not a literal, or a NULL literal, whose access code 
never runs.
+        case _ => s"$variantTerm.getField($keyTerm.toString())"

Review Comment:
   ```suggestion
           case _ => s"$variantTerm.getField($keyTerm)"
   ```



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