{"record":{"id":"dd11b08404220e0e","repo":"apache/beam","slug":"cannot-set-both-startversion-and-starttimestamp","errorCode":null,"errorMessage":"Cannot set both startVersion and startTimestamp.","messagePattern":"Cannot set both startVersion and startTimestamp\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/delta/src/main/java/org/apache/beam/sdk/io/delta/DeltaIO.java","lineNumber":331,"sourceCode":"    }\n\n    public ReadChanges withConfig(Map<String, String> config) {\n      return toBuilder().setHadoopConfig(config).build();\n    }\n\n    @Override\n    public PCollection<Row> expand(PBegin input) {\n      String path = getTablePath();\n      if (path == null) {\n        throw new IllegalArgumentException(\"Table path must be set.\");\n      }\n      if (getStartVersion() == null && getStartTimestamp() == null) {\n        // TODO: for unbounded reads, support using current HEAD or the latest snapshot\n        // as the default starting point.\n        throw new IllegalArgumentException(\"Either startVersion or startTimestamp must be set.\");\n      }\n      if (getStartVersion() != null && getStartTimestamp() != null) {\n        throw new IllegalArgumentException(\"Cannot set both startVersion and startTimestamp.\");\n      }\n      if (getEndVersion() != null && getEndTimestamp() != null) {\n        throw new IllegalArgumentException(\"Cannot set both endVersion and endTimestamp.\");\n      }\n\n      Configuration conf = new Configuration();\n      Map<String, String> hadoopConfig = getHadoopConfig();\n      if (hadoopConfig != null) {\n        for (Map.Entry<String, String> entry : hadoopConfig.entrySet()) {\n          conf.set(entry.getKey(), entry.getValue());\n        }\n      }\n      Engine engine = DefaultEngine.create(conf);\n      Table table = Table.forPath(engine, path);\n\n      TableImpl tableImpl = (TableImpl) table;\n\n      long resolvedEndVersion;","sourceCodeStart":313,"sourceCodeEnd":349,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/delta/src/main/java/org/apache/beam/sdk/io/delta/DeltaIO.java#L313-L349","documentation":"expand() enforces that the read start point is unambiguous: startVersion and startTimestamp are mutually exclusive. Both express different semantics (exact snapshot version vs. time travel by timestamp), so setting both is rejected with IllegalArgumentException.","triggerScenarios":"Calling both .withStartVersion(v) and .withStartTimestamp(t) on the same DeltaIO.read() builder before applying the transform.","commonSituations":"Merging two configurations (one specifying a version, one a timestamp); copy-pasting from examples that use different start styles; a generic time-travel config exposing both fields and the code forwarding both.","solutions":["Keep only one: remove .withStartTimestamp(...) and rely on startVersion","Or remove .withStartVersion(...) and keep .withStartTimestamp(...)","If both come from config, add explicit validation/mutual-exclusion handling in your pipeline options"],"exampleFix":"// before\nDeltaIO.read().withTable(path).withStartVersion(5L).withStartTimestamp(\"2024-01-01T00:00:00\");\n// after\nDeltaIO.read().withTable(path).withStartVersion(5L);","handlingStrategy":"validation","validationCode":"if (startVersion != null && startTimestamp != null) {\n  throw new IllegalArgumentException(\"Choose either startVersion or startTimestamp, not both\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Expose only one start-bound option in your tooling, or enforce exclusivity at config load","Add a config-load check that fails fast when both fields are populated","Prefer startVersion for determinism; use timestamps only when time travel is required"],"tags":["java","apache-beam","delta-lake","configuration","mutually-exclusive"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}