Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

org.apache.iceberg.expressions.(Max/Min)Aggregate Don't handle null DataFile.(upper/lower)Bounds() #10258

Closed
jkolash opened this issue May 1, 2024 · 2 comments 路 Fixed by #10273
Labels
bug Something isn't working

Comments

@jkolash
Copy link
Contributor

jkolash commented May 1, 2024

Apache Iceberg version

1.5.0

Query engine

Spark

Please describe the bug 馃悶

If you use the snapshot table command and run

select max(intValue) from table this can be reproduced.

The spec says this is optional
https://iceberg.apache.org/spec/#manifests
image

Let me know if you want me to provide a test case/fix as it seems like a pretty simple issue to test/fix for.

@jkolash jkolash added the bug Something isn't working label May 1, 2024
@jkolash
Copy link
Contributor Author

jkolash commented May 1, 2024

relevant code
https://github.com/apache/iceberg/blob/main/api/src/main/java/org/apache/iceberg/expressions/MaxAggregate.java#L42

  @Override
  protected boolean hasValue(DataFile file) {
    boolean hasBound = file.upperBounds().containsKey(fieldId); //NPE here
    Long valueCount = safeGet(file.valueCounts(), fieldId);
    Long nullCount = safeGet(file.nullValueCounts(), fieldId);
    boolean boundAllNull =
        valueCount != null
            && valueCount > 0
            && nullCount != null
            && nullCount.longValue() == valueCount.longValue();
    return hasBound || boundAllNull;
  }

@amogh-jahagirdar
Copy link
Contributor

Let me know if you want me to provide a test case/fix as it seems like a pretty simple issue to test/fix for.

@jkolash if you're up for it, feel free to raise a PR! I'm happy to review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants