{"record":{"id":"bd32f225da309242","repo":"apache/beam","slug":"withtable-can-not-be-used-together-with-withquery","errorCode":null,"errorMessage":"withTable() can not be used together with withQuery()","messagePattern":"withTable\\(\\) can not be used together with withQuery\\(\\)","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/singlestore/src/main/java/org/apache/beam/sdk/io/singlestore/SingleStoreUtil.java","lineNumber":76,"sourceCode":"                SingleStoreIO.RowMapper<OutputT>, OutputT>() {});\n    try {\n      return schemaRegistry.getSchemaCoder(outputType);\n    } catch (NoSuchSchemaException e) {\n      log.warn(\n          \"Unable to infer a schema for type {}. Attempting to infer a coder without a schema.\",\n          outputType);\n    }\n    try {\n      return registry.getCoder(outputType);\n    } catch (CannotProvideCoderException e) {\n      throw new IllegalArgumentException(\n          String.format(\"Unable to infer a coder for type %s\", outputType));\n    }\n  }\n\n  public static String getSelectQuery(@Nullable String table, @Nullable String query) {\n    if (table != null && query != null) {\n      throw new IllegalArgumentException(\"withTable() can not be used together with withQuery()\");\n    } else if (table != null) {\n      return \"SELECT * FROM \" + SingleStoreUtil.escapeIdentifier(table);\n    } else if (query != null) {\n      return query;\n    } else {\n      throw new IllegalArgumentException(\"One of withTable() or withQuery() is required\");\n    }\n  }\n\n  public static <OutputT> OutputT getArgumentWithDefault(\n      @Nullable OutputT value, OutputT defaultValue) {\n    if (value == null) {\n      return defaultValue;\n    }\n    return value;\n  }\n\n  public static <T> @Nullable String getClassNameOrNull(@Nullable T value) {","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/singlestore/src/main/java/org/apache/beam/sdk/io/singlestore/SingleStoreUtil.java#L58-L94","documentation":"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.","triggerScenarios":"Building a read with .withTable(\"t\").withQuery(\"SELECT ...\") (either order) on SingleStoreIO.Read or the schema-transform provider config.","commonSituations":"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.","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."],"exampleFix":"// before\nSingleStoreIO.<T>read().withTable(\"orders\").withQuery(\"SELECT * FROM orders WHERE id > 100\")\n\n// after\nSingleStoreIO.<T>read().withQuery(\"SELECT * FROM orders WHERE id > 100\")","handlingStrategy":"validation","validationCode":"if (table != null && query != null) {\n  throw new IllegalArgumentException(\"Specify either table or query, not both\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["beam","singlestore","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-20T03:17:13.778Z"}