Skip to content

Commit

Permalink
Remove Go apis unavailable in 1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
joellubi committed Jan 14, 2024
1 parent 5f15f9a commit 49a6e27
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions go/adbc/driver/snowflake/bulk_ingestion.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,22 +184,28 @@ func (st *statement) ingestStream(ctx context.Context) (nrows int64, err error)
st.streamBind.Release()
st.streamBind = nil
}()
defer func(ctx context.Context) {
defer func() {
// Always check the resulting row count, even in the case of an error. We may have ingested part of the data.
ctx = context.WithoutCancel(ctx)
n, e := countRowsInTable(ctx, st.cnxn.sqldb, st.targetTable)
ctx := context.Background() // TODO(joellubi): switch to context.WithoutCancel(ctx) once we're on Go 1.21
n, countErr := countRowsInTable(ctx, st.cnxn.sqldb, st.targetTable)
nrows = n

// Ingestion, row-count check, or both could have failed
err = errors.Join(err, e)
// Wrap any failures as ADBC errors

// Wrap as ADBC errors
// TODO(joellubi): simplify / improve with errors.Join(err, countErr) once we're on Go 1.20
if err == nil {
err = errToAdbcErr(adbc.StatusInternal, countErr)
return
}

// Failure in the pipeline itself
if errors.Is(err, context.Canceled) {
err = errToAdbcErr(adbc.StatusCancelled, err)
} else {
err = errToAdbcErr(adbc.StatusInternal, err)
}
}(ctx)
}()

parquetProps, arrowProps := newWriterProps(st.alloc, st.ingestOptions)
g, gCtx := errgroup.WithContext(ctx)
Expand Down

0 comments on commit 49a6e27

Please sign in to comment.