raminqaf commented on code in PR #29636:
URL: https://github.com/apache/flink/pull/29636#discussion_r4394378568
##########
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:
`$keyTerm` is of type `BinaryStringData` so dropping the `toString()` will
cause Janino to fail.
We can `toBytes` and add a helper to `BinaryVariant`, but we need the
guaranty that the bytes are valid UTF-8.
```suggestion
case _ => s"$variantTerm.getField($keyTerm.toBytes())"
```
--
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]