{"record":{"id":"cb0207daf0482b0e","repo":"apache/beam","slug":"predicate-node-node-getclass-getsimplename-should-be-a","errorCode":null,"errorMessage":"Predicate node '${node.getClass().getSimpleName()}' should be a boolean expression, but was: ${node.getType().getSqlTypeName()}","messagePattern":"Predicate node '(.+?)' should be a boolean expression, but was: (.+?)","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":430,"sourceCode":"      String supStr =\n          \"supported{\"\n              + supported.stream().map(RexNode::toString).collect(Collectors.joining())\n              + \"}\";\n      String unsupStr =\n          \"unsupported{\"\n              + unsupported.stream().map(RexNode::toString).collect(Collectors.joining())\n              + \"}\";\n\n      return \"[\" + supStr + \", \" + unsupStr + \"]\";\n    }\n\n    public static MongoDbFilter create(List<RexNode> predicateCNF) {\n      ImmutableList.Builder<RexNode> supported = ImmutableList.builder();\n      ImmutableList.Builder<RexNode> unsupported = ImmutableList.builder();\n\n      for (RexNode node : predicateCNF) {\n        if (!node.getType().getSqlTypeName().equals(SqlTypeName.BOOLEAN)) {\n          throw new RuntimeException(\n              \"Predicate node '\"\n                  + node.getClass().getSimpleName()\n                  + \"' should be a boolean expression, but was: \"\n                  + node.getType().getSqlTypeName());\n        }\n\n        if (isSupported(node)) {\n          supported.add(node);\n        } else {\n          unsupported.add(node);\n        }\n      }\n\n      return new MongoDbFilter(supported.build(), unsupported.build());\n    }\n\n    /**\n     * Check whether a {@code RexNode} is supported. To keep things simple:<br>","sourceCodeStart":412,"sourceCodeEnd":448,"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#L412-L448","documentation":"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.","triggerScenarios":"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().","commonSituations":"Users accidentally writing C-style truthiness conditions in SQL; programmatically assembled CNF lists containing a raw input ref of non-boolean type.","solutions":["Make the predicate a boolean expression, e.g. 'WHERE int_field = 1' instead of 'WHERE int_field'.","Before calling create()/isSupported, check each RexNode's type is SqlTypeName.BOOLEAN and drop or rewrite others.","Inspect the generated plan if the optimizer introduced the non-boolean node."],"exampleFix":"// before\nSELECT * FROM t WHERE int_field\n// after\nSELECT * FROM t WHERE int_field = 1","handlingStrategy":"validation","validationCode":"for (RexNode node : cnf) {\n  if (!node.getType().getSqlTypeName().equals(SqlTypeName.BOOLEAN)) {\n    throw new IllegalArgumentException(\"Non-boolean predicate: \" + node);\n  }\n}","typeGuard":null,"tryCatchPattern":"try { MongoDbFilter.create(predicateCNF); } catch (RuntimeException e) { /* treat as unsupported filter */ }","preventionTips":["Always write boolean predicates (col = 1, not just col)","Validate predicate types before push-down","Lint SQL queries for bare-column conditions"],"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"}