Skip to content

fix: Iceberg reflection for current() on TableOperations hierarchy#3895

Open
karuppayya wants to merge 2 commits intoapache:mainfrom
karuppayya:fix-mehthod-hierarchy
Open

fix: Iceberg reflection for current() on TableOperations hierarchy#3895
karuppayya wants to merge 2 commits intoapache:mainfrom
karuppayya:fix-mehthod-hierarchy

Conversation

@karuppayya
Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #3894.

Rationale for this change

Fix NoSuchMethodException from Iceberg Reflection

What changes are included in this PR?

Use findMethodInHierarchy instead of getDeclaredMethod so getTableMetadata and format-version reflection work when current() is declared on a superclass (e.g. BaseMetastoreTableOperations for Hive/Glue-style ops).

How are these changes tested?

  • Added Units
  • Tested by querying Hive backed Iceberg tables where this issue is present.

@mbutrovich mbutrovich changed the title Fix Iceberg reflection for current() on TableOperations hierarchy fix: Iceberg reflection for current() on TableOperations hierarchy Apr 3, 2026
@karuppayya karuppayya force-pushed the fix-mehthod-hierarchy branch 2 times, most recently from 433832e to 904c10f Compare April 7, 2026 23:13
@karuppayya
Copy link
Copy Markdown
Contributor Author

cc: @andygrove @mbutrovich @parthchandra
can any of you help review?
Also looks like workflow needs maintainer approval to progress(But remember that it used to work without this)

val metadata = currentMethod.invoke(ops)
val formatVersionMethod = metadata.getClass.getMethod("formatVersion")
Some(formatVersionMethod.invoke(metadata).asInstanceOf[Int])
findMethodInHierarchy(ops.getClass, "current")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is current the only method affected? operations (a few lines above this) is calling getDeclaredMethod also.
Also, are there other catalog implementations that could have similar issues but for other methods?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mbutrovich wdyt? Is there a potential performance impact here if we replace getDeclaredMethod with findMethodInHierarchy?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I tried that at some point but it's been at least 6 months, open to trying again.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thinking this over, I feel we can defer changing everything over to use findMethodInHierarchy until we hit an issue.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sgtm

Use findMethodInHierarchy instead of getDeclaredMethod so getTableMetadata and format-version reflection work when current() is declared on a superclass (e.g. BaseMetastoreTableOperations for Hive/Glue-style ops).

Add IcebergReflectionSuite with a BaseMetastoreTableOperations stub and BaseTable.

Made-with: Cursor
@karuppayya karuppayya force-pushed the fix-mehthod-hierarchy branch from 904c10f to c602b73 Compare April 9, 2026 16:52
Copy link
Copy Markdown
Contributor

@parthchandra parthchandra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, pending ci

@parthchandra
Copy link
Copy Markdown
Contributor

We've exposed a latent bug, perhaps. In CometScanRule.validateIcebergFileScanTasks, uri.getScheme returns null for the relative paths returned by InMemoryCatalog. We check

        if (scheme != null && !supportedSchemes.contains(scheme)) {
          unsupportedSchemes += scheme
        }

which allows such paths and this later fails.
@mbutrovich, any thoughts on how to handle this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

NoSuchMethodException when reflecting Iceberg TableOperations.current()

3 participants