diff --git a/clients/redshift/dialect/dialect.go b/clients/redshift/dialect/dialect.go index 0036c094..064ab52f 100644 --- a/clients/redshift/dialect/dialect.go +++ b/clients/redshift/dialect/dialect.go @@ -31,12 +31,15 @@ func (RedshiftDialect) IsTableDoesNotExistErr(_ error) bool { } func (rd RedshiftDialect) BuildIsNotToastValueExpression(tableAlias constants.TableAlias, column columns.Column) string { + toastedValue := "%" + constants.ToastUnavailableValuePlaceholder + "%" colName := sql.QuoteTableAliasColumn(tableAlias, column, rd) - if column.KindDetails == typing.Struct { - return fmt.Sprintf(`COALESCE(%s != JSON_PARSE('{"key":"%s"}'), true)`, - colName, constants.ToastUnavailableValuePlaceholder) + + switch column.KindDetails { + case typing.Struct, typing.Array: + return fmt.Sprintf("COALESCE(JSON_SERIALIZE(%s) NOT LIKE '%s', TRUE)", colName, toastedValue) + default: + return fmt.Sprintf(`COALESCE(%s NOT LIKE '%s', TRUE)`, colName, toastedValue) } - return fmt.Sprintf("COALESCE(%s != '%s', true)", colName, constants.ToastUnavailableValuePlaceholder) } func (rd RedshiftDialect) BuildDedupeTableQuery(tableID sql.TableIdentifier, _ []string) string {