Skip to content

Commit 0ce9ce3

Browse files
committed
ClickHouse: add output_text and error_text cols with indexes
1 parent 34203d6 commit 0ce9ce3

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
-- +goose Up
2+
3+
-- Add materialized columns that stringify output and error JSON
4+
-- Returns empty string when the JSON is empty ({}) to simplify search and display
5+
ALTER TABLE trigger_dev.task_runs_v2
6+
ADD COLUMN output_text String MATERIALIZED if(toJSONString(output) = '{}', '', toJSONString(output));
7+
8+
ALTER TABLE trigger_dev.task_runs_v2
9+
ADD COLUMN error_text String MATERIALIZED if(toJSONString(error) = '{}', '', toJSONString(error));
10+
11+
-- Add ngrambf_v1 indexes for substring searching (e.g., user IDs, error messages)
12+
-- 128KB bloom filter sized for up to 128KB JSON with ~3% false positive rate worst case
13+
ALTER TABLE trigger_dev.task_runs_v2
14+
ADD INDEX idx_output_text output_text TYPE ngrambf_v1(3, 131072, 3, 0) GRANULARITY 4;
15+
16+
ALTER TABLE trigger_dev.task_runs_v2
17+
ADD INDEX idx_error_text error_text TYPE ngrambf_v1(3, 131072, 3, 0) GRANULARITY 4;
18+
19+
-- +goose Down
20+
21+
ALTER TABLE trigger_dev.task_runs_v2
22+
DROP INDEX idx_output_text;
23+
24+
ALTER TABLE trigger_dev.task_runs_v2
25+
DROP INDEX idx_error_text;
26+
27+
ALTER TABLE trigger_dev.task_runs_v2
28+
DROP COLUMN output_text;
29+
30+
ALTER TABLE trigger_dev.task_runs_v2
31+
DROP COLUMN error_text;

0 commit comments

Comments
 (0)