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.

chore: Explicitly disable multi-statements in Snowflake (#60119)

Tomás Farías Santanaaa9b6f57e5cb
diff --git a/products/batch_exports/backend/api/destination_tests/snowflake.py b/products/batch_exports/backend/api/destination_tests/snowflake.py
index d34a6e9654e7..ee4f869a9579 100644
--- a/products/batch_exports/backend/api/destination_tests/snowflake.py
+++ b/products/batch_exports/backend/api/destination_tests/snowflake.py
@@ -8,6 +8,12 @@ from products.batch_exports.backend.api.destination_tests.base import (
Status,
)
+# Pin Snowflake's per-session statement count to 1 to block multi-statement
+# execution. This is already the connector default, but setting it explicitly
+# means an account-level override cannot accidentally enable multi-statement
+# execution.
+_SNOWFLAKE_SESSION_PARAMETERS: dict[str, str | int] = {"MULTI_STATEMENT_COUNT": 1}
+
def try_load_private_key(
private_key: str | None = None, private_key_passphrase: str | None = None
@@ -90,6 +96,7 @@ class SnowflakeEstablishConnectionTestStep(DestinationTestStep):
private_key=private_key,
# wrap role in quotes in case it contains lowercase or special characters
role=f'"{self.role}"' if self.role is not None else None,
+ session_parameters=_SNOWFLAKE_SESSION_PARAMETERS,
)
except (OperationalError, InterfaceError, DatabaseError) as err:
if err.msg is not None and "404 Not Found" in err.msg:
@@ -172,6 +179,7 @@ class SnowflakeWarehouseTestStep(DestinationTestStep):
account=self.account,
private_key=private_key,
role=f'"{self.role}"' if self.role is not None else None,
+ session_parameters=_SNOWFLAKE_SESSION_PARAMETERS,
)
with connection.cursor() as cursor:
@@ -261,6 +269,7 @@ class SnowflakeDatabaseTestStep(DestinationTestStep):
private_key=private_key,
role=f'"{self.role}"' if self.role is not None else None,
warehouse=self.warehouse,
+ session_parameters=_SNOWFLAKE_SESSION_PARAMETERS,
)
with connection:
@@ -355,6 +364,7 @@ class SnowflakeSchemaTestStep(DestinationTestStep):
private_key=private_key,
role=f'"{self.role}"' if self.role is not None else None,
warehouse=self.warehouse,
+ session_parameters=_SNOWFLAKE_SESSION_PARAMETERS,
)
with connection:
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 abde9e70949f..26bc0f503f7a 100644
--- a/products/batch_exports/backend/temporal/destinations/snowflake_batch_export.py
+++ b/products/batch_exports/backend/temporal/destinations/snowflake_batch_export.py
@@ -585,6 +585,11 @@ class SnowflakeClient:
role=f'"{self.role}"' if self.role is not None else None,
private_key=self.private_key,
login_timeout=5,
+ # Pin Snowflake's per-session statement count to 1 to block
+ # multi-statement execution. This is already the connector default,
+ # but setting it explicitly means an account-level override cannot
+ # accidentally enable multi-statement execution.
+ session_parameters={"MULTI_STATEMENT_COUNT": 1},
)
connection.telemetry_enabled = False