{"record":{"id":"c4e9c2da1b6e374a","repo":"prestodb/presto","slug":"pinot-exception-c4e9c2","errorCode":"PINOT_EXCEPTION","errorMessage":"Expected pinot to contain %d columns but got %d: %s","messagePattern":"Expected pinot to contain (.+?) columns but got (.+?): (.+?)","errorType":"error_code","errorClass":"PinotException","httpStatus":null,"severity":"error","filePath":"presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/PinotSegmentPageSource.java","lineNumber":112,"sourceCode":"        this.columnTypes = columnHandles.stream()\n                .map(PinotSegmentPageSource::getTypeForBlock)\n                .collect(Collectors.toList());\n        this.pinotStreamingQueryClient = requireNonNull(pinotStreamingQueryClient, \"pinotStreamingQueryClient is null\");\n    }\n\n    public static void checkExceptions(DataTable dataTable, PinotSplit split, boolean markDataFetchExceptionsAsRetriable)\n    {\n        List<String> exceptions = dataTable.getExceptions().values().stream().toList();\n        if (!exceptions.isEmpty()) {\n            throw new PinotException(\n                markDataFetchExceptionsAsRetriable ? PINOT_DATA_FETCH_EXCEPTION : PINOT_EXCEPTION,\n                split.getSegmentPinotQuery(),\n                String.format(\"Encountered %d pinot exceptions for split %s: %s\", exceptions.size(), split, exceptions));\n        }\n        int numColumnsExpected = split.getExpectedColumnHandles().size();\n        int numColumnsActual = dataTable.getDataSchema().size();\n        if (numColumnsActual != numColumnsExpected) {\n            throw new PinotException(\n                    PINOT_EXCEPTION,\n                    split.getSegmentPinotQuery(),\n                    String.format(\"Expected pinot to contain %d columns but got %d: %s\", numColumnsExpected, numColumnsActual, dataTable.getDataSchema()));\n        }\n    }\n\n    @Override\n    public long getCompletedBytes()\n    {\n        return completedBytes;\n    }\n\n    @Override\n    public long getReadTimeNanos()\n    {\n        return readTimeNanos;\n    }\n","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/PinotSegmentPageSource.java#L94-L130","documentation":"The connector validates that the DataTable returned by Pinot has exactly as many columns as the column handles the split's generated SQL expected. A mismatch means the server returned a schema different from what the generated segment query asked for, so the connector throws PINOT_EXCEPTION with both counts and the actual schema.","triggerScenarios":"checkExceptions compares split.getExpectedColumnHandles().size() with dataTable.getDataSchema().size() and they differ — e.g. Pinot dropped, added, or renamed output columns relative to the generated SQL.","commonSituations":"Pinot version skew changing result schema behavior; queries hitting dynamic/schema-evolution mismatches where a column exists in Presto's metadata but not in all segments; broker rewriting the query.","solutions":["Compare the actual DataSchema in the message against expected handles to spot the missing/extra column","Sync the Pinot table schema: reload segments or refresh metadata so all segments match the Presto connector's view","Check for Pinot broker/server version mismatches and align cluster versions","Re-run DESCRIBE / refresh Presto metadata cache for the table, then retry"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// refresh metadata and verify schema consistency before querying\n// DESCRIBE table; ensure columns exist in Pinot and all segments are refreshed","typeGuard":null,"tryCatchPattern":"catch (PinotException e) {\n    if (String.valueOf(e.getMessage()).startsWith(\"Expected pinot to contain\")) {\n        // compare expected vs actual schema in message; resync Pinot schema/metadata\n    }\n}","preventionTips":["Keep Presto connector and Pinot cluster versions aligned","Refresh Pinot segments after schema evolution so all segments share the schema","Clear Presto metadata caches after Pinot schema changes"],"tags":["pinot","schema-mismatch","data-fetch","column-count"],"backgroundTag":"schema-column-count-mismatch","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"}