{"record":{"id":"be2bbb047b095d35","repo":"apache/beam","slug":"for-sequence-generator-start-d-cannot-be-greater-than-end-d","errorCode":null,"errorMessage":"For sequence generator, 'start' (%d) cannot be greater than 'end' (%d).","messagePattern":"For sequence generator, 'start' \\((.+?)\\) cannot be greater than 'end' \\((.+?)\\)\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/datagen/DataGeneratorRowFn.java","lineNumber":140,"sourceCode":"      }\n\n      JsonNode startNode = properties.path(\"fields.\" + fieldName + \".start\");\n      JsonNode endNode = properties.path(\"fields.\" + fieldName + \".end\");\n\n      if (startNode.isMissingNode() && endNode.isMissingNode()) {\n        return (index) -> index;\n      }\n\n      if (startNode.isMissingNode() || endNode.isMissingNode()) {\n        throw new IllegalArgumentException(\n            \"For a cycling sequence generator, both 'start' and 'end' must be specified.\");\n      }\n\n      long start = startNode.asLong(0L);\n      long end = endNode.asLong(Long.MAX_VALUE);\n\n      if (start > end) {\n        throw new IllegalArgumentException(\n            String.format(\n                \"For sequence generator, 'start' (%d) cannot be greater than 'end' (%d).\",\n                start, end));\n      }\n      long cycleLength = end - start + 1;\n      switch (sqlTypeName) {\n        case INTEGER:\n          return (index) -> (int) (start + (index % cycleLength));\n        case SMALLINT:\n          return (index) -> (short) (start + (index % cycleLength));\n        case TINYINT:\n          return (index) -> (byte) (start + (index % cycleLength));\n        default: // BIGINT\n          return (index) -> start + (index % cycleLength);\n      }\n    }\n\n    switch (sqlTypeName) {","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/sql/src/main/java/org/apache/beam/sdk/extensions/sql/meta/provider/datagen/DataGeneratorRowFn.java#L122-L158","documentation":"For a sequence generator the cycle length is computed as end - start + 1, which is invalid when start exceeds end. The builder validates this after parsing both JSON values as longs and throws an IllegalArgumentException naming the offending values.","triggerScenarios":"Setting fields.<name>.start greater than fields.<name>.end (e.g. start=100, end=1) with kind='sequence'.","commonSituations":"Swapping the values by accident; programmatically computing bounds where the order wasn't normalized; editing properties over time until start drifted past end.","solutions":["Swap the values so start <= end.","Compute and order min/max programmatically before emitting the properties JSON.","Validate range bounds in your table DDL generation code."],"exampleFix":"// before\n'{\"fields\":{\"id\":{\"kind\":\"sequence\",\"start\":100,\"end\":1}}}'\n// after\n'{\"fields\":{\"id\":{\"kind\":\"sequence\",\"start\":1,\"end\":100}}}'","handlingStrategy":"validation","validationCode":"long s = props.path(\"fields.\" + name + \".start\").asLong(0);\nlong e = props.path(\"fields.\" + name + \".end\").asLong(Long.MAX_VALUE);\nif (s > e) throw new IllegalArgumentException(name + \": start > end\");","typeGuard":null,"tryCatchPattern":"try { buildRowFn(props); } catch (IllegalArgumentException e) { /* swap/normalize bounds */ }","preventionTips":["Normalize bounds with Math.min/Math.max when generating config.","Unit-test generated TBLPROPERTIES JSON."],"tags":["beam-sql","datagen","range-validation"],"backgroundTag":"value-out-of-range","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}