{"record":{"id":"257a300c377de32d","repo":"apache/beam","slug":"table-must-be-specified-to-read-with-partitions","errorCode":null,"errorMessage":"Table must be specified to read with partitions.","messagePattern":"Table must be specified to read with partitions\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcReadSchemaTransformProvider.java","lineNumber":439,"sourceCode":"          && !JDBC_DRIVER_MAP.containsKey(Objects.requireNonNull(jdbcType).toLowerCase())) {\n        throw new IllegalArgumentException(\"JDBC type must be one of \" + JDBC_DRIVER_MAP.keySet());\n      }\n\n      boolean readQueryPresent = (getReadQuery() != null && !\"\".equals(getReadQuery()));\n      boolean locationPresent = (getLocation() != null && !\"\".equals(getLocation()));\n      boolean partitionColumnPresent =\n          (getPartitionColumn() != null && !\"\".equals(getPartitionColumn()));\n\n      // If you specify a readQuery, it is to be used instead of a table.\n      if (readQueryPresent && locationPresent) {\n        throw new IllegalArgumentException(\"Query and Table are mutually exclusive configurations\");\n      }\n      if (!readQueryPresent && !locationPresent) {\n        throw new IllegalArgumentException(\"Either Query or Table must be specified.\");\n      }\n      // Reading with partitions only supports table argument.\n      if (partitionColumnPresent && !locationPresent) {\n        throw new IllegalArgumentException(\"Table must be specified to read with partitions.\");\n      }\n    }\n\n    public static Builder builder() {\n      return new AutoValue_JdbcReadSchemaTransformProvider_JdbcReadSchemaTransformConfiguration\n          .Builder();\n    }\n\n    public abstract Builder toBuilder();\n\n    @AutoValue.Builder\n    public abstract static class Builder {\n      public abstract Builder setDriverClassName(String value);\n\n      public abstract Builder setJdbcType(String value);\n\n      public abstract Builder setJdbcUrl(String value);\n","sourceCodeStart":421,"sourceCodeEnd":457,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcReadSchemaTransformProvider.java#L421-L457","documentation":"Partitioned reads (withPartitionColumn) in Beam JDBC split the scan by ranges over a table column, which only works against a table, not an arbitrary query. If partitionColumn is set but location (table) is not, validate() throws this IllegalArgumentException.","triggerScenarios":"Building the transform with setPartitionColumn(\"id\") while leaving location empty and supplying a readQuery (or nothing) instead of a table.","commonSituations":"Users attempt to speed up a slow custom query by adding a partition column, not realizing partitioning requires the table form.","solutions":["Replace the query with setLocation(tableName) and keep the partition column.","If you need partitioned query-style reads, drop partitionColumn and rely on the query as-is.","Optionally combine table + readQuery filtering capabilities the provider supports, keeping location set."],"exampleFix":"// before\nbuilder().setReadQuery(\"SELECT * FROM orders\").setPartitionColumn(\"order_id\")\n// after\nbuilder().setLocation(\"orders\").setPartitionColumn(\"order_id\")","handlingStrategy":"validation","validationCode":"if (hasText(config.getPartitionColumn()) && !hasText(config.getLocation())) {\n  throw new IllegalArgumentException(\"partitionColumn requires location (table) to be set\");\n}","typeGuard":null,"tryCatchPattern":"try {\n  config.validate();\n} catch (IllegalArgumentException e) {\n  if (\"Table must be specified to read with partitions.\".equals(e.getMessage())) {\n    throw new IllegalStateException(\"Switch from readQuery to location(table) to enable partitioned reads\", e);\n  }\n  throw e;\n}","preventionTips":["Only expose partitioning options when the user selected table-mode.","Document that partitioning works with tables, not arbitrary queries.","Validate combos in config CI tests."],"tags":["jdbc","java","validation","partitioning"],"backgroundTag":"conflicting-config-options","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"}