apache/beam · error · RuntimeException

Was expecting a RexCall or a boolean RexInputRef, but receiv

Error message

Was expecting a RexCall or a boolean RexInputRef, but received: ${node.getClass().getSimpleName()}

What it means

Terminal validation in MongoDbTable.translateRexNodeToBson: the method only handles RexCall nodes and boolean RexInputRef nodes. Any other RexNode class (or a non-boolean RexInputRef) reaching the end of the method triggers this RuntimeException with the node's simple class name.

Source

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

            // Recursively construct filter for each operand of disjunction.
            return Filters.or(
                compositeNode.getOperands().stream()
                    .map(this::translateRexNodeToBson)
                    .collect(Collectors.toList()));
          default:
            // Encountered an unexpected node kind, RuntimeException below.
            break;
        }
      }
      throw new RuntimeException(
          "Encountered an unexpected node kind: " + node.getKind().toString());
    } else if (node instanceof RexInputRef
        && node.getType().getSqlTypeName().equals(SqlTypeName.BOOLEAN)) {
      // Boolean field, must be true. Ex: `select * from table where bool_field`
      return Filters.eq(fieldIdToName.apply(((RexInputRef) node).getIndex()), true);
    }

    throw new RuntimeException(
        "Was expecting a RexCall or a boolean RexInputRef, but received: "
            + node.getClass().getSimpleName());
  }

  private Object convertToExpectedType(RexInputRef inputRef, RexLiteral literal) {
    FieldType beamFieldType = getSchema().getField(inputRef.getIndex()).getType();

    return literal.getValueAs(
        FieldTypeDescriptors.javaTypeForFieldType(beamFieldType).getRawType());
  }

  private Object convertToExpectedType(RexInputRef inputRef, List<RexLiteral> literals) {
    return literals.stream()
        .map(l -> convertToExpectedType(inputRef, l))
        .collect(Collectors.toList());
  }

  @Override

View on GitHub (pinned to 12126d8942)

Solutions

  1. Ensure every pushed predicate is a boolean expression: a RexCall comparison or a bare boolean field reference.
  2. Filter out non-boolean/non-call nodes before push-down (let Beam evaluate them locally).
  3. If extending the provider, add handling for the reported node class before the final throw.

Example fix

// before
predicates.add(RexUtil.literal(true))
// after
predicates.add(call(eq(booleanColumn, trueLiteral)))
Defensive patterns

Strategy: type-guard

Validate before calling

boolean ok = (n instanceof RexCall) || (n instanceof RexInputRef && n.getType().getSqlTypeName().equals(SqlTypeName.BOOLEAN));
if (!ok) throw new IllegalArgumentException("Predicate not pushable: " + n.getClass().getSimpleName());

Type guard

boolean isPushableNode(RexNode n) { return n instanceof RexCall || (n instanceof RexInputRef && n.getType().getSqlTypeName() == SqlTypeName.BOOLEAN); }

Try / catch

try { translateRexNodeToBson(node); } catch (RuntimeException e) { /* do not push this predicate */ }

Prevention

When it happens

Trigger: Passing a RexLiteral, RexFieldAccess, or a non-boolean RexInputRef directly into the translator — e.g. the CNF input to MongoDbFilter.create contains a node that is neither a call nor a boolean field reference.

Common situations: Optimizer-produced plans containing literal nodes or field accesses inside pushed predicates; programmatic (non-SQL) construction of RexNode filters handed to the MongoDb provider.

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/c1f3a8a1d46b307f. Report an issue: GitHub.