-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ffee7ae
commit 0ccab91
Showing
22 changed files
with
1,145 additions
and
993 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1,887 changes: 947 additions & 940 deletions
1,887
integration_test/snowpipestreaming/snowpipestreaming_test.go
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
router/batchrouter/asyncdestinationmanager/snowpipestreaming/snowpipestreaming_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package snowpipestreaming | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
|
||
whutils "github.com/rudderlabs/rudder-server/warehouse/utils" | ||
) | ||
|
||
func TestFindNewColumns(t *testing.T) { | ||
tests := []struct { | ||
name string | ||
eventSchema whutils.ModelTableSchema | ||
snowPipeSchema whutils.ModelTableSchema | ||
expected []whutils.ColumnInfo | ||
}{ | ||
{ | ||
name: "new column with different data type in event schema", | ||
eventSchema: whutils.ModelTableSchema{ | ||
"new_column": "STRING", | ||
"existing_column": "FLOAT", | ||
}, | ||
snowPipeSchema: whutils.ModelTableSchema{ | ||
"existing_column": "INT", | ||
}, | ||
expected: []whutils.ColumnInfo{ | ||
{Name: "new_column", Type: "STRING"}, | ||
}, | ||
}, | ||
{ | ||
name: "new and existing columns with multiple data types", | ||
eventSchema: whutils.ModelTableSchema{ | ||
"new_column1": "STRING", | ||
"new_column2": "BOOLEAN", | ||
"existing_column": "INT", | ||
}, | ||
snowPipeSchema: whutils.ModelTableSchema{ | ||
"existing_column": "INT", | ||
"another_existing_column": "FLOAT", | ||
}, | ||
expected: []whutils.ColumnInfo{ | ||
{Name: "new_column1", Type: "STRING"}, | ||
{Name: "new_column2", Type: "BOOLEAN"}, | ||
}, | ||
}, | ||
{ | ||
name: "all columns in event schema are new", | ||
eventSchema: whutils.ModelTableSchema{ | ||
"new_column1": "STRING", | ||
"new_column2": "BOOLEAN", | ||
"new_column3": "FLOAT", | ||
}, | ||
snowPipeSchema: whutils.ModelTableSchema{}, | ||
expected: []whutils.ColumnInfo{ | ||
{Name: "new_column1", Type: "STRING"}, | ||
{Name: "new_column2", Type: "BOOLEAN"}, | ||
{Name: "new_column3", Type: "FLOAT"}, | ||
}, | ||
}, | ||
{ | ||
name: "case sensitivity check", | ||
eventSchema: whutils.ModelTableSchema{ | ||
"ColumnA": "STRING", | ||
"columna": "BOOLEAN", | ||
}, | ||
snowPipeSchema: whutils.ModelTableSchema{ | ||
"columna": "BOOLEAN", | ||
}, | ||
expected: []whutils.ColumnInfo{ | ||
{Name: "ColumnA", Type: "STRING"}, | ||
}, | ||
}, | ||
{ | ||
name: "all columns match with identical types", | ||
eventSchema: whutils.ModelTableSchema{ | ||
"existing_column1": "STRING", | ||
"existing_column2": "FLOAT", | ||
}, | ||
snowPipeSchema: whutils.ModelTableSchema{ | ||
"existing_column1": "STRING", | ||
"existing_column2": "FLOAT", | ||
}, | ||
expected: []whutils.ColumnInfo{}, | ||
}, | ||
{ | ||
name: "event schema is empty, SnowPipe schema has columns", | ||
eventSchema: whutils.ModelTableSchema{}, | ||
snowPipeSchema: whutils.ModelTableSchema{ | ||
"existing_column": "STRING", | ||
}, | ||
expected: []whutils.ColumnInfo{}, | ||
}, | ||
{ | ||
name: "SnowPipe schema is nil", | ||
eventSchema: whutils.ModelTableSchema{ | ||
"new_column": "STRING", | ||
}, | ||
snowPipeSchema: nil, | ||
expected: []whutils.ColumnInfo{ | ||
{Name: "new_column", Type: "STRING"}, | ||
}, | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Run(tt.name, func(t *testing.T) { | ||
result := findNewColumns(tt.eventSchema, tt.snowPipeSchema) | ||
assert.ElementsMatch(t, tt.expected, result) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.