Skip to content

[Code Simplification] Removal of Snowflake from codebase#133

Merged
juanmrad merged 2 commits into
mainfrom
remove-snowflake-fully
Mar 21, 2026
Merged

[Code Simplification] Removal of Snowflake from codebase#133
juanmrad merged 2 commits into
mainfrom
remove-snowflake-fully

Conversation

@juanmrad
Copy link
Copy Markdown
Member

Context & Requests for Reviewers

This PR removes all references to snowflake from our codebase. It cleans up the snowflake code, the packages as well as its references. It moves any snowflake related types to common data warehouse types instead.

Tests

(Optional) Rollout Plan

@juanmrad juanmrad marked this pull request as ready for review March 21, 2026 00:55
@juanmrad
Copy link
Copy Markdown
Member Author

Migration order check failed because I modified all migrations to remove the snowflake references as not relevant. so the failure is expected and ok.

@github-actions
Copy link
Copy Markdown
Contributor

Checklist:

  • Are as many columns marked NOT NULL as possible? If some columns can sometimes be null, but not when another column is filled in, have you considered normalizing the schema further (see https://www.guru99.com/database-normalization.html)? If that's not viable/desirable, are there adequate SQL CHECK constraints to capture the relationships between column values (e.g., which can be null together), and are these also captured using unions in the associated kysely types? (.devops/migrator/src/scripts/api-server-pg/2025.12.01T00.00.00.initial-schema.sql, .devops/migrator/src/scripts/api-server-pg/2025.12.01T00.00.01.initial-test-data.seed.staging.sql, .devops/migrator/src/scripts/clickhouse/2025.11.22T00.00.00.initial-schema.sql, .devops/migrator/src/scripts/snowflake/2024.12.02T00.00.00.initial-schema-flattened.sql)

Copy link
Copy Markdown
Contributor

@vinaysrao1 vinaysrao1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work. Can't find anything.

@juanmrad juanmrad merged commit a3bd7ca into main Mar 21, 2026
11 of 12 checks passed
@juanmrad juanmrad deleted the remove-snowflake-fully branch March 21, 2026 22:04
@cassidyjames cassidyjames added this to the v1 milestone Apr 24, 2026
@github-project-automation github-project-automation Bot moved this to Done in Coop May 13, 2026
julietshen added a commit that referenced this pull request May 29, 2026
The rule anomaly detection query was carried over verbatim from the
pre-#133 Snowflake era. Against ClickHouse it fails in five distinct
ways, all of which compound to silently make every rule's computed alarm
state INSUFFICIENT_DATA so the detection job is a no-op in practice.

Surfaced while building the #342 integ test (which couldn't see any
alarm transitions until each of these was fixed in turn):

1. `array_size(passes_distinct_user_ids)` — Snowflake `ARRAY_SIZE` has no
   ClickHouse equivalent under that name. The column is also a JSON
   `String`, not a native `Array`, so `length()` wouldn't help either.
   Switch to `JSONLength(...)`, which parses the JSON array and counts.

2. `SYSDATE()` — not a ClickHouse function. Replace with `now64(3)`,
   which returns `DateTime64(3)` in UTC (matching the column type and
   matching the original Snowflake-comment claim that we wanted UTC).

3. `ts_start_inclusive >= ?` with a `Date` bind — the warehouse adapter
   formats Dates as ISO 8601 with `Z`, which ClickHouse rejects when
   implicitly converting to `DateTime64(3)`. Wrap the bind with
   `parseDateTime64BestEffort(?)` so the format is accepted explicitly.

4. `row.RULE_ID`, `row.NUM_PASSES`, etc — Snowflake defaults to uppercase
   identifiers, ClickHouse returns column names as written. Every column
   access was reading back `undefined`, so the rule-id-keyed grouping in
   `getCurrentPeriodRuleAlarmStatuses` collapsed to a single
   `{ undefined: { status: INSUFFICIENT_DATA } }` bucket.

5. `passCount`/`passingUsersCount`/`runsCount` cast as `number` — but
   ClickHouse `Int64`/`UInt64` columns deserialise to JS `BigInt`. The
   downstream `binomialTest` validator throws on `1n` even though it
   accepts `1`. Coerce with `Number(...)` at the read site.

Snapshots in the existing unit tests updated to match the new SQL.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
julietshen added a commit that referenced this pull request May 29, 2026
The rule anomaly detection query was carried over verbatim from the
pre-#133 Snowflake era. Against ClickHouse it fails in five distinct
ways, all of which compound to silently make every rule's computed alarm
state INSUFFICIENT_DATA so the detection job is a no-op in practice.

Surfaced while building the #342 integ test (which couldn't see any
alarm transitions until each of these was fixed in turn):

1. `array_size(passes_distinct_user_ids)` — Snowflake `ARRAY_SIZE` has no
   ClickHouse equivalent under that name. The column is also a JSON
   `String`, not a native `Array`, so `length()` wouldn't help either.
   Switch to `JSONLength(...)`, which parses the JSON array and counts.

2. `SYSDATE()` — not a ClickHouse function. Replace with `now64(3)`,
   which returns `DateTime64(3)` in UTC (matching the column type and
   matching the original Snowflake-comment claim that we wanted UTC).

3. `ts_start_inclusive >= ?` with a `Date` bind — the warehouse adapter
   formats Dates as ISO 8601 with `Z`, which ClickHouse rejects when
   implicitly converting to `DateTime64(3)`. Wrap the bind with
   `parseDateTime64BestEffort(?)` so the format is accepted explicitly.

4. `row.RULE_ID`, `row.NUM_PASSES`, etc — Snowflake defaults to uppercase
   identifiers, ClickHouse returns column names as written. Every column
   access was reading back `undefined`, so the rule-id-keyed grouping in
   `getCurrentPeriodRuleAlarmStatuses` collapsed to a single
   `{ undefined: { status: INSUFFICIENT_DATA } }` bucket.

5. `passCount`/`passingUsersCount`/`runsCount` cast as `number` — but
   ClickHouse `Int64`/`UInt64` columns deserialise to JS `BigInt`. The
   downstream `binomialTest` validator throws on `1n` even though it
   accepts `1`. Coerce with `Number(...)` at the read site.

Snapshots in the existing unit tests updated to match the new SQL.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants