apache/beam · error · RuntimeException

Predicate node '${node.getClass().getSimpleName()}' should b

Error message

Predicate node '${node.getClass().getSimpleName()}' should be a boolean expression, but was: ${node.getType().getSqlTypeName()}

What it means

MongoDbFilter.create validates each node in the CNF predicate list: every RexNode must have SQL type BOOLEAN. A non-boolean node (e.g. an INTEGER column reference standing alone) fails this check and throws a RuntimeException naming the node class and its SQL type name.

Source

Thrown at sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/mongodb/MongoDbTable.java:430

      String supStr =
          "supported{"
              + supported.stream().map(RexNode::toString).collect(Collectors.joining())
              + "}";
      String unsupStr =
          "unsupported{"
              + unsupported.stream().map(RexNode::toString).collect(Collectors.joining())
              + "}";

      return "[" + supStr + ", " + unsupStr + "]";
    }

    public static MongoDbFilter create(List<RexNode> predicateCNF) {
      ImmutableList.Builder<RexNode> supported = ImmutableList.builder();
      ImmutableList.Builder<RexNode> unsupported = ImmutableList.builder();

      for (RexNode node : predicateCNF) {
        if (!node.getType().getSqlTypeName().equals(SqlTypeName.BOOLEAN)) {
          throw new RuntimeException(
              "Predicate node '"
                  + node.getClass().getSimpleName()
                  + "' should be a boolean expression, but was: "
                  + node.getType().getSqlTypeName());
        }

        if (isSupported(node)) {
          supported.add(node);
        } else {
          unsupported.add(node);
        }
      }

      return new MongoDbFilter(supported.build(), unsupported.build());
    }

    /**
     * Check whether a {@code RexNode} is supported. To keep things simple:<br>

View on GitHub (pinned to 12126d8942)

Solutions

  1. Make the predicate a boolean expression, e.g. 'WHERE int_field = 1' instead of 'WHERE int_field'.
  2. Before calling create()/isSupported, check each RexNode's type is SqlTypeName.BOOLEAN and drop or rewrite others.
  3. Inspect the generated plan if the optimizer introduced the non-boolean node.

Example fix

// before
SELECT * FROM t WHERE int_field
// after
SELECT * FROM t WHERE int_field = 1
Defensive patterns

Strategy: validation

Validate before calling

for (RexNode node : cnf) {
  if (!node.getType().getSqlTypeName().equals(SqlTypeName.BOOLEAN)) {
    throw new IllegalArgumentException("Non-boolean predicate: " + node);
  }
}

Try / catch

try { MongoDbFilter.create(predicateCNF); } catch (RuntimeException e) { /* treat as unsupported filter */ }

Prevention

When it happens

Trigger: A WHERE clause that includes a bare non-boolean expression as a predicate, e.g. 'SELECT * FROM t WHERE int_field' or a predicate list containing a column reference of type VARCHAR/INTEGER passed to create().

Common situations: Users accidentally writing C-style truthiness conditions in SQL; programmatically assembled CNF lists containing a raw input ref of non-boolean type.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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