Skip to content

Commit

Permalink
changed visibility of bulk upsert data types and interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
asmyasnikov committed Oct 4, 2024
1 parent 3637f53 commit 53608c2
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
24 changes: 12 additions & 12 deletions table/table.go
Original file line number Diff line number Diff line change
Expand Up @@ -606,18 +606,18 @@ func (data bulkUpsertRows) ApplyBulkUpsertRequest(a *allocator.Allocator, req *B
return nil
}

func NewBulkUpsertRows(rows value.Value) bulkUpsertRows {
func BulkUpsertDataRows(rows value.Value) bulkUpsertRows {
return bulkUpsertRows{
Rows: rows,
}
}

type bulkUpsertCsv struct {
Data []byte
Options []CsvFormatOption
Options []csvFormatOption
}

type CsvFormatOption interface {
type csvFormatOption interface {
ApplyCsvFormatOption(req *BulkUpsertRequest) (err error)
}

Expand All @@ -637,7 +637,7 @@ func (data bulkUpsertCsv) ApplyBulkUpsertRequest(a *allocator.Allocator, req *Bu
return err
}

func NewBulkUpsertCsv(data []byte, opts ...CsvFormatOption) bulkUpsertCsv {
func BulkUpsertDataCsv(data []byte, opts ...csvFormatOption) bulkUpsertCsv {
return bulkUpsertCsv{
Data: data,
Options: opts,
Expand Down Expand Up @@ -674,7 +674,7 @@ func (opt *csvHeaderOption) ApplyCsvFormatOption(req *BulkUpsertRequest) error {
}

// First not skipped line is a CSV header (list of column names).
func WithCsvHeader() CsvFormatOption {
func WithCsvHeader() csvFormatOption {
return &csvHeaderOption{}
}

Expand All @@ -689,7 +689,7 @@ func (opt *csvNullValueOption) ApplyCsvFormatOption(req *BulkUpsertRequest) erro
}

// String value that would be interpreted as NULL.
func WithCsvNullValue(value []byte) CsvFormatOption {
func WithCsvNullValue(value []byte) csvFormatOption {
return &csvNullValueOption{value}
}

Expand All @@ -704,7 +704,7 @@ func (opt *csvDelimiterOption) ApplyCsvFormatOption(req *BulkUpsertRequest) erro
}

// Fields delimiter in CSV file. It's "," if not set.
func WithCsvDelimiter(value []byte) CsvFormatOption {
func WithCsvDelimiter(value []byte) csvFormatOption {
return &csvDelimiterOption{value}
}

Expand All @@ -719,16 +719,16 @@ func (opt *csvSkipRowsOption) ApplyCsvFormatOption(req *BulkUpsertRequest) error
}

// Number of rows to skip before CSV data. It should be present only in the first upsert of CSV file.
func WithCsvSkipRows(count uint32) CsvFormatOption {
func WithCsvSkipRows(count uint32) csvFormatOption {
return &csvSkipRowsOption{count}
}

type bulkUpsertArrow struct {
Data []byte
Options []ArrowFormatOption
Options []arrowFormatOption
}

type ArrowFormatOption interface {
type arrowFormatOption interface {
ApplyArrowFormatOption(req *BulkUpsertRequest) (err error)
}

Expand All @@ -748,7 +748,7 @@ func (data bulkUpsertArrow) ApplyBulkUpsertRequest(a *allocator.Allocator, req *
return err
}

func NewBulkUpsertArrow(data []byte, opts ...ArrowFormatOption) bulkUpsertArrow {
func BulkUpsertDataArrow(data []byte, opts ...arrowFormatOption) bulkUpsertArrow {
return bulkUpsertArrow{
Data: data,
Options: opts,
Expand Down Expand Up @@ -786,6 +786,6 @@ func (opt *arrowSchemaOption) ApplyArrowFormatOption(req *BulkUpsertRequest) err
return nil
}

func WithArrowSchema(schema []byte) ArrowFormatOption {
func WithArrowSchema(schema []byte) arrowFormatOption {
return &arrowSchemaOption{schema}
}
12 changes: 6 additions & 6 deletions tests/integration/table_bulk_upsert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ func TestTableBulkUpsert(t *testing.T) {
))
}

err := driver.Table().BulkUpsert(scope.Ctx, tablePath, table.NewBulkUpsertRows(
err := driver.Table().BulkUpsert(scope.Ctx, tablePath, table.BulkUpsertDataRows(
types.ListValue(rows...),
))
scope.Require.NoError(err)
Expand All @@ -86,7 +86,7 @@ func TestTableCsvBulkUpsert(t *testing.T) {
42,"text42"
43,"text43"`

err := driver.Table().BulkUpsert(scope.Ctx, tablePath, table.NewBulkUpsertCsv(
err := driver.Table().BulkUpsert(scope.Ctx, tablePath, table.BulkUpsertDataCsv(
[]byte(csv),
table.WithCsvHeader(),
))
Expand All @@ -107,7 +107,7 @@ func TestTableCsvBulkUpsertDelimiter(t *testing.T) {
42:"text42"
43:"text43"`

err := driver.Table().BulkUpsert(scope.Ctx, tablePath, table.NewBulkUpsertCsv(
err := driver.Table().BulkUpsert(scope.Ctx, tablePath, table.BulkUpsertDataCsv(
[]byte(csv),
table.WithCsvHeader(),
table.WithCsvDelimiter([]byte(":")),
Expand All @@ -129,7 +129,7 @@ func TestTableCsvBulkUpsertNullValue(t *testing.T) {
42,hello
43,hello world`

err := driver.Table().BulkUpsert(scope.Ctx, tablePath, table.NewBulkUpsertCsv(
err := driver.Table().BulkUpsert(scope.Ctx, tablePath, table.BulkUpsertDataCsv(
[]byte(csv),
table.WithCsvHeader(),
table.WithCsvNullValue([]byte("hello")),
Expand Down Expand Up @@ -157,7 +157,7 @@ id,val
`

err := driver.Table().BulkUpsert(scope.Ctx, tablePath, table.NewBulkUpsertCsv(
err := driver.Table().BulkUpsert(scope.Ctx, tablePath, table.BulkUpsertDataCsv(
[]byte(csv),
table.WithCsvHeader(),
table.WithCsvSkipRows(2),
Expand All @@ -182,7 +182,7 @@ func TestTableArrowBulkUpsert(t *testing.T) {
schema, err := os.ReadFile("testdata/bulk_upsert_test_schema.arrow")
scope.Require.NoError(err)

err = driver.Table().BulkUpsert(scope.Ctx, tablePath, table.NewBulkUpsertArrow(
err = driver.Table().BulkUpsert(scope.Ctx, tablePath, table.BulkUpsertDataArrow(
[]byte(data),
table.WithArrowSchema(schema),
))
Expand Down

0 comments on commit 53608c2

Please sign in to comment.