Skip to content

Commit 8e0ca71

Browse files
committed
feat(clickhouse): infer mixed-type JSON arrays as Array(Dynamic) on insert
Set input_format_json_infer_array_of_dynamic_from_array_of_different_types=1 on all native-JSON inserts (task_runs_v2, task_events_v1/v2, metrics_v1, sessions_v1). Mixed-type arrays (e.g. [{...}, "str"]) are now inferred as Array(Dynamic) rather than deeply nested Tuple types, which avoids hitting the binary type-complexity limit during background merges. Making the setting explicit at insert time keeps the behavior deterministic and version-controlled, independent of the server profile / compatibility version. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AaChyhestFMBYBWh6bgcCF
1 parent bfa902b commit 8e0ca71

5 files changed

Lines changed: 15 additions & 0 deletions

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
area: webapp
3+
type: fix
4+
---
5+
6+
Infer mixed-type JSON arrays as Array(Dynamic) instead of nested tuples when writing run, event, metric, and session data to avoid ClickHouse type-complexity merge failures

internal-packages/clickhouse/src/metrics.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export function insertMetrics(ch: ClickhouseWriter) {
2222
settings: {
2323
enable_json_type: 1,
2424
type_json_skip_duplicated_paths: 1,
25+
input_format_json_infer_array_of_dynamic_from_array_of_different_types: 1,
2526
input_format_json_throw_on_bad_escape_sequence: 0,
2627
input_format_json_use_string_type_for_ambiguous_paths_in_named_tuples_inference_from_objects: 1,
2728
},

internal-packages/clickhouse/src/sessions.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,7 @@ export function insertSessionsCompactArrays(ch: ClickhouseWriter, settings?: Cli
118118
settings: {
119119
enable_json_type: 1,
120120
type_json_skip_duplicated_paths: 1,
121+
input_format_json_infer_array_of_dynamic_from_array_of_different_types: 1,
121122
...settings,
122123
},
123124
});
@@ -131,6 +132,7 @@ export function insertSessions(ch: ClickhouseWriter, settings?: ClickHouseSettin
131132
settings: {
132133
enable_json_type: 1,
133134
type_json_skip_duplicated_paths: 1,
135+
input_format_json_infer_array_of_dynamic_from_array_of_different_types: 1,
134136
...settings,
135137
},
136138
});

internal-packages/clickhouse/src/taskEvents.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ export function insertTaskEvents(ch: ClickhouseWriter, settings?: ClickHouseSett
3131
settings: {
3232
enable_json_type: 1,
3333
type_json_skip_duplicated_paths: 1,
34+
input_format_json_infer_array_of_dynamic_from_array_of_different_types: 1,
3435
input_format_json_throw_on_bad_escape_sequence: 0,
3536
input_format_json_use_string_type_for_ambiguous_paths_in_named_tuples_inference_from_objects: 1,
3637
...settings,
@@ -206,6 +207,7 @@ export function insertTaskEventsV2(ch: ClickhouseWriter, settings?: ClickHouseSe
206207
settings: {
207208
enable_json_type: 1,
208209
type_json_skip_duplicated_paths: 1,
210+
input_format_json_infer_array_of_dynamic_from_array_of_different_types: 1,
209211
input_format_json_throw_on_bad_escape_sequence: 0,
210212
input_format_json_use_string_type_for_ambiguous_paths_in_named_tuples_inference_from_objects: 1,
211213
...settings,

internal-packages/clickhouse/src/taskRuns.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ export function insertTaskRunsCompactArrays(ch: ClickhouseWriter, settings?: Cli
211211
settings: {
212212
enable_json_type: 1,
213213
type_json_skip_duplicated_paths: 1,
214+
input_format_json_infer_array_of_dynamic_from_array_of_different_types: 1,
214215
...settings,
215216
},
216217
});
@@ -225,6 +226,7 @@ export function insertTaskRuns(ch: ClickhouseWriter, settings?: ClickHouseSettin
225226
settings: {
226227
enable_json_type: 1,
227228
type_json_skip_duplicated_paths: 1,
229+
input_format_json_infer_array_of_dynamic_from_array_of_different_types: 1,
228230
...settings,
229231
},
230232
});
@@ -349,6 +351,7 @@ export function insertRawTaskRunPayloadsCompactArrays(
349351
async_insert_busy_timeout_ms: 1000,
350352
enable_json_type: 1,
351353
type_json_skip_duplicated_paths: 1,
354+
input_format_json_infer_array_of_dynamic_from_array_of_different_types: 1,
352355
...settings,
353356
},
354357
});
@@ -367,6 +370,7 @@ export function insertRawTaskRunPayloads(ch: ClickhouseWriter, settings?: ClickH
367370
async_insert_busy_timeout_ms: 1000,
368371
enable_json_type: 1,
369372
type_json_skip_duplicated_paths: 1,
373+
input_format_json_infer_array_of_dynamic_from_array_of_different_types: 1,
370374
...settings,
371375
},
372376
});

0 commit comments

Comments
 (0)