apache/beam · error · IllegalArgumentException
Either Query or Table must be specified.
Error message
Either Query or Table must be specified.
What it means
Validation guard in JdbcReadSchemaTransformProvider (and related transforms): a JDBC read requires exactly one source specification — either a read query or a table name. When neither (or both are empty/null) is supplied, validate() throws IllegalArgumentException before building the transform.
Solutions
- Set readQuery with a SELECT statement, e.g. setReadQuery("SELECT * FROM my_table").
- Or set location to the table name.
- Add a config pre-check that fails with a clear message when both fields are empty.
Example fix
// before
builder().setJdbcUrl(url).setJdbcType("mysql") // nothing to read
// after
builder().setJdbcUrl(url).setJdbcType("mysql").setReadQuery("SELECT * FROM users") Defensive patterns
Strategy: validation
Validate before calling
if (!hasText(config.getReadQuery()) && !hasText(config.getLocation())) {
throw new IllegalArgumentException("Provide either readQuery or location (table)");
}
static boolean hasText(String s) { return s != null && !s.isBlank(); } Try / catch
try {
config.validate();
} catch (IllegalArgumentException e) {
if ("Either Query or Table must be specified.".equals(e.getMessage())) {
throw new IllegalStateException("No read source configured: pass --query or --table", e);
}
throw e;
} Prevention
- Require one of --query/--table at the CLI/argument-parsing layer.
- Check interpolated query variables are non-empty before building the config.
- Add a unit test asserting a valid minimal configuration.
When it happens
Trigger: Calling from()/validate() on a configuration where both getReadQuery() is null/empty and getLocation() is null/empty.
Common situations: Programmatically built configs where the query is interpolated from user input that turned out empty; CLI/templated pipelines where neither --query nor --table was passed.
Understand the failure class
Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.
Related errors
- JDBC URL cannot be blank
- Query and Table are mutually exclusive configurations
- Batch size is too large! It should be smaller or equal than
- Column delimiter should be set if headers are present.
- Column headers should be supplied when delimiter is present.
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/5cba9acf30349dc2.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/io/jdbc/src/main/java/org/apache/beam/sdk/io/jdbc/JdbcReadSchemaTransformProvider.java:435
throw new IllegalArgumentException(
"One of JDBC Driver class name or JDBC type must be specified.");
}
if (jdbcTypePresent
&& !JDBC_DRIVER_MAP.containsKey(Objects.requireNonNull(jdbcType).toLowerCase())) {
throw new IllegalArgumentException("JDBC type must be one of " + JDBC_DRIVER_MAP.keySet());
}
boolean readQueryPresent = (getReadQuery() != null && !"".equals(getReadQuery()));
boolean locationPresent = (getLocation() != null && !"".equals(getLocation()));
boolean partitionColumnPresent =
(getPartitionColumn() != null && !"".equals(getPartitionColumn()));
// If you specify a readQuery, it is to be used instead of a table.
if (readQueryPresent && locationPresent) {
throw new IllegalArgumentException("Query and Table are mutually exclusive configurations");
}
if (!readQueryPresent && !locationPresent) {
throw new IllegalArgumentException("Either Query or Table must be specified.");
}
// Reading with partitions only supports table argument.
if (partitionColumnPresent && !locationPresent) {
throw new IllegalArgumentException("Table must be specified to read with partitions.");
}
}
public static Builder builder() {
return new AutoValue_JdbcReadSchemaTransformProvider_JdbcReadSchemaTransformConfiguration
.Builder();
}
public abstract Builder toBuilder();
@AutoValue.Builder
public abstract static class Builder {
public abstract Builder setDriverClassName(String value);
View on GitHub (pinned to 12126d8942)