Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

chore: add dataset-run-items tables to clickhouse (#8243)

marliessophie78f59bc5438f
diff --git a/packages/shared/clickhouse/migrations/clustered/0022_dataset_run_items.down.sql b/packages/shared/clickhouse/migrations/clustered/0022_dataset_run_items.down.sql
new file mode 100644
index 0000000000..a432f4214c
--- /dev/null
+++ b/packages/shared/clickhouse/migrations/clustered/0022_dataset_run_items.down.sql
@@ -0,0 +1 @@
+DROP TABLE dataset_run_items ON CLUSTER default;
\ No newline at end of file
diff --git a/packages/shared/clickhouse/migrations/clustered/0022_dataset_run_items.up.sql b/packages/shared/clickhouse/migrations/clustered/0022_dataset_run_items.up.sql
new file mode 100644
index 0000000000..c7363a13ed
--- /dev/null
+++ b/packages/shared/clickhouse/migrations/clustered/0022_dataset_run_items.up.sql
@@ -0,0 +1,36 @@
+CREATE TABLE dataset_run_items ON CLUSTER default (
+ -- primary identifiers
+ `id` String,
+ `project_id` String,
+ `dataset_run_id` String,
+ `dataset_item_id` String,
+ `dataset_id` String,
+ `trace_id` String,
+ `observation_id` Nullable(String),
+
+ -- error field
+ `error` Nullable(String),
+
+ -- timestamps
+ `created_at` DateTime64(3) DEFAULT now(),
+ `updated_at` DateTime64(3) DEFAULT now(),
+
+ -- denormalized immutable dataset run fields
+ `dataset_run_name` String,
+ `dataset_run_description` Nullable(String),
+ `dataset_run_metadata` Map(LowCardinality(String), String),
+ `dataset_run_created_at` DateTime64(3),
+
+ -- denormalized dataset item fields (mutable, but snapshots are relevant)
+ `dataset_item_input` Nullable(String) CODEC(ZSTD(3)), -- json
+ `dataset_item_expected_output` Nullable(String) CODEC(ZSTD(3)), -- json
+ `dataset_item_metadata` Map(LowCardinality(String), String),
+
+ -- clickhouse engine fields
+ `event_ts` DateTime64(3),
+ `is_deleted` UInt8,
+
+ -- For dataset item lookups
+ INDEX idx_dataset_item dataset_item_id TYPE bloom_filter(0.001) GRANULARITY 1,
+) ENGINE = ReplacingMergeTree(event_ts, is_deleted)
+ORDER BY (project_id, dataset_id, dataset_run_id, id);
\ No newline at end of file
diff --git a/packages/shared/clickhouse/migrations/unclustered/0022_dataset_run_items.down.sql b/packages/shared/clickhouse/migrations/unclustered/0022_dataset_run_items.down.sql
new file mode 100644
index 0000000000..c45faad79c
--- /dev/null
+++ b/packages/shared/clickhouse/migrations/unclustered/0022_dataset_run_items.down.sql
@@ -0,0 +1 @@
+DROP TABLE dataset_run_items;
\ No newline at end of file
diff --git a/packages/shared/clickhouse/migrations/unclustered/0022_dataset_run_items.up.sql b/packages/shared/clickhouse/migrations/unclustered/0022_dataset_run_items.up.sql
new file mode 100644
index 0000000000..c8466b6c9d
--- /dev/null
+++ b/packages/shared/clickhouse/migrations/unclustered/0022_dataset_run_items.up.sql
@@ -0,0 +1,36 @@
+CREATE TABLE dataset_run_items (
+ -- primary identifiers
+ `id` String,
+ `project_id` String,
+ `dataset_run_id` String,
+ `dataset_item_id` String,
+ `dataset_id` String,
+ `trace_id` String,
+ `observation_id` Nullable(String),
+
+ -- error field
+ `error` Nullable(String),
+
+ -- timestamps
+ `created_at` DateTime64(3) DEFAULT now(),
+ `updated_at` DateTime64(3) DEFAULT now(),
+
+ -- denormalized immutable dataset run fields
+ `dataset_run_name` String,
+ `dataset_run_description` Nullable(String),
+ `dataset_run_metadata` Map(LowCardinality(String), String),
+ `dataset_run_created_at` DateTime64(3),
+
+ -- denormalized dataset item fields (mutable, but snapshots are relevant)
+ `dataset_item_input` Nullable(String) CODEC(ZSTD(3)), -- json
+ `dataset_item_expected_output` Nullable(String) CODEC(ZSTD(3)), -- json
+ `dataset_item_metadata` Map(LowCardinality(String), String),
+
+ -- clickhouse engine fields
+ `event_ts` DateTime64(3),
+ `is_deleted` UInt8,
+
+ -- For dataset item lookups
+ INDEX idx_dataset_item dataset_item_id TYPE bloom_filter(0.001) GRANULARITY 1,
+) ENGINE = ReplacingMergeTree(event_ts, is_deleted)
+ORDER BY (project_id, dataset_id, dataset_run_id, id);
\ No newline at end of file
diff --git a/worker/src/services/IngestionService/README.md b/worker/src/services/IngestionService/README.md
index 29df9eb500..fae06dabe8 100644
--- a/worker/src/services/IngestionService/README.md
+++ b/worker/src/services/IngestionService/README.md
@@ -1,55 +1,5 @@
# IngestionService
-## Experimental Setup for Dataset Run Items
-
-Warn: Do not apply on your own as this is highly experimental and may change anytime.
-
-We have a new dataset run item table that is used to store dataset run items. We enable experiments on cloud to verify expected behavior.
-It requires the following table schema to be applied on the database instance:
-
-```sql
--- up migration
-CREATE TABLE dataset_run_items (
- -- primary identifiers
- `id` String,
- `project_id` String,
- `dataset_run_id` String,
- `dataset_item_id` String,
- `dataset_id` String,
- `trace_id` String,
- `observation_id` Nullable(String),
-
- -- error field
- `error` Nullable(String),
-
- -- timestamps
- `created_at` DateTime64(3) DEFAULT now(),
- `updated_at` DateTime64(3) DEFAULT now(),
-
- -- denormalized immutable dataset run fields
- `dataset_run_name` String,
- `dataset_run_description` Nullable(String),
- `dataset_run_metadata` Map(LowCardinality(String), String),
- `dataset_run_created_at` DateTime64(3),
-
- -- denormalized dataset item fields (mutable, but snapshots are relevant)
- `dataset_item_input` Nullable(String) CODEC(ZSTD(3)), -- json
- `dataset_item_expected_output` Nullable(String) CODEC(ZSTD(3)), -- json
- `dataset_item_metadata` Map(LowCardinality(String), String),
-
- -- clickhouse engine fields
- `event_ts` DateTime64(3),
- `is_deleted` UInt8,
-
- -- For dataset item lookups
- INDEX idx_dataset_item dataset_item_id TYPE bloom_filter(0.001) GRANULARITY 1,
-) ENGINE = ReplacingMergeTree(event_ts, is_deleted)
-ORDER BY (project_id, dataset_id, dataset_run_id, id);
-
--- down migration
-DROP TABLE dataset_run_items;
-```
-
## Experimental Setup with AggregatingMergeTrees
Warn: Do not apply on your own as this is highly experimental and may change anytime.