1- import type { RawTaskRunPayloadV1 , TaskRunV2 } from "@internal/clickhouse" ;
1+ import type { ClickHouse , TaskRunInsertArray , PayloadInsertArray } from "@internal/clickhouse" ;
2+
3+ // Minimal InsertResult type to avoid dependency on @clickhouse /client
4+ interface InsertResult {
5+ executed : boolean ;
6+ query_id : string ;
7+ summary ?: {
8+ read_rows : string ;
9+ read_bytes : string ;
10+ written_rows : string ;
11+ written_bytes : string ;
12+ total_rows_to_read : string ;
13+ result_rows : string ;
14+ result_bytes : string ;
15+ elapsed_ns : string ;
16+ } ;
17+ response_headers : Record < string , string > ;
18+ }
219
320/**
421 * Mock ClickHouse client for CPU-only profiling.
@@ -12,30 +29,64 @@ export class MockClickHouse {
1229 constructor ( private readonly insertDelayMs : number = 0 ) { }
1330
1431 taskRuns = {
15- insert : async (
16- runs : TaskRunV2 [ ] ,
32+ insertCompactArrays : async (
33+ rows : TaskRunInsertArray [ ] ,
1734 options ?: any
18- ) : Promise < [ Error | null , { rows : number } | null ] > => {
35+ ) : Promise < [ Error | null , InsertResult | null ] > => {
1936 if ( this . insertDelayMs > 0 ) {
2037 await new Promise ( ( resolve ) => setTimeout ( resolve , this . insertDelayMs ) ) ;
2138 }
2239
23- this . insertCount += runs . length ;
40+ this . insertCount += rows . length ;
2441
25- return [ null , { rows : runs . length } ] ;
42+ return [
43+ null ,
44+ {
45+ executed : true ,
46+ query_id : "mock" ,
47+ summary : {
48+ read_rows : "0" ,
49+ read_bytes : "0" ,
50+ written_rows : String ( rows . length ) ,
51+ written_bytes : "0" ,
52+ total_rows_to_read : "0" ,
53+ result_rows : "0" ,
54+ result_bytes : "0" ,
55+ elapsed_ns : "0" ,
56+ } ,
57+ response_headers : { } ,
58+ } ,
59+ ] ;
2660 } ,
2761
28- insertPayloads : async (
29- payloads : RawTaskRunPayloadV1 [ ] ,
62+ insertPayloadsCompactArrays : async (
63+ rows : PayloadInsertArray [ ] ,
3064 options ?: any
31- ) : Promise < [ Error | null , { rows : number } | null ] > => {
65+ ) : Promise < [ Error | null , InsertResult | null ] > => {
3266 if ( this . insertDelayMs > 0 ) {
3367 await new Promise ( ( resolve ) => setTimeout ( resolve , this . insertDelayMs ) ) ;
3468 }
3569
36- this . payloadInsertCount += payloads . length ;
70+ this . payloadInsertCount += rows . length ;
3771
38- return [ null , { rows : payloads . length } ] ;
72+ return [
73+ null ,
74+ {
75+ executed : true ,
76+ query_id : "mock" ,
77+ summary : {
78+ read_rows : "0" ,
79+ read_bytes : "0" ,
80+ written_rows : String ( rows . length ) ,
81+ written_bytes : "0" ,
82+ total_rows_to_read : "0" ,
83+ result_rows : "0" ,
84+ result_bytes : "0" ,
85+ elapsed_ns : "0" ,
86+ } ,
87+ response_headers : { } ,
88+ } ,
89+ ] ;
3990 } ,
4091 } ;
4192
@@ -51,3 +102,8 @@ export class MockClickHouse {
51102 this . payloadInsertCount = 0 ;
52103 }
53104}
105+
106+ // Type assertion helper for use with RunsReplicationService
107+ export function asMockClickHouse ( mock : MockClickHouse ) : Pick < ClickHouse , "taskRuns" > {
108+ return mock as unknown as Pick < ClickHouse , "taskRuns" > ;
109+ }
0 commit comments