{"record":{"id":"9e248c47501587e3","repo":"deeplearning4j/deeplearning4j","slug":"cannot-build-join-left-and-or-right-schemas-are-n","errorCode":null,"errorMessage":"Cannot build Join: left and/or right schemas are null","messagePattern":"Cannot build Join: left and/or right schemas are null","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"datavec/datavec-api/src/main/java/org/datavec/api/transform/join/Join.java","lineNumber":173,"sourceCode":"         */\n        public Builder setJoinColumnsLeft(String... joinColumnNames) {\n            this.joinColumnsLeft = joinColumnNames;\n            return this;\n        }\n\n        /**\n         * Specify the names of the columns to join on, for the right data)\n         * The idea: join examples where firstDataValues(joinColumNamesLeft[i]) == secondDataValues(joinColumnNamesRight[i]) for all i\n         * @param joinColumnNames Names of the columns to join on (for left data)\n         */\n        public Builder setJoinColumnsRight(String... joinColumnNames) {\n            this.joinColumnsRight = joinColumnNames;\n            return this;\n        }\n\n        public Join build() {\n            if (leftSchema == null || rightSchema == null)\n                throw new IllegalStateException(\"Cannot build Join: left and/or right schemas are null\");\n            return new Join(this);\n        }\n    }\n\n\n\n    public Schema getOutputSchema() {\n        if (leftSchema == null)\n            throw new IllegalStateException(\"Left schema is not set (null)\");\n        if (rightSchema == null)\n            throw new IllegalStateException(\"Right schema is not set (null)\");\n        if (joinColumnsLeft == null)\n            throw new IllegalStateException(\"Left key columns are not set (null)\");\n        if (joinColumnsRight == null)\n            throw new IllegalArgumentException(\"Right key columns are not set (null\");\n\n        //Approach here: take the left schema, plus the right schema (excluding the key columns from the right schema)\n        List<ColumnMetaData> metaDataOut = new ArrayList<>(leftSchema.getColumnMetaData());","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/deeplearning4j/deeplearning4j/blob/4c22ac5fe4a8350d05d224e7f4499429f7f69c93/datavec/datavec-api/src/main/java/org/datavec/api/transform/join/Join.java#L155-L191","documentation":"Join.Builder.build() refuses to construct a Join when either the left or right Schema was never set via setLeftSchema/setRightSchema, throwing this IllegalStateException. It is a fail-fast guard so an unusable Join object is never created.","triggerScenarios":"Calling new Join.Builder(JoinType.Inner).setJoinColumnsLeft(...).setJoinColumnsRight(...).build() while omitting the setLeftSchema() and/or setRightSchema() calls.","commonSituations":"Copy-pasting builder code and deleting the schema lines, building a Join programmatically where one schema comes from a possibly-null variable (e.g., failed schema inference from an empty CSV).","solutions":["Add setLeftSchema(schema) and setRightSchema(schema) before build()","Null-check the schema variables before starting the builder","If schemas are inferred from data, verify the source data is non-empty/non-null"],"exampleFix":"// before\nJoin join = new Join.Builder(Join.JoinType.Inner)\n    .setJoinColumnsLeft(\"userId\")\n    .setJoinColumnsRight(\"userId\")\n    .build();\n// after\nJoin join = new Join.Builder(Join.JoinType.Inner)\n    .setLeftSchema(leftSchema)\n    .setRightSchema(rightSchema)\n    .setJoinColumnsLeft(\"userId\")\n    .setJoinColumnsRight(\"userId\")\n    .build();","handlingStrategy":"validation","validationCode":"if (leftSchema == null || rightSchema == null)\n    throw new IllegalStateException(\"Schemas must be set before Join.builder().build()\");","typeGuard":null,"tryCatchPattern":"try {\n    Join join = builder.build();\n} catch (IllegalStateException e) {\n    if (e.getMessage().contains(\"left and/or right schemas are null\")) {\n        // re-run schema setup\n    }\n}","preventionTips":["Always set both schemas immediately after creating the Builder","Fail fast on null schema variables before entering the builder chain","Use a factory method that requires schemas as parameters"],"tags":["java","datavec","join","builder"],"backgroundTag":"missing-required-argument","analyzedSha":"4c22ac5fe4a8350d05d224e7f4499429f7f69c93","analyzedAt":"2026-09-07T05:27:04.714Z","contentChangedAt":"2026-09-07T05:27:04.714Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}