karuppayya commented on code in PR #3895:
URL: https://github.com/apache/datafusion-comet/pull/3895#discussion_r3059344168


##########
spark/src/main/scala/org/apache/comet/iceberg/IcebergReflection.scala:
##########
@@ -228,11 +228,18 @@ object IcebergReflection extends Logging {
           val opsMethod = table.getClass.getDeclaredMethod("operations")
           opsMethod.setAccessible(true)
           val ops = opsMethod.invoke(table)
-          val currentMethod = ops.getClass.getDeclaredMethod("current")
-          currentMethod.setAccessible(true)
-          val metadata = currentMethod.invoke(ops)
-          val formatVersionMethod = 
metadata.getClass.getMethod("formatVersion")
-          Some(formatVersionMethod.invoke(metadata).asInstanceOf[Int])
+          findMethodInHierarchy(ops.getClass, "current")

Review Comment:
   I think we could always call replace all occurences of `getDeclaredMethod` 
with `findMethodInHierarchy`
   Especially, those that assume the superclass's depth seems fragile
   ```
         val tasksMethod = scan.getClass.getSuperclass
           .getDeclaredMethod("tasks")
   ```
   ```
         val filterExpressionsMethod = scan.getClass.getSuperclass.getSuperclass
           .getDeclaredMethod("filterExpressions")
    ```  



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to