{"record":{"id":"0fcfe61fbf8bd4b4","repo":"prestodb/presto","slug":"pinot-invalid-segment-query-generated","errorCode":"PINOT_INVALID_SEGMENT_QUERY_GENERATED","errorMessage":"Expected the segment split to contain the pinot query","messagePattern":"Expected the segment split to contain the pinot query","errorType":"error_code","errorClass":"PinotException","httpStatus":null,"severity":"error","filePath":"presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/PinotSegmentPageSource.java","lineNumber":249,"sourceCode":"            }\n            Page page = fillNextPage();\n            completedPositions += currentDataTable.getDataTable().getNumberOfRows();\n            return page;\n        }\n        finally {\n            if (byteBuffer != null) {\n                ((Buffer) byteBuffer).clear();\n            }\n        }\n    }\n\n    private Iterator<Server.ServerResponse> queryPinot(PinotSplit split)\n    {\n        String sql = split.getSegmentPinotQuery().orElseThrow(() -> new PinotException(PINOT_INVALID_SEGMENT_QUERY_GENERATED, Optional.empty(), \"Expected the segment split to contain the pinot query\"));\n        String grpcHost = split.getGrpcHost().orElseThrow(() -> new PinotException(PINOT_INVALID_SEGMENT_QUERY_GENERATED, Optional.empty(), \"Expected the segment split to contain the grpc host\"));\n        int grpcPort = split.getGrpcPort().orElseThrow(() -> new PinotException(PINOT_INVALID_SEGMENT_QUERY_GENERATED, Optional.empty(), \"Expected the segment split to contain the grpc port\"));\n        if (grpcPort <= 0) {\n            throw new PinotException(\n                PINOT_INVALID_SEGMENT_QUERY_GENERATED,\n                Optional.empty(),\n                \"Expected the grpc port > 0 always\");\n        }\n        PinotProxyGrpcRequestBuilder grpcRequestBuilder = new PinotProxyGrpcRequestBuilder()\n                .setSegments(split.getSegments())\n                .setEnableStreaming(true)\n                .setBrokerId(\"presto-coordinator-grpc\")\n                .addExtraMetadata(pinotConfig.getExtraGrpcMetadata())\n                .setSql(sql);\n        if (pinotConfig.isUseProxy()) {\n            grpcRequestBuilder.setHostName(grpcHost).setPort(grpcPort);\n            return pinotStreamingQueryClient.submit(\n                pinotConfig.getGrpcHost(),\n                pinotConfig.getGrpcPort(),\n                grpcRequestBuilder);\n        }\n        return pinotStreamingQueryClient.submit(grpcHost, grpcPort, grpcRequestBuilder);","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/PinotSegmentPageSource.java#L231-L267","documentation":"The Pinot split handed to the segment page source was expected to carry a generated segment-level PQL/SQL query (plus gRPC host/port), but the Optional was empty. This indicates the split was not built by the normal PinotSplitter path or was built before query generation completed.","triggerScenarios":"queryPinot calls split.getSegmentPinotQuery().orElseThrow(...) (and similarly getGrpcHost/getGrpcPort); a split missing these fields, a grpcPort <= 0, or a split created by a different/older connector version triggers it.","commonSituations":"Stale splits cached across a connector upgrade; custom or hand-rolled split creation; segment splits generated for leaf vs intermediate scheduling mismatch; configuration where gRPC is disabled on brokers so host/port are never populated.","solutions":["Regenerate the query plan / clear cached splits so a fresh PinotSplit with the segment query is produced","Verify broker gRPC service is enabled and PinotSplit generation records grpcHost/grpcPort","Ensure all nodes run the same connector version so split serialization matches","Check that the query is not being pushed down through a code path that bypasses segment query generation"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// validate split before consuming\nif (!split.getSegmentPinotQuery().isPresent()) throw new IllegalStateException(\"Split missing segment pinot query\");\nif (!split.getGrpcHost().isPresent() || !split.getGrpcPort().isPresent()) throw new IllegalStateException(\"Split missing grpc host/port\");\nif (split.getGrpcPort().get() <= 0) throw new IllegalStateException(\"Invalid grpc port\");","typeGuard":null,"tryCatchPattern":"try {\n  page = source.getNextPage();\n} catch (PinotException e) {\n  if (PinotErrorCode.PINOT_INVALID_SEGMENT_QUERY_GENERATED.toErrorCodeObject().equals(e.getErrorCode())) {\n    // fall back: re-plan the query instead of retrying the stale split\n    replanAndExecute(query);\n  } else throw e;\n}","preventionTips":["Clear cached split assignments after connector upgrades","Enable broker gRPC service and verify grpc port config","Run uniform connector versions on all coordinator/worker nodes","Avoid custom split-generation code paths"],"tags":["pinot","split-generation","grpc-config"],"backgroundTag":"invalid-split-generated","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"}