{"record":{"id":"99f6b0c3067fcce5","repo":"prestodb/presto","slug":"missing-attribute-99f6b0","errorCode":"MISSING_ATTRIBUTE","errorMessage":"Column '%s' is missing from left side of join","messagePattern":"Column '(.+?)' is missing from left side of join","errorType":"error_code","errorClass":"SemanticException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/StatementAnalyzer.java","lineNumber":3958,"sourceCode":"\n        private Scope analyzeJoinUsing(Join node, List<Identifier> columns, Optional<Scope> scope, Scope left, Scope right)\n        {\n            List<Field> joinFields = new ArrayList<>();\n\n            List<Integer> leftJoinFields = new ArrayList<>();\n            List<Integer> rightJoinFields = new ArrayList<>();\n\n            Set<Identifier> seen = new HashSet<>();\n            for (Identifier column : columns) {\n                if (!seen.add(column)) {\n                    throw new SemanticException(DUPLICATE_COLUMN_NAME, column, \"Column '%s' appears multiple times in USING clause\", column.getValue());\n                }\n\n                Optional<ResolvedField> leftField = left.tryResolveField(column);\n                Optional<ResolvedField> rightField = right.tryResolveField(column);\n\n                if (!leftField.isPresent()) {\n                    throw new SemanticException(MISSING_ATTRIBUTE, column, \"Column '%s' is missing from left side of join\", column.getValue());\n                }\n                if (!rightField.isPresent()) {\n                    throw new SemanticException(MISSING_ATTRIBUTE, column, \"Column '%s' is missing from right side of join\", column.getValue());\n                }\n\n                // ensure a comparison operator exists for the given types (applying coercions if necessary)\n                try {\n                    functionAndTypeResolver.resolveOperator(OperatorType.EQUAL, fromTypes(\n                            leftField.get().getType(), rightField.get().getType()));\n                }\n                catch (OperatorNotFoundException e) {\n                    throw new SemanticException(TYPE_MISMATCH, column, \"%s\", e.getMessage());\n                }\n\n                Optional<Type> type = functionAndTypeResolver.getCommonSuperType(leftField.get().getType(), rightField.get().getType());\n                analysis.addTypes(ImmutableMap.of(NodeRef.of(column), type.get()));\n\n                joinFields.add(Field.newUnqualified(column.getLocation(), column.getValue(), type.get()));","sourceCodeStart":3940,"sourceCodeEnd":3976,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/sql/analyzer/StatementAnalyzer.java#L3940-L3976","documentation":"In a USING-join, every listed column must be resolvable on both sides of the join. If the column cannot be resolved as a field of the left relation, analysis throws MISSING_ATTRIBUTE naming the column. (A companion error reports the same for the right side.)","triggerScenarios":"`SELECT ... FROM a JOIN b USING (x)` where relation a has no column x (typo, wrong join order, column only exists on one side).","commonSituations":"Swapped table order relative to the column availability; column renamed in one relation; typos; building USING lists from a schema that doesn't match the actual query.","solutions":["Verify the column exists on both relations via SHOW COLUMNS and fix the name or the USING list","Swap the join operands if the column genuinely lives on the other side","Rewrite with an explicit ON a.col = b.col if the column exists on only one side plus a coalesce/literal for the other","Qualify with subselects/aliases that project the needed column into both relations before the USING join"],"exampleFix":"// before\nSELECT * FROM orders o JOIN customers c USING (customer_id) -- customers has no customer_id\n// after\nSELECT * FROM orders o JOIN customers c ON o.customer_id = c.id","handlingStrategy":"validation","validationCode":"SHOW COLUMNS FROM left_relation; -- confirm the USING column exists here (and on the right side too)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Confirm join keys exist on both relations before USING","Prefer explicit ON clauses when sides are asymmetric","Use schema-aware autocomplete and qualify relation order deliberately"],"tags":["presto","sql","join","using","missing-column"],"backgroundTag":"unknown-column-error","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"}