Skip to content

Core: Fix NPE of generateRandomMetrics in FileGenerationUtil#15748

Open
dramaticlly wants to merge 2 commits intoapache:mainfrom
dramaticlly:fix-filegenerationUtil
Open

Core: Fix NPE of generateRandomMetrics in FileGenerationUtil#15748
dramaticlly wants to merge 2 commits intoapache:mainfrom
dramaticlly:fix-filegenerationUtil

Conversation

@dramaticlly
Copy link
Copy Markdown
Contributor

@dramaticlly dramaticlly commented Mar 23, 2026

fix NPE because NaturalOrderComparator.compare will not accept the null. And if the metrics mode is None or Count, today it returns null in FileGenerationUtil:: generateBound

if (mode instanceof None || mode instanceof Counts) {
return null;

Cannot invoke "java.lang.Comparable.compareTo(Object)" because "c1" is null
java.lang.NullPointerException: Cannot invoke "java.lang.Comparable.compareTo(Object)" because "c1" is null
	at java.base/java.util.Comparators$NaturalOrderComparator.compare(Comparators.java:52)
	at java.base/java.util.Comparators$NaturalOrderComparator.compare(Comparators.java:47)
	at org.apache.iceberg.FileGenerationUtil.generateBounds(FileGenerationUtil.java:290)
	at org.apache.iceberg.FileGenerationUtil.generateRandomMetrics(FileGenerationUtil.java:193)
	at org.apache.iceberg.TestFileGenerationUtil.testBoundsForAllMetricsModes(TestFileGenerationUtil.java:113)

@github-actions github-actions bot added the core label Mar 23, 2026
@dramaticlly
Copy link
Copy Markdown
Contributor Author

FYI @aokolnychyi @nastra

Copy link
Copy Markdown
Contributor

@huaxingao huaxingao left a comment

Choose a reason for hiding this comment

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

LGTM

@huaxingao huaxingao changed the title [Core] Fix NPE of generateRandomMetrics in FileGenerationUtil Core: Fix NPE of generateRandomMetrics in FileGenerationUtil Mar 24, 2026
Copy link
Copy Markdown
Contributor

@singhpk234 singhpk234 left a comment

Choose a reason for hiding this comment

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

LGTM with a minor suggestions, thanks @dramaticlly

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants