Skip to content

Commit

Permalink
If DIST Key is specified then only try migration
Browse files Browse the repository at this point in the history
Otherwise it can be AUTO or manually maintained by the user
  • Loading branch information
alok87 committed May 2, 2021
1 parent b4bf345 commit f71ee32
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions redshiftsink/pkg/redshift/redshift.go
Original file line number Diff line number Diff line change
Expand Up @@ -1087,14 +1087,17 @@ func checkColumnsAndOrdering(
targetTableSortColumns := getSortColumns(targetTable)
if !checkColumnsExactlySame(inputTableSortColumns, targetTableSortColumns) {
klog.V(5).Infof(
"SortKeys needs migration: before: %v, now: %v\n",
"%s, SortKey is diff for col: %s, SortKey in config: %v, target: %v\n",
inputTable.Meta.Name,
inCol.Name,
inputTableSortColumns,
targetTableSortColumns,
)
if len(inputTableSortColumns) == 0 {
klog.Warningf(
"SortKey in table %s looks manually modified, skipped.",
klog.V(3).Infof(
"%s, SortKey for col: %s is AUTO or manually modified, skipped.",
inputTable.Name,
inCol.Name,
)
} else {
alterSQL := fmt.Sprintf(
Expand All @@ -1111,7 +1114,23 @@ 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 diff for col: %s, DistKey in config: %v, target: %v\n",
inputTable.Meta.Name,
inCol.Name,
inputTableDistColumns,
targetTableDistColumns,
)
if len(inputTableDistColumns) == 0 {
klog.V(3).Infof(
"%s, DistKey for col: %s is AUTO or manually modified, skipped.",
inputTable.Name,
inCol.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 f71ee32

Please sign in to comment.