{"record":{"id":"9e7e1283e867b8a8","repo":"apache/beam","slug":"encountered-an-unexpected-node-type-node-getclass","errorCode":null,"errorMessage":"Encountered an unexpected node type: ${node.getClass().getSimpleName()}","messagePattern":"Encountered an unexpected node type: (.+?)","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":492,"sourceCode":"          // Ex: `field1 == field2` is not supported.\n          // TODO: Can be supported via Filters#where.\n          if (fields == 1) {\n            return true;\n          }\n        } else if (node.getKind().equals(AND) || node.getKind().equals(OR)) {\n          // Nested ANDs and ORs are supported as long as all operands are supported.\n          for (RexNode operand : compositeNode.getOperands()) {\n            if (!isSupported(operand)) {\n              return false;\n            }\n          }\n          return true;\n        }\n      } else if (node instanceof RexInputRef) {\n        // When field is a boolean.\n        return true;\n      } else {\n        throw new RuntimeException(\n            \"Encountered an unexpected node type: \" + node.getClass().getSimpleName());\n      }\n\n      return false;\n    }\n  }\n}\n","sourceCodeStart":474,"sourceCodeEnd":500,"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#L474-L500","documentation":"MongoDbFilter.isSupported recognizes only RexCall nodes it can translate and bare RexInputRef nodes (boolean fields). Any other RexNode subclass reaching the else branch triggers this RuntimeException with the node's simple class name, signaling the filter-support checker encountered an unhandled node type.","triggerScenarios":"Evaluating predicate support for a CNF list containing RexLiteral, RexFieldAccess, RexCorrelVariable, or other non-call/non-input-ref nodes — e.g. during create() when deciding which predicates are pushable to MongoDB.","commonSituations":"Optimizer-rewritten plans injecting literals or field accesses; programmatic predicate construction bypassing normal SQL parsing.","solutions":["Restrict pushed predicates to comparison RexCalls and boolean RexInputRefs.","Pre-filter the CNF list, skipping nodes that are not RexCall or RexInputRef so they are computed post-scan.","Extend isSupported in the provider if the node type should be pushable."],"exampleFix":"// before\nfilterCreate(cnf) // cnf contains a RexLiteral\n// after\ncnf.removeIf(n -> !(n instanceof RexCall || n instanceof RexInputRef));\nfilterCreate(cnf)","handlingStrategy":"type-guard","validationCode":"if (!(node instanceof RexCall) && !(node instanceof RexInputRef)) {\n  throw new IllegalArgumentException(\"Unsupported node in CNF: \" + node.getClass());\n}","typeGuard":"boolean isSupportedNode(RexNode n) { return n instanceof RexCall || n instanceof RexInputRef; }","tryCatchPattern":"try { support = MongoDbFilter.isSupported(node); } catch (RuntimeException e) { support = false; }","preventionTips":["Pre-filter CNF lists to RexCall/RexInputRef","Handle literals locally rather than pushing","Add tests with optimizer-rewritten plans"],"tags":["java","apache-beam","mongodb","sql","predicate-pushdown"],"backgroundTag":"unsupported-operation","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"}