apache/beam · error · java.lang.IllegalArgumentException

One of withTable() or withQuery() is required

Error message

One of withTable() or withQuery() is required

What it means

SingleStoreUtil.getSelectQuery builds the SELECT statement for a SingleStore read and enforces mutual exclusivity of its inputs: the required-table/query guard rejects the case where neither a table nor a query was provided, since there is nothing to select from. (A separate guard rejects supplying both.) This is a configuration validation at transform build time.

Solutions

  1. Add .withTable("your_table") to the read transform.
  2. Or add .withQuery("SELECT ... FROM ...") for custom SQL.
  3. If config-driven, validate that exactly one of the two fields is present before expanding the pipeline.

Example fix

// before
SingleStoreIO.<T>read().withDataSourceConfiguration(config)

// after
SingleStoreIO.<T>read().withDataSourceConfiguration(config).withTable("orders")
Defensive patterns

Strategy: validation

Validate before calling

if (table == null && query == null) {
  throw new IllegalArgumentException("withTable() or withQuery() is required");
}

Prevention

When it happens

Trigger: Calling SingleStoreIO.read() without calling withTable() or withQuery(); schema-transform read configuration missing both table and query fields.

Common situations: New users forgetting the data source; YAML config where the table/query key was misspelled or left empty; programmatically built config where a variable holding the table name was null.

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


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/7794e7e82a7d7ec5. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/io/singlestore/src/main/java/org/apache/beam/sdk/io/singlestore/SingleStoreUtil.java:82

          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) {
    if (value != null) {
      return value.getClass().getName();
    }
    return null;
  }
}

View on GitHub (pinned to 12126d8942)