{"record":{"id":"9058fb2db35fdc46","repo":"apache/beam","slug":"validation-of-query-1-s-failed-if-the-query-depends-on-an","errorCode":null,"errorMessage":"Validation of query \"%1$s\" failed. If the query depends on an earlier stage of the pipeline, This validation can be disabled using #withoutValidation.","messagePattern":"Validation of query \"%1\\$s\" failed\\. If the query depends on an earlier stage of the pipeline, This validation can be disabled using #withoutValidation\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIO.java","lineNumber":1491,"sourceCode":"                query.isAccessible(), \"Cannot call validate if query is dynamically set.\");\n            JobService jobService = getBigQueryServices().getJobService(bqOptions);\n            // JobConfigurationQuery accepts null for both of these, but the generated API client\n            // is not annotated.\n            @SuppressWarnings(\"nullness\")\n            JobConfigurationQuery queryConfig =\n                new JobConfigurationQuery()\n                    .setQuery(query.get())\n                    .setFlattenResults(getFlattenResults())\n                    .setUseLegacySql(getUseLegacySql());\n            try {\n              jobService.dryRunQuery(\n                  bqOptions.getBigQueryProject() == null\n                      ? bqOptions.getProject()\n                      : bqOptions.getBigQueryProject(),\n                  queryConfig,\n                  getQueryLocation());\n            } catch (Exception e) {\n              throw new IllegalArgumentException(\n                  String.format(\n                      \"Validation of query \\\"%1$s\\\" failed. If the query depends on an earlier stage of the\"\n                          + \" pipeline, This validation can be disabled using #withoutValidation.\",\n                      query.get()),\n                  e);\n            }\n\n            // If the user provided a temp dataset, check if the dataset exists before launching the\n            // query\n            String queryTempDataset = getQueryTempDataset();\n            if (queryTempDataset != null) {\n              // The temp table is only used for dataset and project id validation, not for table\n              // name\n              // validation\n              String project = getQueryTempProject();\n              if (project == null) {\n                project =\n                    bqOptions.getBigQueryProject() == null","sourceCodeStart":1473,"sourceCodeEnd":1509,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/google-cloud-platform/src/main/java/org/apache/beam/sdk/io/gcp/bigquery/BigQueryIO.java#L1473-L1509","documentation":"Thrown when dry-run validation of the SQL query fails at pipeline-construction/validation time. Beam executes a query dry run against BigQuery; any error from that call is wrapped in this IllegalArgumentException.","triggerScenarios":"BigQueryIO.readQuery/readTableRows(query) with validation enabled (default) and the dry run fails: invalid SQL, unknown table/column, or insufficient permissions.","commonSituations":"Query references tables created by an earlier pipeline stage; SQL syntax errors; missing BigQuery Job dry-run permissions; wrong query location/project.","solutions":["If the query depends on earlier pipeline output, disable validation with .withoutValidation()","Fix the SQL error reported in the chained exception (run the query in the BigQuery console)","Check BigQuery permissions and query location via .withQueryLocation()"],"exampleFix":"// before\nBigQueryIO.readTableRows().fromQuery(\"SELECT * FROM proj:ds.tbl\");\n// after\nBigQueryIO.readTableRows().fromQuery(\"SELECT * FROM proj:ds.tbl\").withoutValidation();","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  p.run().waitUntilFinish();\n} catch (IllegalArgumentException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"Validation of query\")) {\n    // dry run failed: check SQL, permissions, or use withoutValidation()\n  }\n  throw e;\n}","preventionTips":["Dry-run queries in the BigQuery console before pipeline runs","Use .withoutValidation() for queries depending on earlier pipeline stages","Set .withQueryLocation() to match your dataset region"],"tags":["bigquery","sql","validation","java"],"backgroundTag":"sql-query-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}