Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[redshift,s3,snowflake] Improve temporary table write performance #713

Merged
merged 3 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions clients/redshift/staging.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ func (s *Store) loadTemporaryTable(tableData *optimization.TableData, newTableID
writer.Comma = '\t'

additionalDateFmts := s.config.SharedTransferConfig.TypingSettings.AdditionalDateFormats
columns := tableData.ReadOnlyInMemoryCols().ValidColumns()
for _, value := range tableData.Rows() {
var row []string
for _, col := range tableData.ReadOnlyInMemoryCols().GetColumnsToUpdate() {
colKind, _ := tableData.ReadOnlyInMemoryCols().GetColumn(col)
castedValue, castErr := s.CastColValStaging(value[col], colKind, additionalDateFmts)
for _, col := range columns {
castedValue, castErr := s.CastColValStaging(value[col.Name()], col, additionalDateFmts)
if castErr != nil {
return "", castErr
}
Expand Down
14 changes: 5 additions & 9 deletions clients/s3/s3.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,20 +106,16 @@ func (s *Store) Merge(tableData *optimization.TableData) error {

additionalDateFmts := s.config.SharedTransferConfig.TypingSettings.AdditionalDateFormats
pw.CompressionType = parquet.CompressionCodec_GZIP
columns := tableData.ReadOnlyInMemoryCols().ValidColumns()
for _, val := range tableData.Rows() {
row := make(map[string]any)
for _, col := range tableData.ReadOnlyInMemoryCols().GetColumnsToUpdate() {
colKind, isOk := tableData.ReadOnlyInMemoryCols().GetColumn(col)
if !isOk {
return fmt.Errorf("expected column: %v to exist in readOnlyInMemoryCols(...) but it does not", col)
}

value, err := parquetutil.ParseValue(val[col], colKind, additionalDateFmts)
for _, col := range columns {
value, err := parquetutil.ParseValue(val[col.Name()], col, additionalDateFmts)
if err != nil {
return fmt.Errorf("failed to parse value, err: %w, value: %v, column: %v", err, val[col], col)
return fmt.Errorf("failed to parse value, err: %w, value: %v, column: %q", err, val[col.Name()], col.Name())
}

row[col] = value
row[col.Name()] = value
}

rowBytes, err := json.Marshal(row)
Expand Down
6 changes: 3 additions & 3 deletions clients/snowflake/staging.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ func (s *Store) writeTemporaryTableFile(tableData *optimization.TableData, newTa
writer.Comma = '\t'

additionalDateFmts := s.config.SharedTransferConfig.TypingSettings.AdditionalDateFormats
columns := tableData.ReadOnlyInMemoryCols().ValidColumns()
for _, value := range tableData.Rows() {
var row []string
for _, col := range tableData.ReadOnlyInMemoryCols().GetColumnsToUpdate() {
column, _ := tableData.ReadOnlyInMemoryCols().GetColumn(col)
castedValue, castErr := castColValStaging(value[col], column, additionalDateFmts)
for _, col := range columns {
castedValue, castErr := castColValStaging(value[col.Name()], col, additionalDateFmts)
if castErr != nil {
return "", castErr
}
Expand Down