prestodb/presto · error · UnsupportedOperationException

Number of values not set for orc file. Set session property

Error message

Number of values not set for orc file. Set session property hive.pushdown_partial_aggregations_into_scan=false and execute query again

What it means

writeNonNullCount reads the file-level numberOfValues from the ORC footer ColumnStatistics to serve a pushed-down COUNT. If hasNumberOfValues() is false the statistic is absent, so the aggregated page source cannot compute the count and throws UnsupportedOperationException with a remediation hint.

Source

Thrown at presto-hive/src/main/java/com/facebook/presto/hive/orc/AggregatedOrcPageSource.java:236

                break;

            case BYTE:
            case BOOLEAN:
            case BINARY:
            case UNION:
            case LIST:
            case STRUCT:
            case MAP:
            default:
                throw new IllegalArgumentException("Unsupported type: " + orcType.getOrcTypeKind());
        }
    }

    private void writeNonNullCount(int columnIndex, BlockBuilder blockBuilder)
    {
        ColumnStatistics columnStatistics = footer.getFileStats().get(columnIndex + 1);
        if (!columnStatistics.hasNumberOfValues()) {
            throw new UnsupportedOperationException("Number of values not set for orc file. Set session property hive.pushdown_partial_aggregations_into_scan=false and execute query again");
        }
        blockBuilder.writeLong(columnStatistics.getNumberOfValues());
    }

    @Override
    public long getSystemMemoryUsage()
    {
        return 0;
    }

    @Override
    public void close()
            throws IOException
    {
        // no-op
    }
}

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Set session property hive.pushdown_partial_aggregations_into_scan=false and rerun the query
  2. Disable the property cluster-wide in hive.properties if affected files are common
  3. Rewrite the ORC files so footer statistics include numberOfValues

Example fix

// before
SELECT COUNT(*) FROM t; // Number of values not set for orc file

// after
SET SESSION hive.pushdown_partial_aggregations_into_scan = false;
SELECT COUNT(*) FROM t;
Defensive patterns

Strategy: fallback

Validate before calling

-- inspect footer stats before relying on pushed-down count
-- java -jar orc-tools.jar meta file.orc  # confirm 'numberOfValues' present in column stats
SHOW SESSION LIKE 'hive.pushdown_partial_aggregations_into_scan';

Try / catch

try {
    return runCountQuery(sql);
} catch (PrestoException e) {
    if (String.valueOf(e.getMessage()).contains("Number of values not set")) {
        session.setProperty("hive.pushdown_partial_aggregations_into_scan", "false");
        return runCountQuery(sql);
    }
    throw e;
}

Prevention

When it happens

Trigger: Pushed-down COUNT aggregation over an ORC file whose footer statistics lack numberOfValues for the target column (footer.getFileStats().get(columnIndex+1).hasNumberOfValues() == false), during getNextPage.

Common situations: ORC files written by writers that skip numberOfValues in column stats (e.g., empty stripes, some third-party/legacy writers); mixed-format tables queried with hive.pushdown_partial_aggregations_into_scan enabled.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/15bb376275ae4790. Report an issue: GitHub.