{"record":{"id":"7794e7e82a7d7ec5","repo":"apache/beam","slug":"one-of-withtable-or-withquery-is-required","errorCode":null,"errorMessage":"One of withTable() or withQuery() is required","messagePattern":"One of withTable\\(\\) or withQuery\\(\\) is required","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":82,"sourceCode":"          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) {\n    if (value != null) {\n      return value.getClass().getName();\n    }\n    return null;\n  }\n}","sourceCodeStart":64,"sourceCodeEnd":100,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/singlestore/src/main/java/org/apache/beam/sdk/io/singlestore/SingleStoreUtil.java#L64-L100","documentation":"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.","triggerScenarios":"Calling SingleStoreIO.read() without calling withTable() or withQuery(); schema-transform read configuration missing both table and query fields.","commonSituations":"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.","solutions":["Add .withTable(\"your_table\") to the read transform.","Or add .withQuery(\"SELECT ... FROM ...\") for custom SQL.","If config-driven, validate that exactly one of the two fields is present before expanding the pipeline."],"exampleFix":"// before\nSingleStoreIO.<T>read().withDataSourceConfiguration(config)\n\n// after\nSingleStoreIO.<T>read().withDataSourceConfiguration(config).withTable(\"orders\")","handlingStrategy":"validation","validationCode":"if (table == null && query == null) {\n  throw new IllegalArgumentException(\"withTable() or withQuery() is required\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always call withTable or withQuery immediately after withDataSourceConfiguration.","Fail fast in config loading if both fields are absent.","Use constants/typed config objects instead of nullable strings."],"tags":["beam","singlestore","configuration","missing-argument"],"backgroundTag":"missing-required-argument","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"}