{"record":{"id":"adf84c3787460321","repo":"apache/seatunnel","slug":"null-value-found-in-in-clause-values","errorCode":null,"errorMessage":"Null value found in IN clause values","messagePattern":"Null value found in IN clause values","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/source/converter/SqlToPaimonPredicateConverter.java","lineNumber":335,"sourceCode":"        int index = getColumnIndex(builder, column);\n\n        Expression right = expr.getRightExpression();\n        if (!(right instanceof ParenthesedExpressionList)) {\n            throw new IllegalArgumentException(\n                    \"Unsupported right expression in IN: expected a parenthesized expression list\");\n        }\n\n        ParenthesedExpressionList list = (ParenthesedExpressionList) right;\n        List<Expression> expressions = list.getExpressions();\n        if (expressions.isEmpty()) {\n            throw new IllegalArgumentException(\"Empty value list in IN clause is not allowed\");\n        }\n\n        List<Object> values = new ArrayList<>(expressions.size());\n        for (Expression expression : expressions) {\n            Object rawVal = getJSQLParserDataTypeValue(expression);\n            if (rawVal == null) {\n                throw new IllegalArgumentException(\"Null value found in IN clause values\");\n            }\n            Object convertedVal =\n                    convertValueByPaimonDataType(rowType, column.getColumnName(), rawVal);\n            if (convertedVal == null) {\n                throw new IllegalArgumentException(\n                        \"Failed to convert value in IN clause: \" + rawVal);\n            }\n            values.add(convertedVal);\n        }\n\n        return expr.isNot() ? builder.notIn(index, values) : builder.in(index, values);\n    }\n\n    private static Column safeGetColumn(Expression expr) {\n        if (!(expr instanceof Column)) {\n            throw new IllegalArgumentException(\n                    \"Expected Column expression, but got: \" + expr.getClass().getSimpleName());\n        }","sourceCodeStart":317,"sourceCodeEnd":353,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-paimon/src/main/java/org/apache/seatunnel/connectors/seatunnel/paimon/source/converter/SqlToPaimonPredicateConverter.java#L317-L353","documentation":"Within an IN clause, a value expression evaluated by getJSQLParserDataTypeValue returned null (e.g. a NULL literal), and the converter rejects NULL as an IN-list member because Paimon's PredicateBuilder.in operates on concrete values and cannot include NULL.","triggerScenarios":"WHERE clause like `col IN (1, NULL, 3)` reaches handleInExpression; getJSQLParserDataTypeValue returns null for the NULL expression.","commonSituations":"Generated SQL that inserts null values into an IN list; users expecting SQL NULL semantics from IN; query builders that stringify nulls.","solutions":["Remove NULL from the IN list; x IN (... NULL ...) never matches NULL anyway.","If NULL rows are needed, split the condition (col IN (1,3) OR col IS NULL), noting IS NULL may not be pushdown-supported.","Validate values and drop nulls before generating SQL."],"exampleFix":"// before: WHERE id IN (1, NULL, 3) | // after: WHERE id IN (1, 3)","handlingStrategy":"validation","validationCode":"List<Object> nonNull = values.stream().filter(Objects::nonNull).collect(Collectors.toList());","typeGuard":null,"tryCatchPattern":"try { pred = converter.convertSqlWhereToPaimonPredicate(where, rowType); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"Null value\")) { /* rebuild clause without nulls */ } throw e; }","preventionTips":["Strip nulls from IN value collections before SQL generation.","Do not rely on IN (... NULL ...) to match NULL rows.","Null-check inputs where the IN list is built."],"tags":["sql","paimon","in-clause","null-value"],"backgroundTag":"null-argument","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}