feat: OLAP status priority functions and query updates (#3156)

* feat: OLAP status priority functions and query updates

- Add v1_status_priority / v1_status_from_priority for v1_readable_status_olap
- Use priority-based aggregation in OLAP task status update queries (EVICTED
  below terminal statuses)
- Migration v1_0_84 and schema v1-olap.sql

Made-with: Cursor

* test: durable eviction tests — replay, cancel after eviction, restore idempotency

- test_eviction_plus_replay, test_evictable_cancel_after_eviction, test_restore_idempotency
- Tighter poll interval for faster test runs

Made-with: Cursor

* fix: flakes

* feedback
This commit is contained in:
Gabe Ruttner
2026-03-04 11:11:09 -08:00
committed by GitHub
parent 51b3af0601
commit 65e44d6f63
6 changed files with 127 additions and 10 deletions
+27
View File
@@ -9,6 +9,33 @@ CREATE TYPE v1_readable_status_olap AS ENUM (
'EVICTED'
);
-- NOTE: enum ordering puts EVICTED after COMPLETED, but logically EVICTED is
-- non-terminal and should rank below terminal statuses. These functions provide
-- the canonical priority ordering for aggregation and comparison.
CREATE OR REPLACE FUNCTION v1_status_to_priority(s v1_readable_status_olap)
RETURNS int IMMUTABLE LANGUAGE sql AS $$
SELECT CASE s
WHEN 'QUEUED' THEN 1
WHEN 'RUNNING' THEN 2
WHEN 'EVICTED' THEN 3
WHEN 'CANCELLED' THEN 4
WHEN 'FAILED' THEN 5
WHEN 'COMPLETED' THEN 6
END;
$$;
CREATE OR REPLACE FUNCTION v1_status_from_priority(p int)
RETURNS v1_readable_status_olap IMMUTABLE LANGUAGE sql AS $$
SELECT CASE p
WHEN 1 THEN 'QUEUED'
WHEN 2 THEN 'RUNNING'
WHEN 3 THEN 'EVICTED'
WHEN 4 THEN 'CANCELLED'
WHEN 5 THEN 'FAILED'
WHEN 6 THEN 'COMPLETED'
END::v1_readable_status_olap;
$$;
-- HELPER FUNCTIONS FOR PARTITIONED TABLES --
CREATE OR REPLACE FUNCTION get_v1_partitions_before_date(
targetTableName text,