apache/beam · error · UnsupportedOperationException

Encountered an unexpected node type

Error message

Encountered an unexpected node type: %s

What it means

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.

Solutions

  1. Rewrite the query to avoid unsupported constructs (subqueries, CASE) in filterable WHERE clauses
  2. Decorrelate/flatten the query (Calcite decorrelation rules) before pushdown
  3. Extend isSupported in BigQueryFilter to classify the additional node type

Example fix

// before
SELECT * FROM t WHERE x IN (SELECT y FROM u)
// after
SELECT * FROM t JOIN u ON t.x = u.y
Defensive patterns

Strategy: validation

Validate before calling

// pre-check node kinds before pushdown
boolean supported = predicate.stream()
    .allMatch(n -> n instanceof RexCall || n instanceof RexInputRef || n instanceof RexLiteral);

Type guard

boolean isPushdownSafe(RexNode n) {
  return n instanceof RexCall || n instanceof RexInputRef || n instanceof RexLiteral;
}

Try / catch

try {
  filter.isSupported(node);
} catch (UnsupportedOperationException e) {
  if (e.getMessage().startsWith("Encountered an unexpected node type")) { /* keep predicate local, don't push */ }
  throw e;
}

Prevention

When it happens

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

Common situations: Queries with IN-subqueries, correlated EXISTS, or CASE expressions in filters reaching the pushdown path; optimizer output containing RexFieldAccess after rewrites.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/54e88638e20478ee. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/bigquery/BigQueryFilter.java:146

      } else {
        for (RexNode operand : compositeNode.getOperands()) {
          // All operands must be supported for a parent node to be supported.
          Pair<Boolean, Integer> childSupported = isSupported(operand);
          // BigQuery supports complex combinations of both conjunctions (AND) and disjunctions
          // (OR).
          if (!node.getKind().belongsTo(ImmutableSet.of(AND, OR))) {
            numberOfInputRefs += childSupported.getRight();
          }
          // Predicate functions, where more than one field is involved are unsupported.
          isSupported = numberOfInputRefs < 2 && childSupported.getLeft();
        }
      }
    } else if (node instanceof RexInputRef) {
      numberOfInputRefs = 1;
    } else if (node instanceof RexLiteral) {
      // RexLiterals are expected, but no action is needed.
    } else {
      throw new UnsupportedOperationException(
          "Encountered an unexpected node type: " + node.getClass().getSimpleName());
    }

    return Pair.of(isSupported, numberOfInputRefs);
  }
}

View on GitHub (pinned to 12126d8942)