prestodb/presto · error · PinotException

PINOT_INVALID_SEGMENT_QUERY_GENERATED

PINOT_INVALID_SEGMENT_QUERY_GENERATED

Error message

Expected the segment split to contain the pinot query

What it means

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.

Source

Thrown at presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/PinotSegmentPageSource.java:249

            }
            Page page = fillNextPage();
            completedPositions += currentDataTable.getDataTable().getNumberOfRows();
            return page;
        }
        finally {
            if (byteBuffer != null) {
                ((Buffer) byteBuffer).clear();
            }
        }
    }

    private Iterator<Server.ServerResponse> queryPinot(PinotSplit split)
    {
        String sql = split.getSegmentPinotQuery().orElseThrow(() -> new PinotException(PINOT_INVALID_SEGMENT_QUERY_GENERATED, Optional.empty(), "Expected the segment split to contain the pinot query"));
        String grpcHost = split.getGrpcHost().orElseThrow(() -> new PinotException(PINOT_INVALID_SEGMENT_QUERY_GENERATED, Optional.empty(), "Expected the segment split to contain the grpc host"));
        int grpcPort = split.getGrpcPort().orElseThrow(() -> new PinotException(PINOT_INVALID_SEGMENT_QUERY_GENERATED, Optional.empty(), "Expected the segment split to contain the grpc port"));
        if (grpcPort <= 0) {
            throw new PinotException(
                PINOT_INVALID_SEGMENT_QUERY_GENERATED,
                Optional.empty(),
                "Expected the grpc port > 0 always");
        }
        PinotProxyGrpcRequestBuilder grpcRequestBuilder = new PinotProxyGrpcRequestBuilder()
                .setSegments(split.getSegments())
                .setEnableStreaming(true)
                .setBrokerId("presto-coordinator-grpc")
                .addExtraMetadata(pinotConfig.getExtraGrpcMetadata())
                .setSql(sql);
        if (pinotConfig.isUseProxy()) {
            grpcRequestBuilder.setHostName(grpcHost).setPort(grpcPort);
            return pinotStreamingQueryClient.submit(
                pinotConfig.getGrpcHost(),
                pinotConfig.getGrpcPort(),
                grpcRequestBuilder);
        }
        return pinotStreamingQueryClient.submit(grpcHost, grpcPort, grpcRequestBuilder);

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Regenerate the query plan / clear cached splits so a fresh PinotSplit with the segment query is produced
  2. Verify broker gRPC service is enabled and PinotSplit generation records grpcHost/grpcPort
  3. Ensure all nodes run the same connector version so split serialization matches
  4. Check that the query is not being pushed down through a code path that bypasses segment query generation
Defensive patterns

Strategy: validation

Validate before calling

// validate split before consuming
if (!split.getSegmentPinotQuery().isPresent()) throw new IllegalStateException("Split missing segment pinot query");
if (!split.getGrpcHost().isPresent() || !split.getGrpcPort().isPresent()) throw new IllegalStateException("Split missing grpc host/port");
if (split.getGrpcPort().get() <= 0) throw new IllegalStateException("Invalid grpc port");

Try / catch

try {
  page = source.getNextPage();
} catch (PinotException e) {
  if (PinotErrorCode.PINOT_INVALID_SEGMENT_QUERY_GENERATED.toErrorCodeObject().equals(e.getErrorCode())) {
    // fall back: re-plan the query instead of retrying the stale split
    replanAndExecute(query);
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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