{"record":{"id":"c1f3a8a1d46b307f","repo":"apache/beam","slug":"was-expecting-a-rexcall-or-a-boolean-rexinputref-but","errorCode":null,"errorMessage":"Was expecting a RexCall or a boolean RexInputRef, but received: ${node.getClass().getSimpleName()}","messagePattern":"Was expecting a RexCall or a boolean RexInputRef, but received: (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/mongodb/MongoDbTable.java","lineNumber":287,"sourceCode":"            // Recursively construct filter for each operand of disjunction.\n            return Filters.or(\n                compositeNode.getOperands().stream()\n                    .map(this::translateRexNodeToBson)\n                    .collect(Collectors.toList()));\n          default:\n            // Encountered an unexpected node kind, RuntimeException below.\n            break;\n        }\n      }\n      throw new RuntimeException(\n          \"Encountered an unexpected node kind: \" + node.getKind().toString());\n    } else if (node instanceof RexInputRef\n        && node.getType().getSqlTypeName().equals(SqlTypeName.BOOLEAN)) {\n      // Boolean field, must be true. Ex: `select * from table where bool_field`\n      return Filters.eq(fieldIdToName.apply(((RexInputRef) node).getIndex()), true);\n    }\n\n    throw new RuntimeException(\n        \"Was expecting a RexCall or a boolean RexInputRef, but received: \"\n            + node.getClass().getSimpleName());\n  }\n\n  private Object convertToExpectedType(RexInputRef inputRef, RexLiteral literal) {\n    FieldType beamFieldType = getSchema().getField(inputRef.getIndex()).getType();\n\n    return literal.getValueAs(\n        FieldTypeDescriptors.javaTypeForFieldType(beamFieldType).getRawType());\n  }\n\n  private Object convertToExpectedType(RexInputRef inputRef, List<RexLiteral> literals) {\n    return literals.stream()\n        .map(l -> convertToExpectedType(inputRef, l))\n        .collect(Collectors.toList());\n  }\n\n  @Override","sourceCodeStart":269,"sourceCodeEnd":305,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/mongodb/MongoDbTable.java#L269-L305","documentation":"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.","triggerScenarios":"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.","commonSituations":"Optimizer-produced plans containing literal nodes or field accesses inside pushed predicates; programmatic (non-SQL) construction of RexNode filters handed to the MongoDb provider.","solutions":["Ensure every pushed predicate is a boolean expression: a RexCall comparison or a bare boolean field reference.","Filter out non-boolean/non-call nodes before push-down (let Beam evaluate them locally).","If extending the provider, add handling for the reported node class before the final throw."],"exampleFix":"// before\npredicates.add(RexUtil.literal(true))\n// after\npredicates.add(call(eq(booleanColumn, trueLiteral)))","handlingStrategy":"type-guard","validationCode":"boolean ok = (n instanceof RexCall) || (n instanceof RexInputRef && n.getType().getSqlTypeName().equals(SqlTypeName.BOOLEAN));\nif (!ok) throw new IllegalArgumentException(\"Predicate not pushable: \" + n.getClass().getSimpleName());","typeGuard":"boolean isPushableNode(RexNode n) { return n instanceof RexCall || (n instanceof RexInputRef && n.getType().getSqlTypeName() == SqlTypeName.BOOLEAN); }","tryCatchPattern":"try { translateRexNodeToBson(node); } catch (RuntimeException e) { /* do not push this predicate */ }","preventionTips":["Guard with instanceof RexCall before translating","Skip literals and non-boolean input refs","Cover translator with unit tests on plan shapes"],"tags":["java","apache-beam","mongodb","sql","predicate-pushdown"],"backgroundTag":"type-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}