MCPcopy Create free account
hub / github.com/Effect-TS/effect / insertQuery

Function insertQuery

packages/sql/clickhouse/src/ClickhouseClient.ts:412–439  ·  view source on GitHub ↗
(options: {
          readonly table: string
          readonly values: Clickhouse.InsertValues<Readable, T>
          readonly format?: Clickhouse.DataFormat
          readonly columns?: NonNullable<Clickhouse.InsertParams<Readable, T>["columns"]>
        })

Source from the content-addressed store, hash-verified

410 return Effect.provideService(effect, ClientMethod, "command")
411 },
412 insertQuery<T = unknown>(options: {
413 readonly table: string
414 readonly values: Clickhouse.InsertValues<Readable, T>
415 readonly format?: Clickhouse.DataFormat
416 readonly columns?: NonNullable<Clickhouse.InsertParams<Readable, T>["columns"]>
417 }) {
418 return Effect.callback<Clickhouse.InsertResult, SqlError>((resume) => {
419 const fiber = Fiber.getCurrent()!
420 const queryId = fiber.getRef(QueryId) ?? Crypto.randomUUID()
421 const settings = fiber.getRef(ClickhouseSettings)
422 const controller = new AbortController()
423 client.insert({
424 format: "JSONEachRow",
425 ...options,
426 abort_signal: controller.signal,
427 query_id: queryId,
428 clickhouse_settings: settings
429 }).then(
430 (result) => resume(Effect.succeed(result)),
431 (cause) =>
432 resume(Effect.fail(new SqlError({ reason: classifyError(cause, "Failed to insert data", "insert") })))
433 )
434 return Effect.suspend(() => {
435 controller.abort()
436 return killQuery(client, queryId)
437 })
438 })
439 },
440 withQueryId: dual(
441 2,
442 <A, E, R>(effect: Effect.Effect<A, E, R>, queryId: string) => Effect.provideService(effect, QueryId, queryId)

Callers

nothing calls this directly

Calls 7

killQueryFunction · 0.85
getRefMethod · 0.80
classifyErrorFunction · 0.70
failMethod · 0.65
abortMethod · 0.65
resumeFunction · 0.50
succeedMethod · 0.45

Tested by

no test coverage detected