{"record":{"id":"15bb376275ae4790","repo":"prestodb/presto","slug":"number-of-values-not-set-for-orc-file-set-session","errorCode":null,"errorMessage":"Number of values not set for orc file. Set session property hive.pushdown_partial_aggregations_into_scan=false and execute query again","messagePattern":"Number of values not set for orc file\\. Set session property hive\\.pushdown_partial_aggregations_into_scan=false and execute query again","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/orc/AggregatedOrcPageSource.java","lineNumber":236,"sourceCode":"                break;\n\n            case BYTE:\n            case BOOLEAN:\n            case BINARY:\n            case UNION:\n            case LIST:\n            case STRUCT:\n            case MAP:\n            default:\n                throw new IllegalArgumentException(\"Unsupported type: \" + orcType.getOrcTypeKind());\n        }\n    }\n\n    private void writeNonNullCount(int columnIndex, BlockBuilder blockBuilder)\n    {\n        ColumnStatistics columnStatistics = footer.getFileStats().get(columnIndex + 1);\n        if (!columnStatistics.hasNumberOfValues()) {\n            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\");\n        }\n        blockBuilder.writeLong(columnStatistics.getNumberOfValues());\n    }\n\n    @Override\n    public long getSystemMemoryUsage()\n    {\n        return 0;\n    }\n\n    @Override\n    public void close()\n            throws IOException\n    {\n        // no-op\n    }\n}\n","sourceCodeStart":218,"sourceCodeEnd":254,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/orc/AggregatedOrcPageSource.java#L218-L254","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set session property hive.pushdown_partial_aggregations_into_scan=false and rerun the query","Disable the property cluster-wide in hive.properties if affected files are common","Rewrite the ORC files so footer statistics include numberOfValues"],"exampleFix":"// before\nSELECT COUNT(*) FROM t; // Number of values not set for orc file\n\n// after\nSET SESSION hive.pushdown_partial_aggregations_into_scan = false;\nSELECT COUNT(*) FROM t;","handlingStrategy":"fallback","validationCode":"-- inspect footer stats before relying on pushed-down count\n-- java -jar orc-tools.jar meta file.orc  # confirm 'numberOfValues' present in column stats\nSHOW SESSION LIKE 'hive.pushdown_partial_aggregations_into_scan';","typeGuard":null,"tryCatchPattern":"try {\n    return runCountQuery(sql);\n} catch (PrestoException e) {\n    if (String.valueOf(e.getMessage()).contains(\"Number of values not set\")) {\n        session.setProperty(\"hive.pushdown_partial_aggregations_into_scan\", \"false\");\n        return runCountQuery(sql);\n    }\n    throw e;\n}","preventionTips":["Rewrite legacy ORC files with current Hive/Spark writers so footers carry numberOfValues","Disable partial-aggregation pushdown when reading mixed-writer tables","Validate footers with orc-tools during ingestion pipelines"],"tags":["orc","hive","statistics","count-aggregation","pushdown"],"backgroundTag":"orc-missing-column-statistics","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}