Skip to content

Commit

Permalink
Alias
Browse files Browse the repository at this point in the history
  • Loading branch information
nathan-artie committed May 10, 2024
1 parent 99e4d80 commit 9e49284
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
12 changes: 6 additions & 6 deletions lib/destination/dml/columns_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"testing"

"github.com/artie-labs/transfer/clients/snowflake/dialect"
snowflakeDialect "github.com/artie-labs/transfer/clients/snowflake/dialect"
"github.com/artie-labs/transfer/lib/config/constants"
"github.com/artie-labs/transfer/lib/sql"
"github.com/artie-labs/transfer/lib/typing"
Expand All @@ -14,11 +14,11 @@ import (

func TestQuoteColumns(t *testing.T) {
assert.Equal(t, []string{}, quoteColumns(nil, sql.BigQueryDialect{}))
assert.Equal(t, []string{}, quoteColumns(nil, dialect.SnowflakeDialect{}))
assert.Equal(t, []string{}, quoteColumns(nil, snowflakeDialect.SnowflakeDialect{}))

cols := []columns.Column{columns.NewColumn("a", typing.Invalid), columns.NewColumn("b", typing.Invalid)}
assert.Equal(t, []string{"`a`", "`b`"}, quoteColumns(cols, sql.BigQueryDialect{}))
assert.Equal(t, []string{`"A"`, `"B"`}, quoteColumns(cols, dialect.SnowflakeDialect{}))
assert.Equal(t, []string{`"A"`, `"B"`}, quoteColumns(cols, snowflakeDialect.SnowflakeDialect{}))
}

func TestRemoveDeleteColumnMarker(t *testing.T) {
Expand Down Expand Up @@ -141,7 +141,7 @@ func TestBuildColumnsUpdateFragment(t *testing.T) {
{
name: "string and toast",
columns: stringAndToastCols,
dialect: dialect.SnowflakeDialect{},
dialect: snowflakeDialect.SnowflakeDialect{},
expectedString: `"FOO"= CASE WHEN COALESCE(cc."FOO" != '__debezium_unavailable_value', true) THEN cc."FOO" ELSE c."FOO" END,"BAR"=cc."BAR"`,
},
{
Expand Down Expand Up @@ -174,13 +174,13 @@ func TestBuildColumnsUpdateFragment(t *testing.T) {
func TestBuildProcessToastStructColExpression(t *testing.T) {
assert.Equal(t, `CASE WHEN COALESCE(cc.foo != JSON_PARSE('{"key":"__debezium_unavailable_value"}'), true) THEN cc.foo ELSE c.foo END`, sql.RedshiftDialect{}.BuildProcessToastStructColExpression("foo"))
assert.Equal(t, `CASE WHEN COALESCE(TO_JSON_STRING(cc.foo) != '{"key":"__debezium_unavailable_value"}', true) THEN cc.foo ELSE c.foo END`, sql.BigQueryDialect{}.BuildProcessToastStructColExpression("foo"))
assert.Equal(t, `CASE WHEN COALESCE(cc.foo != {'key': '__debezium_unavailable_value'}, true) THEN cc.foo ELSE c.foo END`, dialect.SnowflakeDialect{}.BuildProcessToastStructColExpression("foo"))
assert.Equal(t, `CASE WHEN COALESCE(cc.foo != {'key': '__debezium_unavailable_value'}, true) THEN cc.foo ELSE c.foo END`, snowflakeDialect.SnowflakeDialect{}.BuildProcessToastStructColExpression("foo"))
assert.Equal(t, `CASE WHEN COALESCE(cc.foo, {}) != {'key': '__debezium_unavailable_value'} THEN cc.foo ELSE c.foo END`, sql.MSSQLDialect{}.BuildProcessToastStructColExpression("foo"))
}

func TestProcessToastCol(t *testing.T) {
assert.Equal(t, `CASE WHEN COALESCE(cc.bar != '__debezium_unavailable_value', true) THEN cc.bar ELSE c.bar END`, processToastCol("bar", sql.RedshiftDialect{}))
assert.Equal(t, `CASE WHEN COALESCE(cc.bar != '__debezium_unavailable_value', true) THEN cc.bar ELSE c.bar END`, processToastCol("bar", sql.BigQueryDialect{}))
assert.Equal(t, `CASE WHEN COALESCE(cc.bar != '__debezium_unavailable_value', true) THEN cc.bar ELSE c.bar END`, processToastCol("bar", dialect.SnowflakeDialect{}))
assert.Equal(t, `CASE WHEN COALESCE(cc.bar != '__debezium_unavailable_value', true) THEN cc.bar ELSE c.bar END`, processToastCol("bar", snowflakeDialect.SnowflakeDialect{}))
assert.Equal(t, `CASE WHEN COALESCE(cc.bar, '') != '__debezium_unavailable_value' THEN cc.bar ELSE c.bar END`, processToastCol("bar", sql.MSSQLDialect{}))
}
14 changes: 7 additions & 7 deletions lib/destination/dml/merge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (

"github.com/stretchr/testify/assert"

"github.com/artie-labs/transfer/clients/snowflake/dialect"
snowflakeDialect "github.com/artie-labs/transfer/clients/snowflake/dialect"
"github.com/artie-labs/transfer/lib/config/constants"
"github.com/artie-labs/transfer/lib/mocks"
"github.com/artie-labs/transfer/lib/sql"
Expand Down Expand Up @@ -49,7 +49,7 @@ func TestMergeStatementSoftDelete(t *testing.T) {
IdempotentKey: idempotentKey,
PrimaryKeys: []columns.Column{columns.NewColumn("id", typing.Invalid)},
Columns: _cols.ValidColumns(),
Dialect: dialect.SnowflakeDialect{},
Dialect: snowflakeDialect.SnowflakeDialect{},
SoftDelete: true,
}

Expand Down Expand Up @@ -99,7 +99,7 @@ func TestMergeStatement(t *testing.T) {
IdempotentKey: "",
PrimaryKeys: []columns.Column{columns.NewColumn("id", typing.Invalid)},
Columns: _cols.ValidColumns(),
Dialect: dialect.SnowflakeDialect{},
Dialect: snowflakeDialect.SnowflakeDialect{},
SoftDelete: false,
}

Expand Down Expand Up @@ -148,7 +148,7 @@ func TestMergeStatementIdempotentKey(t *testing.T) {
IdempotentKey: "updated_at",
PrimaryKeys: []columns.Column{columns.NewColumn("id", typing.Invalid)},
Columns: _cols.ValidColumns(),
Dialect: dialect.SnowflakeDialect{},
Dialect: snowflakeDialect.SnowflakeDialect{},
SoftDelete: false,
}

Expand Down Expand Up @@ -194,7 +194,7 @@ func TestMergeStatementCompositeKey(t *testing.T) {
columns.NewColumn("another_id", typing.Invalid),
},
Columns: _cols.ValidColumns(),
Dialect: dialect.SnowflakeDialect{},
Dialect: snowflakeDialect.SnowflakeDialect{},
SoftDelete: false,
}

Expand Down Expand Up @@ -244,7 +244,7 @@ func TestMergeStatementEscapePrimaryKeys(t *testing.T) {
columns.NewColumn("group", typing.Invalid),
},
Columns: _cols.ValidColumns(),
Dialect: dialect.SnowflakeDialect{},
Dialect: snowflakeDialect.SnowflakeDialect{},
SoftDelete: false,
}

Expand Down Expand Up @@ -366,7 +366,7 @@ func TestMergeArgument_BuildRedshiftDeleteQuery(t *testing.T) {

func TestMergeArgument_BuildStatements_Validation(t *testing.T) {
for _, arg := range []*MergeArgument{
{Dialect: dialect.SnowflakeDialect{}},
{Dialect: snowflakeDialect.SnowflakeDialect{}},
{Dialect: sql.BigQueryDialect{}},
} {
parts, err := arg.BuildStatements()
Expand Down
4 changes: 2 additions & 2 deletions lib/typing/columns/default_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"testing"
"time"

"github.com/artie-labs/transfer/clients/snowflake/dialect"
snowflakeDialect "github.com/artie-labs/transfer/clients/snowflake/dialect"
"github.com/artie-labs/transfer/lib/sql"

"github.com/artie-labs/transfer/lib/typing/ext"
Expand All @@ -18,7 +18,7 @@ import (
var dialects = []sql.Dialect{
sql.BigQueryDialect{},
sql.RedshiftDialect{},
dialect.SnowflakeDialect{},
snowflakeDialect.SnowflakeDialect{},
}

func TestColumn_DefaultValue(t *testing.T) {
Expand Down

0 comments on commit 9e49284

Please sign in to comment.