Skip to content

Commit

Permalink
Merge pull request #212 from practo/dist-key-auto
Browse files Browse the repository at this point in the history
Try DISTKey migration only if key is specified
  • Loading branch information
alok87 authored May 2, 2021
2 parents b4bf345 + 124d2b5 commit 6895ac3
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions redshiftsink/pkg/redshift/redshift.go
Original file line number Diff line number Diff line change
Expand Up @@ -1087,13 +1087,14 @@ func checkColumnsAndOrdering(
targetTableSortColumns := getSortColumns(targetTable)
if !checkColumnsExactlySame(inputTableSortColumns, targetTableSortColumns) {
klog.V(5).Infof(
"SortKeys needs migration: before: %v, now: %v\n",
"%s, SortKey is different, SortKey in config: %v, target: %v\n",
inputTable.Name,
inputTableSortColumns,
targetTableSortColumns,
)
if len(inputTableSortColumns) == 0 {
klog.Warningf(
"SortKey in table %s looks manually modified, skipped.",
klog.V(3).Infof(
"%s, SortKey is AUTO or manually modified, skipped.",
inputTable.Name,
)
} else {
Expand All @@ -1111,7 +1112,21 @@ func checkColumnsAndOrdering(
inputTableDistColumns := getDistColumns(inputTable)
targetTableDistColumns := getDistColumns(targetTable)
if !checkColumnsExactlySame(inputTableDistColumns, targetTableDistColumns) {
columnOps = append(columnOps, "ALTER DISTKEY using table migration")
klog.V(5).Infof(
"%s, DistKey is different, DistKey in config: %v, target: %v\n",
inputTable.Name,
inputTableDistColumns,
targetTableDistColumns,
)
if len(inputTableDistColumns) == 0 {
klog.V(3).Infof(
"%s, DistKey is AUTO or manually modified, skipped.",
inputTable.Name,
)
} else {
// TODO: #121 DISTKEY support is required
columnOps = append(columnOps, "ALTER DISTKEY using table migration")
}
}

return transactColumnOps, columnOps, varCharColumnOps, errors
Expand Down

0 comments on commit 6895ac3

Please sign in to comment.