{"record":{"id":"91392c0debbc3974","repo":"infiniflow/ragflow","slug":"bigquery-requires-either-a-custom-query-or-both-da","errorCode":null,"errorMessage":"BigQuery requires either a custom query or both dataset_id and table_id.","messagePattern":"BigQuery requires either a custom query or both dataset_id and table_id\\.","errorType":"validation","errorClass":"ConnectorValidationError","httpStatus":null,"severity":"error","filePath":"common/data_source/bigquery_connector.py","lineNumber":205,"sourceCode":"                project=self.project_id or None,\n                credentials=creds,\n                location=self.location or None,\n            )\n        except Exception as exc:\n            raise ConnectorValidationError(f\"Failed to create BigQuery client: {exc}\")\n\n        return self._client\n\n    # ------------------------------------------------------------------ #\n    # Query construction\n    # ------------------------------------------------------------------ #\n    def _build_base_query(self) -> str:\n        \"\"\"Return the single base query (custom query takes precedence over table mode).\"\"\"\n        if self.query:\n            return self.query.rstrip(\";\")\n        if self.dataset_id and self.table_id:\n            return f\"SELECT * FROM `{self.project_id}.{self.dataset_id}.{self.table_id}`\"\n        raise ConnectorValidationError(\"BigQuery requires either a custom query or both dataset_id and table_id.\")\n\n    @staticmethod\n    def _wrap_query(base_query: str, select_clause: str = \"*\") -> str:\n        return f\"SELECT {select_clause} FROM ({base_query}) AS ragflow_src\"\n\n    def _build_query_job_config(\n        self,\n        query_parameters: Optional[List[Any]] = None,\n        dry_run: bool = False,\n    ):\n        config = bigquery.QueryJobConfig()\n        config.use_legacy_sql = False\n        config.use_query_cache = self.use_query_cache\n        if self.maximum_bytes_billed:\n            config.maximum_bytes_billed = int(self.maximum_bytes_billed)\n        if self.job_timeout_ms:\n            config.job_timeout_ms = int(self.job_timeout_ms)\n        if query_parameters:","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/common/data_source/bigquery_connector.py#L187-L223","documentation":"Raised by BigQueryConnector._build_base_query when the connector has neither a custom SQL `query` nor the pair `dataset_id` + `table_id` set. The connector cannot form any SELECT statement, so it refuses before touching the BigQuery API.","triggerScenarios":"Calling any method that builds the base query (fetch, sync, validate_connector_settings, schema resolution) with a config where query is empty AND at least one of dataset_id/table_id is empty.","commonSituations":"Connector config dict created from a form where the user left the query field blank and filled only dataset_id, or only table_id; config keys typo'd (e.g. 'datasetId' vs 'dataset_id'); partially migrated configs after a schema change.","solutions":["Set a complete table target: both dataset_id and table_id (project_id comes from credentials/config), e.g. {'project_id': 'p', 'dataset_id': 'd', 'table_id': 't'}","Or provide a custom query instead: config['query'] = 'SELECT ... FROM ...'","Verify config keys are exactly query/dataset_id/table_id before constructing the connector"],"exampleFix":"// before\nconfig = {\"project_id\": \"my-proj\", \"dataset_id\": \"my_data\"}  # table_id missing\n\n// after\nconfig = {\"project_id\": \"my-proj\", \"dataset_id\": \"my_data\", \"table_id\": \"events\"}\n# or: config = {\"project_id\": \"my-proj\", \"query\": \"SELECT * FROM `my-proj.my_data.events`\"}","handlingStrategy":"validation","validationCode":"def has_bigquery_target(cfg: dict) -> bool:\n    return bool(cfg.get(\"query\") or (cfg.get(\"dataset_id\") and cfg.get(\"table_id\")))\n\nif not has_bigquery_target(config):\n    raise ValueError(\"Set 'query' or both 'dataset_id' and 'table_id'\")","typeGuard":null,"tryCatchPattern":"try:\n    conn.fetch(...)\nexcept ConnectorValidationError as e:\n    if \"custom query\" in str(e):\n        fix_target_config()  # set query or dataset_id+table_id\n    else:\n        raise","preventionTips":["Validate connector config with a JSON schema requiring query XOR (dataset_id AND table_id)","Run validate_connector_settings() immediately after construction","Fail fast in config-building code instead of at first fetch"],"tags":["bigquery","configuration","validation","connector"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}