(ctx *sql.Context, handler *DuckHandler, schema string, table sql.InsertableTable, columns tree.NameList, options string)
| 23 | |
| 24 | func 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. |
| 58 | func (loader *ArrowDataLoader) buildSQL() string { |
| 59 | var b strings.Builder |
| 60 | b.Grow(256) |
no test coverage detected