Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(data-warehouse): Allow syncing to a single S3 folder for the life of a schema #23155

Merged
merged 3 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,6 @@ def sql_database(
table_rows,
name=table.name,
primary_key=get_primary_key(table),
write_disposition="replace",
spec=SqlDatabaseTableConfiguration,
)(engine, table)
16 changes: 8 additions & 8 deletions posthog/temporal/data_imports/pipelines/stripe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def get_resource(name: str, is_incremental: bool) -> EndpointResource:
"name": "BalanceTransaction",
"table_name": "balance_transaction",
"primary_key": "id",
"write_disposition": "merge",
"write_disposition": "merge" if is_incremental else "replace",
"columns": get_dlt_mapping_for_external_table("stripe_balancetransaction"), # type: ignore
"endpoint": {
"data_selector": "data",
Expand Down Expand Up @@ -41,7 +41,7 @@ def get_resource(name: str, is_incremental: bool) -> EndpointResource:
"name": "Charge",
"table_name": "charge",
"primary_key": "id",
"write_disposition": "merge",
"write_disposition": "merge" if is_incremental else "replace",
"columns": get_dlt_mapping_for_external_table("stripe_charge"), # type: ignore
"endpoint": {
"data_selector": "data",
Expand Down Expand Up @@ -69,7 +69,7 @@ def get_resource(name: str, is_incremental: bool) -> EndpointResource:
"name": "Customer",
"table_name": "customer",
"primary_key": "id",
"write_disposition": "merge",
"write_disposition": "merge" if is_incremental else "replace",
"columns": get_dlt_mapping_for_external_table("stripe_customer"), # type: ignore
"endpoint": {
"data_selector": "data",
Expand All @@ -96,7 +96,7 @@ def get_resource(name: str, is_incremental: bool) -> EndpointResource:
"name": "Invoice",
"table_name": "invoice",
"primary_key": "id",
"write_disposition": "merge",
"write_disposition": "merge" if is_incremental else "replace",
"columns": get_dlt_mapping_for_external_table("stripe_invoice"), # type: ignore
"endpoint": {
"data_selector": "data",
Expand Down Expand Up @@ -126,7 +126,7 @@ def get_resource(name: str, is_incremental: bool) -> EndpointResource:
"name": "Price",
"table_name": "price",
"primary_key": "id",
"write_disposition": "merge",
"write_disposition": "merge" if is_incremental else "replace",
"columns": get_dlt_mapping_for_external_table("stripe_price"), # type: ignore
"endpoint": {
"data_selector": "data",
Expand Down Expand Up @@ -157,7 +157,7 @@ def get_resource(name: str, is_incremental: bool) -> EndpointResource:
"name": "Product",
"table_name": "product",
"primary_key": "id",
"write_disposition": "merge",
"write_disposition": "merge" if is_incremental else "replace",
"columns": get_dlt_mapping_for_external_table("stripe_product"), # type: ignore
"endpoint": {
"data_selector": "data",
Expand Down Expand Up @@ -186,7 +186,7 @@ def get_resource(name: str, is_incremental: bool) -> EndpointResource:
"name": "Subscription",
"table_name": "subscription",
"primary_key": "id",
"write_disposition": "merge",
"write_disposition": "merge" if is_incremental else "replace",
"columns": get_dlt_mapping_for_external_table("stripe_subscription"), # type: ignore
"endpoint": {
"data_selector": "data",
Expand Down Expand Up @@ -263,7 +263,7 @@ def stripe_source(
},
"resource_defaults": {
"primary_key": "id",
"write_disposition": "merge",
"write_disposition": "merge" if is_incremental else "replace",
},
"resources": [get_resource(endpoint, is_incremental)],
}
Expand Down
20 changes: 10 additions & 10 deletions posthog/temporal/data_imports/pipelines/zendesk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def get_resource(name: str, is_incremental: bool) -> EndpointResource:
"name": "brands",
"table_name": "brands",
"primary_key": "id",
"write_disposition": "merge",
"write_disposition": "merge" if is_incremental else "replace",
"columns": get_dlt_mapping_for_external_table("zendesk_brands"), # type: ignore
"endpoint": {
"data_selector": "brands",
Expand All @@ -30,7 +30,7 @@ def get_resource(name: str, is_incremental: bool) -> EndpointResource:
"name": "organizations",
"table_name": "organizations",
"primary_key": "id",
"write_disposition": "merge",
"write_disposition": "merge" if is_incremental else "replace",
"columns": get_dlt_mapping_for_external_table("zendesk_organizations"), # type: ignore
"endpoint": {
"data_selector": "organizations",
Expand All @@ -48,7 +48,7 @@ def get_resource(name: str, is_incremental: bool) -> EndpointResource:
"name": "groups",
"table_name": "groups",
"primary_key": "id",
"write_disposition": "merge",
"write_disposition": "merge" if is_incremental else "replace",
"columns": get_dlt_mapping_for_external_table("zendesk_groups"), # type: ignore
"endpoint": {
"data_selector": "groups",
Expand All @@ -68,7 +68,7 @@ def get_resource(name: str, is_incremental: bool) -> EndpointResource:
"name": "sla_policies",
"table_name": "sla_policies",
"primary_key": "id",
"write_disposition": "merge",
"write_disposition": "merge" if is_incremental else "replace",
"columns": get_dlt_mapping_for_external_table("zendesk_sla_policies"), # type: ignore
"endpoint": {
"data_selector": "sla_policies",
Expand All @@ -83,7 +83,7 @@ def get_resource(name: str, is_incremental: bool) -> EndpointResource:
"name": "users",
"table_name": "users",
"primary_key": "id",
"write_disposition": "merge",
"write_disposition": "merge" if is_incremental else "replace",
"columns": get_dlt_mapping_for_external_table("zendesk_users"), # type: ignore
"endpoint": {
"data_selector": "users",
Expand All @@ -106,7 +106,7 @@ def get_resource(name: str, is_incremental: bool) -> EndpointResource:
"name": "ticket_fields",
"table_name": "ticket_fields",
"primary_key": "id",
"write_disposition": "merge",
"write_disposition": "merge" if is_incremental else "replace",
"columns": get_dlt_mapping_for_external_table("zendesk_ticket_fields"), # type: ignore
"endpoint": {
"data_selector": "ticket_fields",
Expand All @@ -127,7 +127,7 @@ def get_resource(name: str, is_incremental: bool) -> EndpointResource:
"name": "ticket_events",
"table_name": "ticket_events",
"primary_key": "id",
"write_disposition": "merge",
"write_disposition": "merge" if is_incremental else "replace",
"columns": get_dlt_mapping_for_external_table("zendesk_ticket_events"), # type: ignore
"endpoint": {
"data_selector": "ticket_events",
Expand All @@ -150,7 +150,7 @@ def get_resource(name: str, is_incremental: bool) -> EndpointResource:
"name": "tickets",
"table_name": "tickets",
"primary_key": "id",
"write_disposition": "merge",
"write_disposition": "merge" if is_incremental else "replace",
"columns": get_dlt_mapping_for_external_table("zendesk_tickets"), # type: ignore
"endpoint": {
"data_selector": "tickets",
Expand All @@ -172,7 +172,7 @@ def get_resource(name: str, is_incremental: bool) -> EndpointResource:
"name": "ticket_metric_events",
"table_name": "ticket_metric_events",
"primary_key": "id",
"write_disposition": "merge",
"write_disposition": "merge" if is_incremental else "replace",
"columns": get_dlt_mapping_for_external_table("zendesk_ticket_metric_events"), # type: ignore
"endpoint": {
"data_selector": "ticket_metric_events",
Expand Down Expand Up @@ -263,7 +263,7 @@ def zendesk_source(
},
"resource_defaults": {
"primary_key": "id",
"write_disposition": "merge",
"write_disposition": "merge" if is_incremental else "replace",
},
"resources": [get_resource(endpoint, is_incremental)],
}
Expand Down
5 changes: 1 addition & 4 deletions posthog/warehouse/models/external_data_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ class Status(models.TextChoices):

@property
def folder_path(self) -> str:
if self.schema and self.schema.is_incremental:
return f"team_{self.team_id}_{self.pipeline.source_type}_{str(self.schema.pk)}".lower().replace("-", "_")

return f"team_{self.team_id}_{self.pipeline.source_type}_{str(self.pk)}".lower().replace("-", "_")
return f"team_{self.team_id}_{self.pipeline.source_type}_{str(self.schema_id)}".lower().replace("-", "_")

def url_pattern_by_schema(self, schema: str) -> str:
if TEST:
Expand Down
Loading