MCPcopy Create free account
hub / github.com/apecloud/myduckserver / NewArrowDataLoader

Function NewArrowDataLoader

pgserver/arrowloader.go:25–57  ·  view source on GitHub ↗
(ctx *sql.Context, handler *DuckHandler, schema string, table sql.InsertableTable, columns tree.NameList, options string)

Source from the content-addressed store, hash-verified

23
24func NewArrowDataLoader(ctx *sql.Context, handler *DuckHandler, schema string, table sql.InsertableTable, columns tree.NameList, options string) (DataLoader, error) {
25 // Create the FIFO pipe
26 duckBuilder := handler.e.Analyzer.ExecBuilder.(*backend.DuckBuilder)
27 pipePath, err := duckBuilder.CreatePipe(ctx, "pg-from-arrow")
28 if err != nil {
29 return nil, err
30 }
31 arrowName := "__sys_copy_from_arrow_" + strconv.Itoa(int(ctx.ID())) + "__"
32
33 // Create a child without mutating the parent context into its own ancestor.
34 ctx, cancel := newCopyContext(ctx)
35
36 loader := &ArrowDataLoader{
37 PipeDataLoader: PipeDataLoader{
38 ctx: ctx,
39 cancel: cancel,
40 schema: schema,
41 table: table,
42 columns: columns,
43 pipePath: pipePath,
44 rowCount: make(chan int64, 1),
45 logger: ctx.GetLogger(),
46 },
47 arrowName: arrowName,
48 options: options,
49 }
50 loader.read = func() {
51 loader.executeInsert(loader.buildSQL(), pipePath)
52 }
53
54 return loader, nil
55}
56
57// buildSQL builds the DuckDB INSERT statement.
58func (loader *ArrowDataLoader) buildSQL() string {
59 var b strings.Builder
60 b.Grow(256)

Callers 1

handleCopyDataHelperMethod · 0.85

Calls 4

executeInsertMethod · 0.95
buildSQLMethod · 0.95
CreatePipeMethod · 0.80
IDMethod · 0.80

Tested by

no test coverage detected