yuxiqian commented on code in PR #4241:
URL: https://github.com/apache/flink-cdc/pull/4241#discussion_r2752962879
##########
flink-cdc-runtime/src/main/java/org/apache/flink/cdc/runtime/parser/JaninoCompiler.java:
##########
@@ -468,6 +470,37 @@ private static Java.Rvalue generateOtherOperation(
throw new ParseException("Unrecognized expression: " +
sqlBasicCall.toString());
}
+ private static Java.Rvalue generateItemAccessOperation(
+ Context context, SqlBasicCall sqlBasicCall, Java.Rvalue[] atoms) {
+ if (atoms.length != 2) {
+ throw new ParseException("Unrecognized item access expression: " +
sqlBasicCall);
+ }
+ Java.Rvalue methodInvocation =
+ new Java.MethodInvocation(Location.NOWHERE, null,
"itemAccess", atoms);
+
+ // Deduce the return type and add a cast to ensure proper type
conversion
+ DataType resultType =
+ TransformParser.deduceSubExpressionType(
+ context.columns,
+ sqlBasicCall,
+ context.udfDescriptors,
+ context.supportedMetadataColumns);
+
+ // Get the Java class for the result type and add a cast
+ Class<?> javaClass = JavaClassConverter.toJavaClass(resultType);
+ if (javaClass != null && javaClass != Object.class) {
+ return new Java.Cast(
+ Location.NOWHERE,
+ new Java.ReferenceType(
+ Location.NOWHERE,
+ new Java.Annotation[0],
+ javaClass.getName().split("\\."),
Review Comment:
Shall we use `getCanonicalName()` here? Adding a test to index
`ARRAY<BINARY>` might be able to verify this.
```
jshell> byte[].class.getName()
$1 ==> "[B"
jshell> byte[].class.getCanonicalName()
$2 ==> "byte[]"
```
--
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]