{"record":{"id":"f6070394d11f96a1","repo":"apache/beam","slug":"cannot-create-a-filter-for-an-unsupported-node-node","errorCode":null,"errorMessage":"Cannot create a filter for an unsupported node: ${node}","messagePattern":"Cannot create a filter for an unsupported node: (.+?)","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":257,"sourceCode":"            case NOT_EQUALS:\n              return Filters.not(Filters.eq(inputFieldName, literal));\n            case LESS_THAN:\n              return Filters.lt(inputFieldName, literal);\n            case GREATER_THAN:\n              return Filters.gt(inputFieldName, literal);\n            case GREATER_THAN_OR_EQUAL:\n              return Filters.gte(inputFieldName, literal);\n            case LESS_THAN_OR_EQUAL:\n              return Filters.lte(inputFieldName, literal);\n            default:\n              // Encountered an unexpected node kind, RuntimeException below.\n              break;\n          }\n        } else if (node.getKind().equals(SqlKind.NOT)) {\n          // Ex: `where not boolean_field`\n          return Filters.not(translateRexNodeToBson(inputRef));\n        } else {\n          throw new RuntimeException(\n              \"Cannot create a filter for an unsupported node: \" + node.toString());\n        }\n      } else { // Operation is a conjunction/disjunction.\n        switch (node.getKind()) {\n          case AND:\n            // Recursively construct filter for each operand of conjunction.\n            return Filters.and(\n                compositeNode.getOperands().stream()\n                    .map(this::translateRexNodeToBson)\n                    .collect(Collectors.toList()));\n          case OR:\n            // 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.","sourceCodeStart":239,"sourceCodeEnd":275,"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#L239-L275","documentation":"In MongoDbTable.translateRexNodeToBson, when a RexCall's operands are translated and the operation is neither a recognized comparison nor a NOT of a boolean input ref, the code throws a RuntimeException naming the unsupported node. This indicates a Calcite predicate shape the BSON translator has no mapping for.","triggerScenarios":"Pushing down a WHERE predicate using an operator the translator does not implement (e.g. LIKE, complex expressions such as 'a = b' with two non-literal operands, or other SqlKinds not handled in the switch) when the MongoDb provider attempts predicate push-down.","commonSituations":"Queries with string pattern matching (LIKE), arithmetic in filters, or non-boolean operands inside OR/AND clauses against a MongoDb external table.","solutions":["Rewrite the query so the unsupported predicate is computed after the scan (Beam computes it client-side) — keep only supported (=, <>, <, >, <=, >=, AND, OR, NOT) filters pushable to MongoDB.","Simplify the filter into supported comparisons over columns against literals.","If this is a valid common case, file/patch the provider to translate the additional SqlKind in translateRexNodeToBson."],"exampleFix":"// before\nSELECT * FROM t WHERE name LIKE 'a%'\n// after\nSELECT * FROM t WHERE name >= 'a' AND name < 'b'","handlingStrategy":"validation","validationCode":"Set<SqlKind> supported = EnumSet.of(SqlKind.EQUALS, SqlKind.NOT_EQUALS, SqlKind.LESS_THAN, SqlKind.LESS_THAN_OR_EQUAL, SqlKind.GREATER_THAN, SqlKind.GREATER_THAN_OR_EQUAL, SqlKind.AND, SqlKind.OR, SqlKind.NOT);\nboolean pushable = node.getKind() != null && supported.contains(node.getKind());","typeGuard":null,"tryCatchPattern":"try { filter = MongoDbFilter.create(cnf); } catch (RuntimeException e) { filter = null; /* evaluate client-side */ }","preventionTips":["Restrict WHERE clauses to simple comparisons and AND/OR","Avoid LIKE and arithmetic in filters on MongoDb tables","Test push-down of all filters used in production queries"],"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-14T11:17:12.474Z"}