{"record":{"id":"54e88638e20478ee","repo":"apache/beam","slug":"encountered-an-unexpected-node-type-s","errorCode":null,"errorMessage":"Encountered an unexpected node type: %s","messagePattern":"Encountered an unexpected node type: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/bigquery/BigQueryFilter.java","lineNumber":146,"sourceCode":"      } else {\n        for (RexNode operand : compositeNode.getOperands()) {\n          // All operands must be supported for a parent node to be supported.\n          Pair<Boolean, Integer> childSupported = isSupported(operand);\n          // BigQuery supports complex combinations of both conjunctions (AND) and disjunctions\n          // (OR).\n          if (!node.getKind().belongsTo(ImmutableSet.of(AND, OR))) {\n            numberOfInputRefs += childSupported.getRight();\n          }\n          // Predicate functions, where more than one field is involved are unsupported.\n          isSupported = numberOfInputRefs < 2 && childSupported.getLeft();\n        }\n      }\n    } else if (node instanceof RexInputRef) {\n      numberOfInputRefs = 1;\n    } else if (node instanceof RexLiteral) {\n      // RexLiterals are expected, but no action is needed.\n    } else {\n      throw new UnsupportedOperationException(\n          \"Encountered an unexpected node type: \" + node.getClass().getSimpleName());\n    }\n\n    return Pair.of(isSupported, numberOfInputRefs);\n  }\n}\n","sourceCodeStart":128,"sourceCodeEnd":153,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/bigquery/BigQueryFilter.java#L128-L153","documentation":"BigQueryFilter.isSupported walks a RexNode tree to decide whether a predicate can be pushed to BigQuery, and only recognizes RexCall, RexInputRef, and RexLiteral nodes. Encountering any other RexNode subclass (e.g. RexFieldAccess, RexCorrelVariable, RexSubQuery) throws UnsupportedOperationException.","triggerScenarios":"Attempting BigQuery filter pushdown on a predicate containing node types outside the supported set — such as subqueries, correlated variables, or dynamic-parameter nodes inside the WHERE clause being analyzed by isSupported/childSupported.","commonSituations":"Queries with IN-subqueries, correlated EXISTS, or CASE expressions in filters reaching the pushdown path; optimizer output containing RexFieldAccess after rewrites.","solutions":["Rewrite the query to avoid unsupported constructs (subqueries, CASE) in filterable WHERE clauses","Decorrelate/flatten the query (Calcite decorrelation rules) before pushdown","Extend isSupported in BigQueryFilter to classify the additional node type"],"exampleFix":"// before\nSELECT * FROM t WHERE x IN (SELECT y FROM u)\n// after\nSELECT * FROM t JOIN u ON t.x = u.y","handlingStrategy":"validation","validationCode":"// pre-check node kinds before pushdown\nboolean supported = predicate.stream()\n    .allMatch(n -> n instanceof RexCall || n instanceof RexInputRef || n instanceof RexLiteral);","typeGuard":"boolean isPushdownSafe(RexNode n) {\n  return n instanceof RexCall || n instanceof RexInputRef || n instanceof RexLiteral;\n}","tryCatchPattern":"try {\n  filter.isSupported(node);\n} catch (UnsupportedOperationException e) {\n  if (e.getMessage().startsWith(\"Encountered an unexpected node type\")) { /* keep predicate local, don't push */ }\n  throw e;\n}","preventionTips":["Avoid subqueries and correlated variables in predicates meant for BigQuery pushdown","Decorrelate queries before pushdown analysis","Extend the supported-node list deliberately when new RexNode types appear"],"tags":["beam-sql","bigquery","predicate-pushdown","unsupported-node"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}