zabetak commented on a change in pull request #2230:
URL: https://github.com/apache/calcite/pull/2230#discussion_r524987928



##########
File path: core/src/main/java/org/apache/calcite/runtime/SqlFunctions.java
##########
@@ -2956,7 +2963,12 @@ public static Object structAccess(Object structObject, 
int index, String fieldNa
     } else {
       Class<?> beanClass = structObject.getClass();
       try {
-        Field structField = beanClass.getDeclaredField(fieldName);
+        Field structField;
+        if (fieldName == null) {
+          structField = beanClass.getDeclaredFields()[index];

Review comment:
       Thanks for taking a look @vlsi . 
   
   When we create the model/types we rely more or less on the same methods 
(e.g., 
https://github.com/apache/calcite/blob/3ccad7b2bcc962d48c1dee1c9604fd085d82c608/core/src/main/java/org/apache/calcite/jdbc/JavaTypeFactoryImpl.java#L75)
 so in many cases the code should work fine I think. I don't know how we can 
handle this better with the way the code is right now. Do you have a better 
idea?
   
   It's true that the exception should be updated. I will take care of it but 
let's see if there are other things to do at the same time.




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

For queries about this service, please contact Infrastructure at:
[email protected]


Reply via email to