diff --git a/clients/mssql/dialect/dialect.go b/clients/mssql/dialect/dialect.go index 5f120c05..b2773ef8 100644 --- a/clients/mssql/dialect/dialect.go +++ b/clients/mssql/dialect/dialect.go @@ -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 { diff --git a/clients/shared/merge.go b/clients/shared/merge.go index 743c7e31..51392e31 100644 --- a/clients/shared/merge.go +++ b/clients/shared/merge.go @@ -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) } diff --git a/clients/snowflake/dialect/dialect_test.go b/clients/snowflake/dialect/dialect_test.go index 8625893b..fa01cb71 100644 --- a/clients/snowflake/dialect/dialect_test.go +++ b/clients/snowflake/dialect/dialect_test.go @@ -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) }