{"record":{"id":"ab20168ff20c8315","repo":"apache/seatunnel","slug":"commonerrorcodedeprecated-illegal-argument-ab2016","errorCode":"CommonErrorCodeDeprecated.ILLEGAL_ARGUMENT","errorMessage":"sql should not contain more than one where","messagePattern":"sql should not contain more than one where","errorType":"error_code","errorClass":"IotdbConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-iotdb-v2/src/main/java/org/apache/seatunnel/connectors/seatunnel/iotdbv2/source/IoTDBv2SourceSplitEnumerator.java","lineNumber":144,"sourceCode":"        // no need numPartitions, use one partition\n        if (!conf.getOptional(NUM_PARTITIONS).isPresent()) {\n            iotDBSourceSplits.add(new IoTDBv2SourceSplit(DEFAULT_PARTITIONS, sql));\n            return iotDBSourceSplits;\n        }\n        long start = conf.get(LOWER_BOUND);\n        long end = conf.get(UPPER_BOUND);\n        int numPartitions = conf.get(NUM_PARTITIONS);\n        String sqlBase = sql;\n        String sqlAlign = null;\n        String sqlCondition = null;\n        String[] sqls = sqlBase.split(\"(?i)\" + SQL_ALIGN);\n        if (sqls.length > 1) {\n            sqlBase = sqls[0];\n            sqlAlign = sqls[1];\n        }\n        sqls = sqlBase.split(\"(?i)\" + SQL_WHERE);\n        if (sqls.length > SQL_WHERE_SPLIT_LENGTH) {\n            throw new IotdbConnectorException(\n                    CommonErrorCodeDeprecated.ILLEGAL_ARGUMENT,\n                    \"sql should not contain more than one where\");\n        }\n        if (sqls.length > 1) {\n            sqlBase = sqls[0];\n            sqlCondition = sqls[1];\n        }\n        long size = (end - start) / numPartitions + 1;\n        long remainder = (end + 1 - start) % numPartitions;\n        if (end - start < numPartitions) {\n            numPartitions = (int) (end - start);\n        }\n        long currentStart = start;\n        int i = 0;\n        while (i < numPartitions) {\n            String query =\n                    \" where (\"\n                            + RESERVED_TIME","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-iotdb-v2/src/main/java/org/apache/seatunnel/connectors/seatunnel/iotdbv2/source/IoTDBv2SourceSplitEnumerator.java#L126-L162","documentation":"Thrown by getIotDBSplit when parsing the configured query SQL and more than one WHERE clause keyword is found. The enumerator splits the SQL on WHERE once to build per-split range conditions; a second WHERE would break that construction, so the config is rejected as illegal. This is a user SQL configuration validation error before any split is emitted.","triggerScenarios":"The 'query'/'sql' sink-source config contains two WHERE clauses (e.g. a subquery or appended condition), so sqlBase.split(SQL_WHERE) yields more than SQL_WHERE_SPLIT_LENGTH parts.","commonSituations":"Users writing complex queries with subqueries containing WHERE; copy-pasted SQL with redundant conditions; dynamically built SQL appending an extra filter; also align-query SQL (sqlAlign) combined incorrectly.","solutions":["Rewrite the query to use exactly one top-level WHERE, combining conditions with AND/OR","Move subquery WHEREs into a join or restructure the query to avoid nested WHERE keywords","Pre-filter conditions by merging them into the single WHERE clause (e.g. WHERE a=1 AND b=2)","If you need complex queries, disable split-based querying or upgrade to a version supporting richer SQL parsing"],"exampleFix":"// before\nquery = \"select * from sensor where status=1 where region='us'\"\n// after\nquery = \"select * from sensor where status=1 and region='us'\"","handlingStrategy":"validation","validationCode":"String query = conf.get(\"query\");\nString[] parts = query.split(\"(?i)where\");\nif (parts.length > 2) {\n    throw new IllegalArgumentException(\"query may contain at most one WHERE clause: \" + query);\n}","typeGuard":null,"tryCatchPattern":"try {\n    enumerator.getIotDBSplit();\n} catch (IotdbConnectorException e) {\n    if (e.getSeaTunnelErrorCode().equals(CommonErrorCodeDeprecated.ILLEGAL_ARGUMENT)) {\n        // rewrite config query with a single top-level WHERE and retry job\n    }\n    throw e;\n}","preventionTips":["Lint the 'query' config at submit time: exactly one top-level WHERE","Merge conditions with AND/OR instead of stacking WHERE clauses","Avoid subqueries containing WHERE in the configured query","Unit-test SQL parsing of your configured queries before deploy"],"tags":["iotdb","sql","config","split-enumerator"],"backgroundTag":"invalid-argument-value","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}