prestodb/presto · error · IllegalArgumentException
expecting SpecialFormExpression(DEREFERENCE) with constants
Error message
expecting SpecialFormExpression(DEREFERENCE) with constants for indices, but got:
What it means
Internal shape check while flattening DEREFERENCE chains in createNestedColumn: an array/struct index within the dereference chain did not optimize to a ConstantExpression holding a Number. The rule only pushes down constant indices; anything else violates the invariant — planner bug or unexpected expression form.
Source
Thrown at presto-parquet/src/main/java/com/facebook/presto/parquet/rule/ParquetDereferencePushDown.java:202
ExpressionOptimizer.Level.OPTIMIZED,
session);
if (indexExpression instanceof ConstantExpression) {
Object index = ((ConstantExpression) indexExpression).getValue();
if (index instanceof Number) {
Optional<String> fieldName = baseType.getFields().get(((Number) index).intValue()).getName();
if (fieldName.isPresent()) {
elements.add(new Subfield.NestedField(fieldName.get()));
currentRowExpression = base;
continue;
}
}
}
}
break;
}
throw new IllegalArgumentException("expecting SpecialFormExpression(DEREFERENCE) with constants for indices, but got: " + currentRowExpression);
}
/**
* Visitor to extract all dereference expressions and variable references.
* <p>
* If a dereference expression contains dereference expression, inner dereference expression are not returned
* * sub(deref(deref(x, 1), 2)) --> deref(deref(x,1), 2)
* Variable expressions returned are the ones not referenced by the dereference expressions
* * sub(x + 1) --> x
* * sub(deref(x, 1)) -> deref(x,1)
*/
private static class ExtractDereferenceAndVariables
extends DefaultRowExpressionTraversalVisitor<Set<RowExpression>>
{
private final ConnectorSession connectorSession;
private final ExpressionOptimizer expressionOptimizer;
public ExtractDereferenceAndVariables(ConnectorSession connectorSession, ExpressionOptimizer expressionOptimizer)View on GitHub (pinned to 55bb57d202)
Solutions
- Report the query/plan as a Presto planner bug
- Disable the parquet dereference pushdown rule as a workaround
- Ensure indices in nested accesses are literal constants in the query
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at presto-parquet/src/main/java/com/facebook/presto/parquet/rule/ParquetDereferencePushDown.java:202 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/e64227255b759ca2.
Report an issue: GitHub.