: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
feat(batch-exports): Export person_properties by default (#80326)
Tomás Farías Santana9650280b0d0d
diff --git a/frontend/snapshots.yml b/frontend/snapshots.ymlindex 48bb99e40098..742f15abd609 100644--- a/frontend/snapshots.yml+++ b/frontend/snapshots.yml@@ -7135,9 +7135,9 @@ snapshots:scenes-app-settings-authentication-domains--no-domains--light:hash: v1.k794b7964.37755257eeeb09bcb190a4623e6554e356ffcc6b4e61086b8d2427a3796af34b.eJhnmp6Mqw_TfNQhRHgzZylOtfr8VMwxaRjOdzUHuiIscenes-app-settings-authentication-domains--one-unverified-domain--dark:- hash: v1.k794b7964.d2354aea8e40abfcfeb18691d15e48abc24724460dbc0118185c750d3f8ce6d1.Gcj1tCTTgepeyP-Ep4JIhieodM8RlFeAjTQGNkP2UeQ+ hash: v1.k794b7964.ba64063f3c9c93c5f26f1ef7b83800afeb7a63aec7008d369e2cd7538c4d760b.w4icGggF4i9ltix044heGQLCxuyCXP0irKyWwkKl6Fsscenes-app-settings-authentication-domains--one-unverified-domain--light:- hash: v1.k794b7964.0c40bb5374be5247d5c0e2d73a2118c34d8083775cce447d3faf00ab4012f187.rqLTqwCSkMm5b7tey65wa2ycrn4lTsv8Rw4ASlNuCKs+ hash: v1.k794b7964.9f4f53aee807047bda1de6e3898a5c784bca50bb1f0cbf1d3333e3323e056b41.1g_1hgiCN3qaOaI0lA8Ajwhb8mZhXu95OkHJq1dGfv0scenes-app-settings-environment--settings-environment-access-control--dark:hash: v1.k794b7964.cdbb2694b5d5524628e578f807f3282a0e458c45172c29b79e2b6e7c06eac09f.HqYn6cyhm9cm_fXbavd2nlYeqoTVNd7ODjvCMKlAsIcscenes-app-settings-environment--settings-environment-access-control--light:diff --git a/frontend/src/scenes/data-pipelines/batch-exports/destinations/azureblob.tsx b/frontend/src/scenes/data-pipelines/batch-exports/destinations/azureblob.tsxindex ef4ac11617bb..ef8b67492d99 100644--- a/frontend/src/scenes/data-pipelines/batch-exports/destinations/azureblob.tsx+++ b/frontend/src/scenes/data-pipelines/batch-exports/destinations/azureblob.tsx@@ -3,7 +3,13 @@ import { LemonInput } from '@posthog/lemon-ui'import { IntegrationChoice } from 'lib/components/CyclotronJob/integrations/IntegrationChoice'import { LemonField } from 'lib/lemon-ui/LemonField'-import { CompressionField, FileFormatField, MaxFileSizeField, validateAzureContainerName } from './common'+import {+ CompressionField,+ FileFormatField,+ MaxFileSizeField,+ PERSON_PROPERTIES_EVENT_FIELD,+ validateAzureContainerName,+} from './common'import type { DestinationDefinition } from './types'export const azureBlobDefinition: DestinationDefinition = {@@ -19,6 +25,7 @@ export const azureBlobDefinition: DestinationDefinition = {container_name: validateAzureContainerName(formValues.container_name),}),eventTableOverrides: { teamIdHogql: 'team_id' },+ eventTableExtraFields: { ...PERSON_PROPERTIES_EVENT_FIELD },Fields: function AzureBlobFields({ formValues }) {return (<>diff --git a/frontend/src/scenes/data-pipelines/batch-exports/destinations/bigquery.tsx b/frontend/src/scenes/data-pipelines/batch-exports/destinations/bigquery.tsxindex e4fb3741f0fd..72f6e2558fb4 100644--- a/frontend/src/scenes/data-pipelines/batch-exports/destinations/bigquery.tsx+++ b/frontend/src/scenes/data-pipelines/batch-exports/destinations/bigquery.tsx@@ -4,6 +4,7 @@ import { LemonCheckbox, LemonInput, Tooltip } from '@posthog/lemon-ui'import { IntegrationChoice } from 'lib/components/CyclotronJob/integrations/IntegrationChoice'import { LemonField } from 'lib/lemon-ui/LemonField'+import { PERSON_PROPERTIES_EVENT_FIELD } from './common'import type { DestinationDefinition } from './types'export const bigqueryDefinition: DestinationDefinition = {@@ -15,6 +16,7 @@ export const bigqueryDefinition: DestinationDefinition = {configKeys: ['dataset_id', 'table_id', 'use_json_type'],eventTableOverrides: { teamIdHogql: 'team_id' },eventTableExtraFields: {+ ...PERSON_PROPERTIES_EVENT_FIELD,bq_ingested_timestamp: {name: 'bq_ingested_timestamp',hogql_value: 'NOW64()',diff --git a/frontend/src/scenes/data-pipelines/batch-exports/destinations/common.tsx b/frontend/src/scenes/data-pipelines/batch-exports/destinations/common.tsxindex aa6806042ba9..1982f7eb9ffc 100644--- a/frontend/src/scenes/data-pipelines/batch-exports/destinations/common.tsx+++ b/frontend/src/scenes/data-pipelines/batch-exports/destinations/common.tsx@@ -262,6 +262,17 @@ export function MaxFileSizeField(): JSX.Element {)}+// Included in every destination's event table preview except HTTP, which posts capture-format+// payloads and does not export the column.+export const PERSON_PROPERTIES_EVENT_FIELD: Record<string, DatabaseSchemaField> = {+ person_properties: {+ name: 'person_properties',+ hogql_value: "nullIf(person_properties, '')",+ type: 'string',+ schema_valid: true,+ },+}+// Event table preview columns shared by every S3-family destination (S3, AwsS3, S3Compatible).export const S3_FAMILY_EVENT_TABLE_EXTRA_FIELDS: Record<string, DatabaseSchemaField> = {person_id: {@@ -270,12 +281,7 @@ export const S3_FAMILY_EVENT_TABLE_EXTRA_FIELDS: Record<string, DatabaseSchemaFitype: 'string',schema_valid: true,},- person_properties: {- name: 'person_properties',- hogql_value: "nullIf(person_properties, '')",- type: 'string',- schema_valid: true,- },+ ...PERSON_PROPERTIES_EVENT_FIELD,created_at: {name: 'created_at',hogql_value: 'created_at',diff --git a/frontend/src/scenes/data-pipelines/batch-exports/destinations/databricks.tsx b/frontend/src/scenes/data-pipelines/batch-exports/destinations/databricks.tsxindex a1be897f79e6..edd8fb92c445 100644--- a/frontend/src/scenes/data-pipelines/batch-exports/destinations/databricks.tsx+++ b/frontend/src/scenes/data-pipelines/batch-exports/destinations/databricks.tsx@@ -4,6 +4,7 @@ import { LemonCheckbox, LemonInput, Link, Tooltip } from '@posthog/lemon-ui'import { IntegrationChoice } from 'lib/components/CyclotronJob/integrations/IntegrationChoice'import { LemonField } from 'lib/lemon-ui/LemonField'+import { PERSON_PROPERTIES_EVENT_FIELD } from './common'import type { DestinationDefinition } from './types'export const databricksDefinition: DestinationDefinition = {@@ -23,6 +24,7 @@ export const databricksDefinition: DestinationDefinition = {type: 'integer',schema_valid: true,},+ ...PERSON_PROPERTIES_EVENT_FIELD,databricks_ingested_timestamp: {name: 'databricks_ingested_timestamp',hogql_value: 'NOW64()',diff --git a/frontend/src/scenes/data-pipelines/batch-exports/destinations/postgres.tsx b/frontend/src/scenes/data-pipelines/batch-exports/destinations/postgres.tsxindex 17778da0bd62..f41461383796 100644--- a/frontend/src/scenes/data-pipelines/batch-exports/destinations/postgres.tsx+++ b/frontend/src/scenes/data-pipelines/batch-exports/destinations/postgres.tsx@@ -4,6 +4,7 @@ import { LemonBanner, LemonCheckbox, LemonInput, Tooltip } from '@posthog/lemon-import { IntegrationChoice } from 'lib/components/CyclotronJob/integrations/IntegrationChoice'import { LemonField } from 'lib/lemon-ui/LemonField'+import { PERSON_PROPERTIES_EVENT_FIELD } from './common'import type { DestinationDefinition } from './types'export const postgresDefinition: DestinationDefinition = {@@ -21,6 +22,7 @@ export const postgresDefinition: DestinationDefinition = {return ['host', 'port', 'database', 'schema', 'table_name']},eventTableOverrides: { teamIdHogql: 'toInt32(team_id)' },+ eventTableExtraFields: { ...PERSON_PROPERTIES_EVENT_FIELD },Fields: function PostgresFields({ isNew, formValues }) {const useIntegration = isNew || !!formValues.integration_iddiff --git a/frontend/src/scenes/data-pipelines/batch-exports/destinations/redshift.tsx b/frontend/src/scenes/data-pipelines/batch-exports/destinations/redshift.tsxindex b0094e850bc9..de72820916f0 100644--- a/frontend/src/scenes/data-pipelines/batch-exports/destinations/redshift.tsx+++ b/frontend/src/scenes/data-pipelines/batch-exports/destinations/redshift.tsx@@ -2,7 +2,7 @@ import { LemonInput, LemonSelect } from '@posthog/lemon-ui'import { LemonField } from 'lib/lemon-ui/LemonField'-import { AWS_ONLY_REGION_OPTIONS, validateBucketName } from './common'+import { AWS_ONLY_REGION_OPTIONS, PERSON_PROPERTIES_EVENT_FIELD, validateBucketName } from './common'import type { DestinationDefinition } from './types'// Redshift is the only destination with a non-trivial form ↔ payload mapping.@@ -112,6 +112,7 @@ export const redshiftDefinition: DestinationDefinition = {return result},eventTableOverrides: { teamIdHogql: 'toInt32(team_id)' },+ eventTableExtraFields: { ...PERSON_PROPERTIES_EVENT_FIELD },Fields: function RedshiftFields({ isNew, formValues }) {return (<>diff --git a/frontend/src/scenes/data-pipelines/batch-exports/destinations/snowflake.tsx b/frontend/src/scenes/data-pipelines/batch-exports/destinations/snowflake.tsxindex fec9480b6d76..898fb82aedc0 100644--- a/frontend/src/scenes/data-pipelines/batch-exports/destinations/snowflake.tsx+++ b/frontend/src/scenes/data-pipelines/batch-exports/destinations/snowflake.tsx@@ -3,6 +3,7 @@ import { LemonBanner, LemonInput, LemonSelect, LemonTextArea } from '@posthog/leimport { IntegrationChoice } from 'lib/components/CyclotronJob/integrations/IntegrationChoice'import { LemonField } from 'lib/lemon-ui/LemonField'+import { PERSON_PROPERTIES_EVENT_FIELD } from './common'import type { DestinationDefinition } from './types'// New Snowflake exports must store credentials in a linked Integration. Exports created before@@ -39,6 +40,7 @@ export const snowflakeDefinition: DestinationDefinition = {setOnceName: 'people_set_once',},eventTableExtraFields: {+ ...PERSON_PROPERTIES_EVENT_FIELD,snowflake_ingested_timestamp: {name: 'snowflake_ingested_timestamp',hogql_value: 'NOW64()',diff --git a/products/batch_exports/backend/temporal/batch_exports.py b/products/batch_exports/backend/temporal/batch_exports.pyindex a5452f423a7c..58aee05bafd9 100644--- a/products/batch_exports/backend/temporal/batch_exports.py+++ b/products/batch_exports/backend/temporal/batch_exports.py@@ -157,6 +157,7 @@ def default_fields() -> list[BatchExportField]:expression="set_once",alias="set_once",),+ BatchExportField(expression="person_properties", alias="person_properties"),]@@ -174,6 +175,7 @@ def events_model_default_fields() -> list[BatchExportField]:BatchExportField(expression="event", alias="event"),BatchExportField(expression="properties", alias="properties"),BatchExportField(expression="distinct_id", alias="distinct_id"),+ BatchExportField(expression="person_properties", alias="person_properties"),]diff --git a/products/batch_exports/backend/temporal/destinations/databricks_batch_export.py b/products/batch_exports/backend/temporal/destinations/databricks_batch_export.pyindex 58911125028b..e9a1b8c7213f 100644--- a/products/batch_exports/backend/temporal/destinations/databricks_batch_export.py+++ b/products/batch_exports/backend/temporal/destinations/databricks_batch_export.py@@ -1035,6 +1035,7 @@ def _get_databricks_table_settings(("uuid", "STRING"),("event", "STRING"),("properties", json_type),+ ("person_properties", json_type),("distinct_id", "STRING"),("team_id", "BIGINT"),("timestamp", "TIMESTAMP"),@@ -1325,6 +1326,16 @@ async def insert_into_databricks_activity_from_stage(inputs: DatabricksInsertInp# client before it reaches this point)statement_timeout_seconds=long_running_query_timeout + ONE_MINUTE,).connect() as databricks_client:+ if not requires_merge and inputs.use_automatic_schema_evolution is False:+ # Without a stage table, COPY INTO copies directly into the final table,+ # and with schema evolution disabled it fails on any column an existing+ # table lacks, so skip such columns. A missing table returns no columns.+ existing_columns = await databricks_client.aget_table_columns(inputs.table_name)+ if existing_columns:+ filtered_fields = [field for field in table_fields if field[0] in existing_columns]+ if filtered_fields:+ table_fields = filtered_fields+async with manage_resources(client=databricks_client,volume_name=volume_name,diff --git a/products/batch_exports/backend/temporal/destinations/postgres_batch_export.py b/products/batch_exports/backend/temporal/destinations/postgres_batch_export.pyindex 5360b292a384..57e3bdb1e7e1 100644--- a/products/batch_exports/backend/temporal/destinations/postgres_batch_export.py+++ b/products/batch_exports/backend/temporal/destinations/postgres_batch_export.py@@ -805,6 +805,7 @@ def _get_table_fields(("ip", "VARCHAR(200)"),("site_url", "VARCHAR(200)"),("timestamp", "TIMESTAMP WITH TIME ZONE"),+ ("person_properties", "JSONB"),]else:return get_postgres_fields_from_record_schema(diff --git a/products/batch_exports/backend/temporal/destinations/redshift_batch_export.py b/products/batch_exports/backend/temporal/destinations/redshift_batch_export.pyindex 200be848c74b..a8891458e0dc 100644--- a/products/batch_exports/backend/temporal/destinations/redshift_batch_export.py+++ b/products/batch_exports/backend/temporal/destinations/redshift_batch_export.py@@ -61,7 +61,11 @@ from products.batch_exports.backend.temporal.pipeline.transformer import ()from products.batch_exports.backend.temporal.pipeline.types import BatchExportResultfrom products.batch_exports.backend.temporal.queue import RecordBatchQueue, wait_for_schema_or_producer-from products.batch_exports.backend.temporal.utils import JsonType, handle_non_retryable_errors+from products.batch_exports.backend.temporal.utils import (+ JsonType,+ cast_record_batch_schema_json_columns,+ handle_non_retryable_errors,+)LOGGER = get_write_only_logger(__name__)EXTERNAL_LOGGER = get_logger()@@ -789,6 +793,7 @@ def _get_table_schemas(("ip", "VARCHAR(200)"),("site_url", "VARCHAR(200)"),("timestamp", "TIMESTAMP WITH TIME ZONE"),+ ("person_properties", properties_type),]else:@@ -1395,6 +1400,28 @@ async def copy_into_redshift_activity_from_stage(inputs: RedshiftCopyActivityInpelse inputs.table.name)+ if not merge_settings.requires_merge:+ # Without a stage table, Parquet files are copied directly into the final+ # table, and the COPY column list names every column in the files. Pre-set+ # the transformer's schema to drop columns missing from an existing table,+ # as COPY would otherwise fail on them.+ try:+ async with RedshiftClient.from_inputs(+ inputs.connection, database=inputs.connection.database+ ).connect() as redshift_client:+ existing_columns = set(+ await redshift_client.aget_table_columns(inputs.table.schema_name, inputs.table.name)+ )+ except (psycopg.errors.UndefinedTable, psycopg.errors.InternalError_):+ pass+ else:+ filtered_fields = [field for field in record_batch_schema if field.name in existing_columns]++ if 0 < len(filtered_fields) < len(record_batch_schema):+ transformer.schema = cast_record_batch_schema_json_columns(+ pa.schema(filtered_fields), json_columns=table_schemas.super_columns+ )+async with s3_client(credentials.aws_access_key_id,credentials.aws_secret_access_key,diff --git a/products/batch_exports/backend/temporal/destinations/s3_batch_export.py b/products/batch_exports/backend/temporal/destinations/s3_batch_export.pyindex d136a2c0ea13..fc3c601cff20 100644--- a/products/batch_exports/backend/temporal/destinations/s3_batch_export.py+++ b/products/batch_exports/backend/temporal/destinations/s3_batch_export.py@@ -260,7 +260,6 @@ def s3_default_fields() -> list[BatchExportField]:"""batch_export_fields = default_fields()batch_export_fields.append({"expression": "elements_chain", "alias": "elements_chain"})- batch_export_fields.append({"expression": "person_properties", "alias": "person_properties"})batch_export_fields.append({"expression": "person_id", "alias": "person_id"})# Again, in contrast to other destinations, and for historical reasons, we do not include these fields.diff --git a/products/batch_exports/backend/tests/temporal/destinations/databricks/test_workflow.py b/products/batch_exports/backend/tests/temporal/destinations/databricks/test_workflow.pyindex a3308d0c300f..ee938debfb6e 100644--- a/products/batch_exports/backend/tests/temporal/destinations/databricks/test_workflow.py+++ b/products/batch_exports/backend/tests/temporal/destinations/databricks/test_workflow.py@@ -361,9 +361,45 @@ class TestDatabricksBatchExportWorkflow(CommonWorkflowTests):)@pytest.mark.parametrize("use_automatic_schema_evolution", [True, False])+ @pytest.mark.parametrize(+ "model_name,missing_column,pre_created_table_columns",+ [+ pytest.param(+ "persons",+ "created_at",+ [+ ("team_id", "BIGINT"),+ ("distinct_id", "STRING"),+ ("person_id", "STRING"),+ ("properties", "VARIANT"),+ ("person_distinct_id_version", "BIGINT"),+ ("person_version", "BIGINT"),+ ("is_deleted", "BOOLEAN"),+ ],+ id="persons-missing-created_at",+ ),+ pytest.param(+ "events",+ "person_properties",+ [+ ("uuid", "STRING"),+ ("event", "STRING"),+ ("properties", "VARIANT"),+ ("distinct_id", "STRING"),+ ("team_id", "BIGINT"),+ ("timestamp", "TIMESTAMP"),+ ("databricks_ingested_timestamp", "TIMESTAMP"),+ ],+ id="events-missing-person_properties",+ ),+ ],+ )async def test_workflow_handles_model_schema_changes(self,use_automatic_schema_evolution: bool,+ model_name: str,+ missing_column: str,+ pre_created_table_columns: list[tuple[str, str]],destination_test: DatabricksDestinationTest,interval: str,generate_test_data,@@ -378,34 +414,29 @@ class TestDatabricksBatchExportWorkflow(CommonWorkflowTests):If we update the schema of the model we export, we should still be able to export the data without breakingexisting exports.- To replicate this situation we first export the data with the original schema, then delete a column in the- destination and then rerun the export.+ To replicate this situation we create the destination table with a schema that predates `missing_column`+ and then run the export.Databricks supports automatic schema evolution, which means the target table will automatically be updated with- the schema of the source table (no columns will ever be dropped from the target table however).+ the schema of the source table (no columns will ever be dropped from the target table however). For the persons+ model this happens in the MERGE, for the events model in the COPY INTO.- If `use_automatic_schema_evolution` is True, we will use `WITH SCHEMA EVOLUTION` to enable automatic schema- evolution. In this case, the target table will automatically be updated with the new column.-- If `use_automatic_schema_evolution` is False, we will not use `WITH SCHEMA EVOLUTION` and the target table will- not be updated with the new column.+ If `use_automatic_schema_evolution` is True, the target table will automatically be updated with the new+ column.+ If `use_automatic_schema_evolution` is False, the target table will not be updated with the new column, and+ the export should proceed without it."""- # create the table manually, specifically without the created_at column+ # create the table manually, specifically without `missing_column`destination_config = batch_export_for_destination.destination.configcatalog = destination_config["catalog"]schema = destination_config["schema"]table_name = destination_config["table_name"]+ column_ddl = ",\n".join(f"`{name}` {field_type}" for name, field_type in pre_created_table_columns)query = f"""CREATE TABLE IF NOT EXISTS `{catalog}`.`{schema}`.`{table_name}` (- `team_id` BIGINT,- `distinct_id` STRING,- `person_id` STRING,- `properties` VARIANT,- `person_distinct_id_version` BIGINT,- `person_version` BIGINT,- `is_deleted` BOOLEAN+ {column_ddl})USING DELTACOMMENT 'PostHog generated table'@@ -413,7 +444,7 @@ class TestDatabricksBatchExportWorkflow(CommonWorkflowTests):with destination_test.cursor(ateam.pk, integration) as cursor:cursor.execute(query)- batch_export_model = BatchExportModel(name="persons", schema=None)+ batch_export_model = BatchExportModel(name=model_name, schema=None)inputs = destination_test.create_batch_export_inputs(team_id=ateam.pk,@@ -431,8 +462,9 @@ class TestDatabricksBatchExportWorkflow(CommonWorkflowTests):)assert run.status == "Completed"- _, persons_to_export_created = generate_test_data- assert run.records_completed == len(persons_to_export_created)+ events_to_export_created, persons_to_export_created = generate_test_data+ expected_records = persons_to_export_created if model_name == "persons" else events_to_export_created+ assert run.records_completed == len(expected_records)await assert_clickhouse_records_in_destination(destination_test=destination_test,team_id=ateam.pk,@@ -442,20 +474,20 @@ class TestDatabricksBatchExportWorkflow(CommonWorkflowTests):exclude_events=None,inputs=inputs,integration=integration,- # if `use_automatic_schema_evolution` is False, we expect the created_at column to be dropped- fields_to_exclude=["created_at"] if use_automatic_schema_evolution is False else [],+ # if `use_automatic_schema_evolution` is False, we expect `missing_column` to be dropped+ fields_to_exclude=[missing_column] if use_automatic_schema_evolution is False else [],)- # check that the created_at column is present or not in the destination+ # check that `missing_column` is present or not in the destinationrecords_from_destination = await destination_test.get_inserted_records(team_id=ateam.pk,json_columns=destination_test.get_json_columns(inputs),integration=integration,)if use_automatic_schema_evolution is True:- assert "created_at" in records_from_destination[0]+ assert missing_column in records_from_destination[0]else:- assert "created_at" not in records_from_destination[0]+ assert missing_column not in records_from_destination[0]async def test_workflow_raises_incompatible_schema_error_when_target_table_schema_is_wrong(self,diff --git a/products/batch_exports/backend/tests/temporal/destinations/redshift/test_copy_activity.py b/products/batch_exports/backend/tests/temporal/destinations/redshift/test_copy_activity.pyindex 5268bff1167b..b4862e7c05f5 100644--- a/products/batch_exports/backend/tests/temporal/destinations/redshift/test_copy_activity.py+++ b/products/batch_exports/backend/tests/temporal/destinations/redshift/test_copy_activity.py@@ -669,6 +669,85 @@ async def test_copy_into_redshift_activity_inserts_data_with_extra_columns()[email protected]("exclude_events", [None], indirect=True)[email protected]("properties_data_type", ["varchar"], indirect=True)[email protected]("model", [TEST_MODELS[1]])+async def test_copy_into_redshift_activity_handles_events_table_missing_columns(+ clickhouse_client,+ activity_environment,+ psycopg_connection,+ redshift_config,+ bucket_name,+ bucket_region,+ exclude_events,+ model: BatchExportModel,+ generate_test_data,+ data_interval_start,+ data_interval_end,+ properties_data_type,+ aws_credentials,+ key_prefix,+ ateam,+):+ """Test the events model export succeeds with a table missing selected columns.++ Without a merge, files are copied directly into the final table, and the COPY+ column list names every column in the files. So, columns missing from an existing+ table must be excluded from the files we upload.++ To replicate this situation, we create the destination table without the+ 'site_url' column, as if it had been created before 'site_url' was exported.+ """+ table_name = f"test_copy_activity_missing_columns_table__{ateam.pk}"+ table_fields = [+ ("uuid", "VARCHAR(200)"),+ ("event", "VARCHAR(200)"),+ ("properties", "VARCHAR(65535)"),+ ("elements", "VARCHAR(65535)"),+ ("set", "VARCHAR(65535)"),+ ("set_once", "VARCHAR(65535)"),+ ("distinct_id", "VARCHAR(200)"),+ ("team_id", "INTEGER"),+ ("ip", "VARCHAR(200)"),+ ("timestamp", "TIMESTAMP WITH TIME ZONE"),+ ]++ async with psycopg_connection.transaction():+ async with psycopg_connection.cursor() as cursor:+ await cursor.execute(+ sql.SQL("CREATE TABLE {table} ({fields})").format(+ table=sql.Identifier(redshift_config["schema"], table_name),+ fields=sql.SQL(",").join(+ sql.SQL("{field} {type}").format(field=sql.Identifier(field), type=sql.SQL(field_type))+ for field, field_type in table_fields+ ),+ )+ )++ table_column_names = {field for field, _ in table_fields}+ expected_fields = [field["alias"] for field in redshift_default_fields() if field["alias"] in table_column_names]++ await _run_activity(+ activity_environment,+ redshift_connection=psycopg_connection,+ clickhouse_client=clickhouse_client,+ team=ateam,+ table_name=table_name,+ bucket_name=bucket_name,+ bucket_region=bucket_region,+ key_prefix=key_prefix,+ credentials=aws_credentials,+ properties_data_type=properties_data_type,+ data_interval_start=data_interval_start,+ data_interval_end=data_interval_end,+ exclude_events=exclude_events,+ batch_export_model=model,+ redshift_config=redshift_config,+ sort_key="event",+ expected_fields=expected_fields,+ )++@pytest.mark.parametrize("exclude_events", [None], indirect=True)@pytest.mark.parametrize("properties_data_type", ["varchar"], indirect=True)@pytest.mark.parametrize("model", [TEST_MODELS[1]])