Skip to content

Commit

Permalink
the code only runs when Exclude; change
Browse files Browse the repository at this point in the history
  • Loading branch information
heavycrystal committed Dec 13, 2024
1 parent 54d9b05 commit 5da46f1
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions flow/shared/schema_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,27 +49,25 @@ func BuildProcessedSchemaMapping(
for _, mapping := range tableMappings {
if mapping.SourceTableIdentifier == srcTableName {
dstTableName = mapping.DestinationTableIdentifier
if len(mapping.Exclude) != 0 {
columns := make([]*protos.FieldDescription, 0, len(tableSchema.Columns))
pkeyColumns := make([]string, 0, len(tableSchema.PrimaryKeyColumns))
for _, column := range tableSchema.Columns {
if !slices.Contains(mapping.Exclude, column.Name) && !strings.Contains(column.Name, "-") {
columns = append(columns, column)
}
if slices.Contains(tableSchema.PrimaryKeyColumns, column.Name) &&
!slices.Contains(mapping.Exclude, column.Name) {
pkeyColumns = append(pkeyColumns, column.Name)
}
columns := make([]*protos.FieldDescription, 0, len(tableSchema.Columns))
pkeyColumns := make([]string, 0, len(tableSchema.PrimaryKeyColumns))
for _, column := range tableSchema.Columns {
if !slices.Contains(mapping.Exclude, column.Name) && !strings.Contains(column.Name, "-") {
columns = append(columns, column)
}
tableSchema = &protos.TableSchema{
TableIdentifier: tableSchema.TableIdentifier,
PrimaryKeyColumns: pkeyColumns,
IsReplicaIdentityFull: tableSchema.IsReplicaIdentityFull,
NullableEnabled: tableSchema.NullableEnabled,
System: tableSchema.System,
Columns: columns,
if slices.Contains(tableSchema.PrimaryKeyColumns, column.Name) &&
!slices.Contains(mapping.Exclude, column.Name) {
pkeyColumns = append(pkeyColumns, column.Name)
}
}
tableSchema = &protos.TableSchema{
TableIdentifier: tableSchema.TableIdentifier,
PrimaryKeyColumns: pkeyColumns,
IsReplicaIdentityFull: tableSchema.IsReplicaIdentityFull,
NullableEnabled: tableSchema.NullableEnabled,
System: tableSchema.System,
Columns: columns,
}
break
}
}
Expand Down

0 comments on commit 5da46f1

Please sign in to comment.