prestodb/presto · error · IllegalStateException
Group By column (%s) definition not found in input selection
Error message
Group By column (%s) definition not found in input selections: %s
What it means
While building the column-index mapping from Pinot's output order to Presto's expected order, getIndicesMappingFromPinotSchemaToPrestoSchema looks up each group-by column in the accumulated selections. A missing definition means the group-by variable was never registered as a selection, indicating an internal inconsistency in the generated plan/context; it is thrown as IllegalStateException (no specific error code).
Source
Thrown at presto-pinot-toolkit/src/main/java/com/facebook/presto/pinot/query/PinotQueryGeneratorContext.java:411
return new PinotQueryGenerator.GeneratedPinotQuery(tableName, query, indices, filter.isPresent(), forBroker);
}
private String updateSelection(String definition, ConnectorSession session)
{
final String overrideDistinctCountFunction = PinotSessionProperties.getOverrideDistinctCountFunction(session);
if (!PINOT_DISTINCT_COUNT_FUNCTION_NAME.equalsIgnoreCase(overrideDistinctCountFunction)) {
return definition.replaceFirst(PINOT_DISTINCT_COUNT_FUNCTION_NAME.toUpperCase() + "\\(", overrideDistinctCountFunction.toUpperCase() + "\\(");
}
return definition;
}
private List<Integer> getIndicesMappingFromPinotSchemaToPrestoSchema(String query, Map<VariableReferenceExpression, PinotColumnHandle> assignments)
{
LinkedHashMap<VariableReferenceExpression, Selection> expressionsInPinotOrder = new LinkedHashMap<>();
for (VariableReferenceExpression groupByColumn : groupByColumns) {
Selection groupByColumnDefinition = selections.get(groupByColumn);
if (groupByColumnDefinition == null) {
throw new IllegalStateException(format(
"Group By column (%s) definition not found in input selections: %s",
groupByColumn,
Joiner.on(",").withKeyValueSeparator(":").join(selections)));
}
expressionsInPinotOrder.put(groupByColumn, groupByColumnDefinition);
}
for (VariableReferenceExpression outputColumn : outputs) {
Selection outputColumnDefinition = selections.get(outputColumn);
if (outputColumnDefinition == null) {
throw new IllegalStateException(format(
"Output column (%s) definition not found in input selections: %s",
outputColumn,
Joiner.on(",").withKeyValueSeparator(":").join(selections)));
}
expressionsInPinotOrder.put(outputColumn, outputColumnDefinition);
}
checkSupported(View on GitHub (pinned to 55bb57d202)
Solutions
- Rewrite the query to group by a plain column reference from the table instead of a derived/renamed expression alias.
- If derived grouping is needed, materialize it via a supported project pattern the connector recognizes, or fall back to Presto-side grouping.
- Capture the query and the selections listed in the message and file a bug against the Pinot connector; this indicates a generator bug.
Example fix
// before SELECT user_region AS region, count(*) FROM events GROUP BY region; // alias not in selections // after SELECT user_region, count(*) FROM events GROUP BY user_region;
Defensive patterns
Strategy: try-catch
Validate before calling
// Prefer grouping by plain column references, not aliases of projections
// Verify each GROUP BY term matches a base column name of the table
boolean plain = groupByTerms.stream().allMatch(tableColumns::contains);
if (!plain) { disablePushdown(); } Try / catch
try {
runQuery(sql);
} catch (IllegalStateException e) {
if (e.getMessage() != null && e.getMessage().startsWith("Group By column")) {
runQueryWithoutPushdown(sql); // report bug + fallback
} else {
throw e;
}
} Prevention
- Group by base table columns, not derived aliases.
- Avoid relying on GROUP BY ordinal/alias of computed expressions on Pinot tables.
- Report occurrences — this indicates a connector generator bug.
When it happens
Trigger: A GROUP BY column variable is absent from the context's selections map, typically after a chain of project/aggregation nodes where the group-by column was renamed or derived but not added to selections before indices() is called.
Common situations: Queries grouping by an expression alias computed in a projection; connector/planner version mismatches where variable naming changed; internal bug reports rather than user-level query mistakes.
Related errors
- Output column (%s) definition not found in input selections:
- PINOT_UNSUPPORTED_EXPRESSION
- PINOT_UNSUPPORTED_EXPRESSION
- PINOT_UNSUPPORTED_EXPRESSION
- PINOT_UNSUPPORTED_EXPRESSION
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/de3006f714dabe25.
Report an issue: GitHub.