Skip to content

: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.

feat(batch-exports): Export a date column to Snowflake (#121880)

Tomás Farías Santana4724805d8de1
diff --git a/products/batch_exports/backend/temporal/destinations/snowflake_batch_export.py b/products/batch_exports/backend/temporal/destinations/snowflake_batch_export.py
index 9aa5c1cb8cc1..322772b97da4 100644
--- a/products/batch_exports/backend/temporal/destinations/snowflake_batch_export.py
+++ b/products/batch_exports/backend/temporal/destinations/snowflake_batch_export.py
@@ -290,6 +290,7 @@ SnowflakeTypeName = typing.Literal[
"DOUBLE",
"DOUBLE PRECISION",
"BOOLEAN",
+ "DATE",
"TIMESTAMP",
"TIMESTAMP_NTZ",
"TIMESTAMP_LTZ",
@@ -334,6 +335,9 @@ def data_type_to_snowflake_type(data_type: pa.DataType) -> SnowflakeType:
elif pa.types.is_boolean(data_type):
snowflake_type_name = "BOOLEAN"
+ elif pa.types.is_date(data_type):
+ snowflake_type_name = "DATE"
+
elif pa.types.is_timestamp(data_type):
snowflake_type_name = "TIMESTAMP"
@@ -360,6 +364,8 @@ def snowflake_type_to_data_type(type: SnowflakeType) -> pa.DataType:
base_type = pa.bool_()
case "VARIANT":
base_type = JsonType()
+ case "DATE":
+ base_type = pa.date32()
case "TIMESTAMP" | "TIMESTAMP_NTZ" | "TIMESTAMP_LTZ" | "TIMESTAMP_TZ":
base_type = pa.timestamp("ms", tz="UTC")
case "FLOAT" | "FLOAT4" | "FLOAT8" | "DOUBLE PRECISION" | "REAL":