{"record":{"id":"89381b968b57a0b6","repo":"apache/iceberg","slug":"abovemax-has-no-value","errorCode":null,"errorMessage":"AboveMax has no value","messagePattern":"AboveMax has no value","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"api/src/main/java/org/apache/iceberg/expressions/Literals.java","lineNumber":183,"sourceCode":"    ComparableLiteral(C value) {\n      super(value);\n    }\n\n    @Override\n    @SuppressWarnings(\"unchecked\")\n    public Comparator<C> comparator() {\n      return (Comparator<C>) CMP;\n    }\n  }\n\n  static class AboveMax<T> implements Literal<T> {\n    private static final AboveMax INSTANCE = new AboveMax();\n\n    private AboveMax() {}\n\n    @Override\n    public T value() {\n      throw new UnsupportedOperationException(\"AboveMax has no value\");\n    }\n\n    @Override\n    public <X> Literal<X> to(Type type) {\n      throw new UnsupportedOperationException(\"Cannot change the type of AboveMax\");\n    }\n\n    @Override\n    public Comparator<T> comparator() {\n      throw new UnsupportedOperationException(\"AboveMax has no comparator\");\n    }\n\n    @Override\n    public String toString() {\n      return \"aboveMax\";\n    }\n  }\n","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/apache/iceberg/blob/86d9c8fc543e7c56c9f624eb725f76c9baff9570/api/src/main/java/org/apache/iceberg/expressions/Literals.java#L165-L201","documentation":"AboveMax is a sentinel Literal produced when converting a literal that exceeds the maximum representable value of a target type (Literal.to(Type)). It has no concrete value, so calling value() throws UnsupportedOperationException. The sentinel exists so comparisons like 'x > AboveMax' can be recognized as always-false without a real value.","triggerScenarios":"Calling value() on the literal returned by Literals.aboveMax() or by literal.to(smallType) where the original value overflowed the target type — e.g. in expression evaluation, bound extraction, or statistics code that assumes every literal has a value.","commonSituations":"Narrowing a Long literal to Integer or a Double literal to Float where the value exceeds the target range, then attempting to read the value for lower/upper bound computation.","solutions":["Check for AboveMax/BelowMin (instanceof Literals.AboveMax / Literals.BelowMin) before calling value() and treat them as +/- infinity","Use the literal's comparator or special-case the comparison instead of extracting a value","Recompute the literal in a wider type so a concrete value exists"],"exampleFix":"// before\nObject v = converted.value(); // throws for AboveMax\n// after\nif (converted instanceof Literals.AboveMax) { return alwaysFalse(); }\nObject v = converted.value();","handlingStrategy":"type-guard","validationCode":"if (lit instanceof Literals.AboveMax || lit instanceof Literals.BelowMin) {\n  // handle as +/- infinity; do not call value()\n}","typeGuard":"static boolean hasConcreteValue(Literal<?> lit) {\n  return !(lit instanceof Literals.AboveMax) && !(lit instanceof Literals.BelowMin);\n}","tryCatchPattern":"Object v;\ntry {\n  v = lit.value();\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().contains(\"AboveMax has no value\")) {\n    return treatAsPositiveInfinity();\n  }\n  throw e;\n}","preventionTips":["Always instanceof-check for AboveMax/BelowMin after Literal.to(Type) conversions","Remember any to() can overflow and return a sentinel; extract values only from checked literals","Use comparator-based or bound logic that treats sentinels as +/- infinity instead of reading values"],"tags":["java","literals","sentinel-literal","overflow"],"backgroundTag":"unsupported-operation","analyzedSha":"86d9c8fc543e7c56c9f624eb725f76c9baff9570","analyzedAt":"2026-09-12T00:46:39.097Z","contentChangedAt":"2026-09-12T00:46:39.097Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}