{"record":{"id":"9fa22ed45c776108","repo":"prestodb/presto","slug":"pinot-query-generator-failure","errorCode":"PINOT_QUERY_GENERATOR_FAILURE","errorMessage":"Limit  not supported: Limit is not being pushed down","messagePattern":"Limit  not supported: Limit is not being pushed down","errorType":"error_code","errorClass":"PinotException","httpStatus":null,"severity":"error","filePath":"presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGeneratorContext.java","lineNumber":210,"sourceCode":"    {\n        checkSupported(!newOutputs.isEmpty(), \"Missing output expression in Pinot query context\");\n        return new PinotQueryGeneratorContext(\n                newSelections,\n                newOutputs,\n                from,\n                filter,\n                aggregations,\n                groupByColumns,\n                topNColumnInformationMap,\n                limit,\n                variablesInAggregation,\n                hiddenColumnSet);\n    }\n\n    private static int checkForValidLimit(long limit)\n    {\n        if (limit <= 0 || limit > Integer.MAX_VALUE) {\n            throw new PinotException(PINOT_QUERY_GENERATOR_FAILURE, Optional.empty(), \"Limit \" + limit + \" not supported: Limit is not being pushed down\");\n        }\n        return toIntExact(limit);\n    }\n\n    /**\n     * Apply limit to current context and return the updated context. Throws error for invalid operations.\n     */\n    public PinotQueryGeneratorContext withLimit(long limit)\n    {\n        int intLimit = checkForValidLimit(limit);\n        checkSupported(!hasLimit(), \"Limit already exists. Pinot doesn't support limit on top of another limit\");\n        return new PinotQueryGeneratorContext(\n                selections,\n                outputs,\n                from,\n                filter,\n                aggregations,\n                groupByColumns,","sourceCodeStart":192,"sourceCodeEnd":228,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGeneratorContext.java#L192-L228","documentation":"checkForValidLimit converts the plan's LIMIT into an int for the generated Pinot query. A limit of 0, negative, or above Integer.MAX_VALUE cannot be represented as a valid Pinot LIMIT clause, so the context throws PINOT_QUERY_GENERATOR_FAILURE indicating the limit is not being pushed down.","triggerScenarios":"A LIMIT pushdown is attempted with limit <= 0 or limit > 2147483647, e.g. LIMIT 0 queries emitted by optimizers/BI tools, or huge limits like LIMIT 100000000000 used as 'fetch everything'.","commonSituations":"BI tools issuing LIMIT 0 for schema probes; ORM-generated queries with sentinel limits; queries using an enormous LIMIT to mean 'no limit' against a Pinot table.","solutions":["Replace the invalid LIMIT with a positive value <= 2147483647 (e.g. LIMIT 1000000).","For 'fetch everything' semantics, omit the LIMIT and configure pinot.limit-large-for-segment / broker limits appropriately.","If LIMIT 0 is intentional (metadata probe), run it against a different connector or handle it client-side without Pinot pushdown."],"exampleFix":"// before\nSELECT * FROM events LIMIT 0;\n// after\nSELECT * FROM events LIMIT 1; // or a real positive limit","handlingStrategy":"validation","validationCode":"long limit = requestedLimit;\nif (limit <= 0 || limit > Integer.MAX_VALUE) {\n    throw new IllegalArgumentException(\"Limit not pushable to Pinot: \" + limit);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never emit LIMIT 0 or negative limits toward Pinot tables.","Cap programmatic limits at 2147483647; use a sane default like 10000.","Use configured large-limit properties for 'fetch everything' semantics instead of giant LIMITs."],"tags":["pinot","pushdown","limit","argument-validation"],"backgroundTag":"invalid-limit-pushdown","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"}