{"record":{"id":"e64227255b759ca2","repo":"prestodb/presto","slug":"expecting-specialformexpression-dereference-with","errorCode":null,"errorMessage":"expecting SpecialFormExpression(DEREFERENCE) with constants for indices, but got: ","messagePattern":"expecting SpecialFormExpression\\(DEREFERENCE\\) with constants for indices, but got: ","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"presto-parquet/src/main/java/com/facebook/presto/parquet/rule/ParquetDereferencePushDown.java","lineNumber":202,"sourceCode":"                        ExpressionOptimizer.Level.OPTIMIZED,\n                        session);\n\n                if (indexExpression instanceof ConstantExpression) {\n                    Object index = ((ConstantExpression) indexExpression).getValue();\n                    if (index instanceof Number) {\n                        Optional<String> fieldName = baseType.getFields().get(((Number) index).intValue()).getName();\n                        if (fieldName.isPresent()) {\n                            elements.add(new Subfield.NestedField(fieldName.get()));\n                            currentRowExpression = base;\n                            continue;\n                        }\n                    }\n                }\n            }\n            break;\n        }\n\n        throw new IllegalArgumentException(\"expecting SpecialFormExpression(DEREFERENCE) with constants for indices, but got: \" + currentRowExpression);\n    }\n\n    /**\n     * Visitor to extract all dereference expressions and variable references.\n     * <p>\n     * If a dereference expression contains dereference expression, inner dereference expression are not returned\n     * * sub(deref(deref(x, 1), 2)) --> deref(deref(x,1), 2)\n     * Variable expressions returned are the ones not referenced by the dereference expressions\n     * * sub(x + 1) --> x\n     * * sub(deref(x, 1)) -> deref(x,1)\n     */\n    private static class ExtractDereferenceAndVariables\n            extends DefaultRowExpressionTraversalVisitor<Set<RowExpression>>\n    {\n        private final ConnectorSession connectorSession;\n        private final ExpressionOptimizer expressionOptimizer;\n\n        public ExtractDereferenceAndVariables(ConnectorSession connectorSession, ExpressionOptimizer expressionOptimizer)","sourceCodeStart":184,"sourceCodeEnd":220,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-parquet/src/main/java/com/facebook/presto/parquet/rule/ParquetDereferencePushDown.java#L184-L220","documentation":"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.","triggerScenarios":"Thrown at presto-parquet/src/main/java/com/facebook/presto/parquet/rule/ParquetDereferencePushDown.java:202 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}