apache/beam · error · java.lang.IllegalArgumentException
withTable() can not be used together with withQuery()
Error message
withTable() can not be used together with withQuery()
What it means
SingleStoreIO lets you specify the data source either as a table (withTable) or as a custom SQL statement (withQuery), but not both. getSelectQuery throws this IllegalArgumentException when both are configured, since the resulting SELECT would be ambiguous.
Solutions
- Remove the withTable(...) call and keep only withQuery(...).
- Remove the withQuery(...) call and keep only withTable(...).
- If you need filtering, either embed it in the query or select the whole table.
Example fix
// before
SingleStoreIO.<T>read().withTable("orders").withQuery("SELECT * FROM orders WHERE id > 100")
// after
SingleStoreIO.<T>read().withQuery("SELECT * FROM orders WHERE id > 100") Defensive patterns
Strategy: validation
Validate before calling
if (table != null && query != null) {
throw new IllegalArgumentException("Specify either table or query, not both");
} Prevention
- Pick one source style (table OR query) per read config and document it.
- Centralize SingleStore read config construction in one helper that enforces exclusivity.
- When merging YAML/env config, clear one field when setting the other.
When it happens
Trigger: Building a read with .withTable("t").withQuery("SELECT ...") (either order) on SingleStoreIO.Read or the schema-transform provider config.
Common situations: Copy-pasting pipeline config where a table was set first and a filter query appended later; YAML/programmatic config merging both fields from different sources; a default table configured plus a user-supplied query.
Related errors
- Can't set both the topic and the subscription for a…
- One of withTable() or withQuery() is required
- Both a BigQuery table and a query were specified. Please…
- Cannot set both endVersion and endTimestamp.
- Cannot set both startVersion and startTimestamp.
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/bd32f225da309242.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/io/singlestore/src/main/java/org/apache/beam/sdk/io/singlestore/SingleStoreUtil.java:76
SingleStoreIO.RowMapper<OutputT>, OutputT>() {});
try {
return schemaRegistry.getSchemaCoder(outputType);
} catch (NoSuchSchemaException e) {
log.warn(
"Unable to infer a schema for type {}. Attempting to infer a coder without a schema.",
outputType);
}
try {
return registry.getCoder(outputType);
} catch (CannotProvideCoderException e) {
throw new IllegalArgumentException(
String.format("Unable to infer a coder for type %s", outputType));
}
}
public static String getSelectQuery(@Nullable String table, @Nullable String query) {
if (table != null && query != null) {
throw new IllegalArgumentException("withTable() can not be used together with withQuery()");
} else if (table != null) {
return "SELECT * FROM " + SingleStoreUtil.escapeIdentifier(table);
} else if (query != null) {
return query;
} else {
throw new IllegalArgumentException("One of withTable() or withQuery() is required");
}
}
public static <OutputT> OutputT getArgumentWithDefault(
@Nullable OutputT value, OutputT defaultValue) {
if (value == null) {
return defaultValue;
}
return value;
}
public static <T> @Nullable String getClassNameOrNull(@Nullable T value) {View on GitHub (pinned to 12126d8942)