{"record":{"id":"2e3c5ca564e58008","repo":"apache/seatunnel","slug":"commonerrorcodedeprecated-illegal-argument-2e3c5c","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/src/main/java/org/apache/seatunnel/connectors/seatunnel/iotdb/source/IoTDBSourceSplitEnumerator.java","lineNumber":144,"sourceCode":"        // no need numPartitions, use one partition\n        if (!conf.getOptional(NUM_PARTITIONS).isPresent()) {\n            iotDBSourceSplits.add(new IoTDBSourceSplit(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/src/main/java/org/apache/seatunnel/connectors/seatunnel/iotdb/source/IoTDBSourceSplitEnumerator.java#L126-L162","documentation":"The IoTDB split enumerator splits the user's query SQL on the WHERE keyword to generate per-split range queries. If the SQL contains more than one WHERE clause than the expected count, the split logic cannot safely rewrite it, so it throws IotdbConnectorException(ILLEGAL_ARGUMENT).","triggerScenarios":"getIotDBSplit() (via newSplits()) splits the configured query SQL on case-insensitive ' WHERE ' and finds more segments than SQL_WHERE_SPLIT_LENGTH allows — e.g. a query containing two WHERE keywords (nested/subquery or one inside a string literal).","commonSituations":"Users write complex align-by queries with subqueries containing WHERE; a WHERE keyword appears inside quoted string values or comments; copy-pasted SQL with duplicated conditions.","solutions":["Rewrite the query to use at most one top-level WHERE clause; move extra conditions into the single WHERE with AND/OR.","Avoid subqueries with their own WHERE in the configured SQL.","Escape or reword string literals containing the word WHERE.","Use the query's base table directly and express filtering in one WHERE block."],"exampleFix":"// before\nquery = \"select * from root.sg.d1 where a > 1; select * from root.sg.d2 where b < 2\"\n// after\nquery = \"select * from root.sg.d1 where a > 1\"","handlingStrategy":"validation","validationCode":"String sql = config.query(); int whereCount = sql.split(\"(?i)\\\\bWHERE\\\\b\").length - 1; if (whereCount > 1) throw new IllegalArgumentException(\"query may contain at most one WHERE clause\");","typeGuard":null,"tryCatchPattern":"catch (IotdbConnectorException e) { if (e.getErrorCode() == CommonErrorCodeDeprecated.ILLEGAL_ARGUMENT) { /* fix configured query SQL */ } }","preventionTips":["Use exactly one top-level WHERE in IoTDB query configs","Avoid subqueries and string literals containing the word WHERE","Test split queries on a single device/time range before scaling"],"tags":["iotdb","source","sql","split-enumeration"],"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"}