From 8035d1994471c82b5374b23c0e28077545563de4 Mon Sep 17 00:00:00 2001 From: Robin Tang Date: Sun, 17 Nov 2024 09:39:43 -0800 Subject: [PATCH] Remove usage of columns in `table_config` (#1047) --- clients/redshift/staging.go | 2 +- clients/shared/merge.go | 2 +- lib/destination/types/table_config.go | 10 +++++----- lib/destination/types/table_config_test.go | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/clients/redshift/staging.go b/clients/redshift/staging.go index 64c8bce32..4e233286d 100644 --- a/clients/redshift/staging.go +++ b/clients/redshift/staging.go @@ -26,7 +26,7 @@ func (s *Store) PrepareTemporaryTable(ctx context.Context, tableData *optimizati for colName, newValue := range colToNewLengthMap { // Try to upsert columns first. If this fails, we won't need to update the destination table. - err = tableConfig.Columns().UpsertColumn(colName, columns.UpsertColumnArg{ + err = tableConfig.UpsertColumn(colName, columns.UpsertColumnArg{ StringPrecision: typing.ToPtr(newValue), }) diff --git a/clients/shared/merge.go b/clients/shared/merge.go index 341c3879e..83de84557 100644 --- a/clients/shared/merge.go +++ b/clients/shared/merge.go @@ -78,7 +78,7 @@ func Merge(ctx context.Context, dwh destination.DataWarehouse, tableData *optimi for attempts := 0; attempts < backfillMaxRetries; attempts++ { backfillErr = BackfillColumn(dwh, col, tableID) if backfillErr == nil { - err = tableConfig.Columns().UpsertColumn(col.Name(), columns.UpsertColumnArg{ + err = tableConfig.UpsertColumn(col.Name(), columns.UpsertColumnArg{ Backfilled: typing.ToPtr(true), }) diff --git a/lib/destination/types/table_config.go b/lib/destination/types/table_config.go index 1c11142bd..4f433da8a 100644 --- a/lib/destination/types/table_config.go +++ b/lib/destination/types/table_config.go @@ -59,12 +59,12 @@ func (d *DwhTableConfig) GetColumns() []columns.Column { return d.columns.GetColumns() } -func (d *DwhTableConfig) Columns() *columns.Columns { - if d == nil { - return nil - } +func (d *DwhTableConfig) UpdateColumn(col columns.Column) { + d.columns.UpdateColumn(col) +} - return d.columns +func (d *DwhTableConfig) UpsertColumn(colName string, arg columns.UpsertColumnArg) error { + return d.columns.UpsertColumn(colName, arg) } func (d *DwhTableConfig) MutateInMemoryColumns(columnOp constants.ColumnOperation, cols ...columns.Column) { diff --git a/lib/destination/types/table_config_test.go b/lib/destination/types/table_config_test.go index 58e309657..83536c94b 100644 --- a/lib/destination/types/table_config_test.go +++ b/lib/destination/types/table_config_test.go @@ -70,7 +70,7 @@ func TestDwhTableConfig_ColumnsConcurrency(t *testing.T) { kindDetails = typing.Array } - tableCfg.Columns().UpdateColumn(columns.NewColumn("foo", kindDetails)) + tableCfg.UpdateColumn(columns.NewColumn("foo", kindDetails)) assert.Len(t, tableCfg.GetColumns(), 3) } }(dwhTableCfg)