apache/flink · error · IllegalArgumentException

A predicate on a LONG column requires an integer literal, i.

Error message

A predicate on a LONG column requires an integer literal, i.e., Byte, Short, Integer, or Long.

What it means

While converting a pushed-down predicate literal for an ORC LONG-typed column, the Java literal must be Byte, Short, Integer, or Long so it can be widened to org.apache.hadoop.hive.ql.io.sarg.SearchArgument's Long. Any other type (e.g. a floating-point or string literal compared to a BIGINT column, or a BigDecimal) throws IllegalArgumentException.

Source

Thrown at flink-formats/flink-orc/src/main/java/org/apache/flink/orc/OrcFilters.java:425

        ColumnPredicate(String columnName, PredicateLeaf.Type literalType) {
            this.columnName = columnName;
            this.literalType = literalType;
        }

        Object castLiteral(Serializable literal) {

            switch (literalType) {
                case LONG:
                    if (literal instanceof Byte) {
                        return new Long((Byte) literal);
                    } else if (literal instanceof Short) {
                        return new Long((Short) literal);
                    } else if (literal instanceof Integer) {
                        return new Long((Integer) literal);
                    } else if (literal instanceof Long) {
                        return literal;
                    } else {
                        throw new IllegalArgumentException(
                                "A predicate on a LONG column requires an integer "
                                        + "literal, i.e., Byte, Short, Integer, or Long.");
                    }
                case FLOAT:
                    if (literal instanceof Float) {
                        return new Double((Float) literal);
                    } else if (literal instanceof Double) {
                        return literal;
                    } else if (literal instanceof BigDecimal) {
                        return ((BigDecimal) literal).doubleValue();
                    } else {
                        throw new IllegalArgumentException(
                                "A predicate on a FLOAT column requires a floating "
                                        + "literal, i.e., Float or Double.");
                    }
                case STRING:
                    if (literal instanceof String) {
                        return literal;

View on GitHub (pinned to 2f3c205e92)

Solutions

  1. Make the literal an exact integer type in the query: compare against 42 not 42.0, or CAST the literal to the column type.
  2. When building filters programmatically, wrap the value so it is a Long/Integer/Short/Byte before creating the predicate (e.g. ((Number) v).longValue()).
  3. Use the modern ORC filesystem connector, whose pushdown handles literal casts.

Example fix

// before
new OrcFilters.Predicate("id", PredicateLeaf.Type.LONG, 3.5) // wrong literal type
// after
new OrcFilters.Predicate("id", PredicateLeaf.Type.LONG, 3L) // or 4 after rounding
Defensive patterns

Strategy: type-guard

Validate before calling

// Coerce before building the predicate
Object lit = (value instanceof Byte || value instanceof Short
        || value instanceof Integer || value instanceof Long)
        ? ((Number) value).longValue() : null;
if (lit == null) throw new IllegalArgumentException("LONG column needs integer literal");

Type guard

static boolean isLongPushable(Object v) {
    return v instanceof Byte || v instanceof Short || v instanceof Integer || v instanceof Long;
}

Prevention

When it happens

Trigger: An ORC predicate like col_bigint = 3.5 or col_bigint = '123' where the column type maps to PredicateLeaf.Type.LONG but the ValueLiteralExpression's Java value is Float/Double/BigDecimal/String — toOrcType derives LONG from the column, then the literal check fails.

Common situations: Comparing a BIGINT/INT column to a decimal literal typed as BigDecimal by the planner; string literals against numeric columns relying on implicit casts that the legacy OrcFilters path does not perform; programmatic filter construction with mismatched types.

Related errors


AI-assisted analysis of apache/flink@2f3c205e92 (2026-08-14). Data as JSON: /api/errors/7e1c3eb0a93825b8. Report an issue: GitHub.