{"record":{"id":"b040c17004f78401","repo":"prestodb/presto","slug":"unsupported-join-criteria-s","errorCode":null,"errorMessage":"unsupported join criteria: %s","messagePattern":"unsupported join criteria: (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/StatementAnalyzer.java","lineNumber":3551,"sourceCode":"                    analysis.addCoercion(expression, BOOLEAN, false);\n                }\n\n                if (expression instanceof LogicalBinaryExpression) {\n                    if (((LogicalBinaryExpression) expression).getOperator() == LogicalBinaryExpression.Operator.OR) {\n                        String warningMessage = createWarningMessage(expression, \"JOIN conditions with an OR can cause performance issues as it may lead to a cross join with filter\");\n                        warningCollector.add(new PrestoWarning(PERFORMANCE_WARNING, warningMessage));\n                    }\n                }\n\n                verifyJoinOnConditionReferencesRelatedFields(left, right, expression, node.getRight());\n                verifyNoAggregateWindowOrGroupingFunctions(analysis.getFunctionHandles(), functionAndTypeResolver, expression, \"JOIN clause\");\n\n                analysis.recordSubqueries(node, expressionAnalysis);\n                analysis.setJoinCriteria(node, expression);\n                collectIndirectSources(expression, TransformationSubtype.JOIN);\n            }\n            else {\n                throw new UnsupportedOperationException(\"unsupported join criteria: \" + criteria.getClass().getName());\n            }\n\n            return output;\n        }\n\n        private void verifyJoinOnConditionReferencesRelatedFields(Scope leftScope, Scope rightScope, Expression expression, Relation rightRelation)\n        {\n            if (!isJoinOnConditionReferencesRelatedFields(expression, leftScope, rightScope)) {\n                Optional<String> tableName = tryGetTableName(rightRelation);\n                String warningMessage = tableName.isPresent() ?\n                        createWarningMessage(\n                                expression,\n                                format(\n                                        \"JOIN ON condition(s) do not reference the joined table '%s' and other tables in the same \" +\n                                                \"expression that can cause performance issues as it may lead to a cross join with filter\",\n                                        tableName.get())) :\n                        createWarningMessage(\n                                expression,","sourceCodeStart":3533,"sourceCodeEnd":3569,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/StatementAnalyzer.java#L3533-L3569","documentation":"After handling JoinOn, JoinUsing, and (rejected earlier) NaturalJoin criteria, any other JoinCriteria implementation reaches an else branch that throws a plain UnsupportedOperationException naming the criteria class. This is an internal invariant violation rather than a SemanticException — the parser produced a criteria type the analyzer does not handle (e.g. a newly added criteria type without analyzer support).","triggerScenarios":"A Join node whose criteria is a JoinCriteria subclass not covered by the analyzer's instanceof chain (new grammar feature or custom criteria type); usually surfaced only after parser extensions or version mismatches between parser and analyzer.","commonSituations":"Running a patched/extended Presto build where new join syntax was added to the parser but not the analyzer; bugs during Presto upgrades where grammar and analyzer are out of sync.","solutions":["Check the Presto version for a known bug matching the criteria class in the message and upgrade/downgrade accordingly","Rewrite the join using standard ON or USING syntax","File a bug with the query and criteria class name reported in the message"],"exampleFix":"-- before (unhandled criteria form)\nSELECT * FROM a JOIN b ON <unsupported-criteria>\n-- after\nSELECT * FROM a JOIN b ON a.id = b.id","handlingStrategy":"fallback","validationCode":"// Use only JOIN ... ON / JOIN ... USING forms; reject anything else\nif (!Pattern.compile(\"\\\\bJOIN\\\\b(?!\").matcher(sql).find()) { /* gate to standard joins */ }","typeGuard":null,"tryCatchPattern":"try { stmt.execute(sql); } catch (SQLException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"unsupported join criteria\")) {\n        throw new QueryBuildException(\"Analyzer cannot handle this join criteria class: \" + e.getMessage(), e);\n    } throw e;\n}","preventionTips":["Stick to ON/USING join syntax supported by stock Presto","Avoid patched parser extensions not mirrored in the analyzer","Keep parser and analyzer versions consistent (no mixed jars) when upgrading"],"tags":["sql","join","internal-error"],"backgroundTag":"unsupported-join-criteria","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}