Skip to content

Commit

Permalink
WIP.
Browse files Browse the repository at this point in the history
  • Loading branch information
Tang8330 committed Dec 12, 2024
1 parent 17103d3 commit bc49b78
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
8 changes: 2 additions & 6 deletions clients/mssql/dialect/dialect.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,9 @@ func (MSSQLDialect) IsTableDoesNotExistErr(err error) bool {
}

func (md MSSQLDialect) BuildIsNotToastValueExpression(tableAlias constants.TableAlias, column columns.Column) string {
toastedValue := "%" + constants.ToastUnavailableValuePlaceholder + "%"
colName := sql.QuoteTableAliasColumn(tableAlias, column, md)
// Microsoft SQL Server doesn't allow boolean expressions to be in the COALESCE statement.
if column.KindDetails == typing.Struct {
return fmt.Sprintf("COALESCE(%s, {}) != {'key': '%s'}", colName, constants.ToastUnavailableValuePlaceholder)
}

return fmt.Sprintf("COALESCE(%s, '') != '%s'", colName, constants.ToastUnavailableValuePlaceholder)
return fmt.Sprintf("COALESCE(%s NOT LIKE '%s', TRUE)", colName, toastedValue)
}

func (MSSQLDialect) BuildDedupeTableQuery(_ sql.TableIdentifier, _ []string) string {
Expand Down
2 changes: 2 additions & 0 deletions clients/shared/merge.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,8 @@ func Merge(ctx context.Context, dwh destination.DataWarehouse, tableData *optimi
return fmt.Errorf("failed to generate merge statements: %w", err)
}

fmt.Println("mergeStatements", mergeStatements)

if err = destination.ExecStatements(dwh, mergeStatements); err != nil {
return fmt.Errorf("failed to execute merge statements: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion clients/snowflake/dialect/dialect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ func TestSnowflakeDialect_BuildIsNotToastValueExpression(t *testing.T) {
}

func buildColumns(colTypesMap map[string]typing.KindDetails) *columns.Columns {
colNames := []string{}
var colNames []string
for colName := range colTypesMap {
colNames = append(colNames, colName)
}
Expand Down

0 comments on commit bc49b78

Please sign in to comment.