:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(bigquery): Raise non-retryable on missing REQUIRED field (#68534)
Tomás Farías Santana08f30e7cb885
diff --git a/products/batch_exports/backend/temporal/destinations/bigquery_batch_export.py b/products/batch_exports/backend/temporal/destinations/bigquery_batch_export.pyindex 3c9663ab1fe5..2eb2bb3c2f92 100644--- a/products/batch_exports/backend/temporal/destinations/bigquery_batch_export.py+++ b/products/batch_exports/backend/temporal/destinations/bigquery_batch_export.py@@ -102,12 +102,23 @@ NON_RETRYABLE_ERROR_TYPES = ("ServiceAccountOwnershipError",# Raised when the BigQuery integration is not found."BigQueryIntegrationNotFoundError",+ # Raised when the destination table schema is incompatible with the schema of the file we are trying to load.+ "BigQueryIncompatibleSchemaError",)LOGGER = get_write_only_logger(__name__)EXTERNAL_LOGGER = get_logger("EXTERNAL")+class BigQueryIncompatibleSchemaError(Exception):+ """Raised when the destination table schema is incompatible with the schema of the file we are trying to load."""++ def __init__(self, err_msg: str):+ super().__init__(+ f"The data being loaded into the destination table is incompatible with the schema of the destination table: {err_msg}"+ )++FileFormat = typing.Literal["Parquet", "JSONLines"]BigQueryTypeName = typing.Literal["JSON",@@ -1046,6 +1057,23 @@ class BigQueryClient:)await asyncio.sleep(backoff)attempt += 1+ except BadRequest as err:+ if err.reason != "invalidQuery" or "Required field" not in str(err):+ raise+ try:+ field_name = str(err).split(" ")[2]+ except IndexError:+ field_name = "unknown"++ self.external_logger.warning(+ "BigQuery load job failed as a nullable field ('%s') is REQUIRED in the destination table."+ " Consider updating your table's schema so that the field is not REQUIRED."+ " Tables created automatically by the batch export always use non-REQUIRED fields.",+ field_name,+ error_code=err.code,+ exc_info=True,+ )+ raise BigQueryIncompatibleSchemaError(repr(field_name))else:return result