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

feat!: Remove unique constraints in append mode #17129

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/cmd/migrate_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func migrateConnectionV2(ctx context.Context, sourceClient *managedplugin.Client
defer log.Info().Str("source", sourceSpec.Name).Strs("destinations", destinationStrings).Time("migrate_time", migrateStart).Msg("End migration")

sourcePbClient := pbSource.NewSourceClient(sourceClient.Conn)
destinationsTransformers := getSourceV2DestV3DestinationsTransformers(destinationSpecs, destinationsVersions, sourceSpec)
destinationsTransformers := getSourceV2DestV3DestinationsTransformers(destinationSpecs, destinationsVersions)
destinationsPbClients := make([]pbdestination.DestinationClient, len(managedDestinationsClients))
for i := range managedDestinationsClients {
destinationsPbClients[i] = pbdestination.NewDestinationClient(managedDestinationsClients[i].Conn)
Expand Down
4 changes: 1 addition & 3 deletions cli/cmd/migrate_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,7 @@ func migrateConnectionV3(ctx context.Context, sourceClient *managedplugin.Client
}
if destinationSpecs[i].WriteMode == specs.WriteModeAppend {
opts = append(opts, transformer.WithRemovePKs(), transformer.WithRemovePKs())
if sourceSpec.DeterministicCQID {
opts = append(opts, transformer.WithRemoveUniqueConstraints())
}
opts = append(opts, transformer.WithRemoveUniqueConstraints())
} else if destinationSpecs[i].PKMode == specs.PKModeCQID {
opts = append(opts, transformer.WithRemovePKs())
opts = append(opts, transformer.WithCQIDPrimaryKey())
Expand Down
8 changes: 3 additions & 5 deletions cli/cmd/sync_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"google.golang.org/protobuf/types/known/timestamppb"
)

func getSourceV2DestV3DestinationsTransformers(destinationSpecs []specs.Destination, destinationsVersions [][]int, sourceSpec specs.Source) []*transformer.RecordTransformer {
func getSourceV2DestV3DestinationsTransformers(destinationSpecs []specs.Destination, destinationsVersions [][]int) []*transformer.RecordTransformer {
destinationsTransformers := make([]*transformer.RecordTransformer, 0, len(destinationsVersions))
for i := range destinationsVersions {
// We only need to transform to destinations that are v3
Expand All @@ -33,9 +33,7 @@ func getSourceV2DestV3DestinationsTransformers(destinationSpecs []specs.Destinat
opts := []transformer.RecordTransformerOption{}
if destinationSpecs[i].WriteMode == specs.WriteModeAppend {
opts = append(opts, transformer.WithRemovePKs(), transformer.WithRemovePKs())
if sourceSpec.DeterministicCQID {
opts = append(opts, transformer.WithRemoveUniqueConstraints())
}
opts = append(opts, transformer.WithRemoveUniqueConstraints())
} else if destinationSpecs[i].PKMode == specs.PKModeCQID {
opts = append(opts, transformer.WithRemovePKs())
opts = append(opts, transformer.WithCQIDPrimaryKey())
Expand Down Expand Up @@ -104,7 +102,7 @@ func syncConnectionV2(ctx context.Context, sourceClient *managedplugin.Client, d

sourcePbClient := source.NewSourceClient(sourceClient.Conn)
destinationsPbClients := make([]destination.DestinationClient, len(destinationsClients))
destinationsTransformers := getSourceV2DestV3DestinationsTransformers(destinationSpecs, destinationsVersions, sourceSpec)
destinationsTransformers := getSourceV2DestV3DestinationsTransformers(destinationSpecs, destinationsVersions)
for i := range destinationsClients {
destinationsPbClients[i] = destination.NewDestinationClient(destinationsClients[i].Conn)
}
Expand Down
4 changes: 1 addition & 3 deletions cli/cmd/sync_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,7 @@ func syncConnectionV3(ctx context.Context, source v3source, destinations []v3des
}
if destinationSpecs[i].WriteMode == specs.WriteModeAppend {
opts = append(opts, transformer.WithRemovePKs())
if sourceSpec.DeterministicCQID {
opts = append(opts, transformer.WithRemoveUniqueConstraints())
}
opts = append(opts, transformer.WithRemoveUniqueConstraints())
} else if destinationSpecs[i].PKMode == specs.PKModeCQID {
opts = append(opts, transformer.WithRemovePKs())
opts = append(opts, transformer.WithCQIDPrimaryKey())
Expand Down