Skip to content

Commit

Permalink
feat: add array data type support for legacy mappings in snowflake (#123
Browse files Browse the repository at this point in the history
)
  • Loading branch information
AchuthaSourabhC authored Jul 8, 2024
1 parent 8478198 commit b564a72
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"errors"
"fmt"
"os"
"reflect"
"strings"
"sync"
"testing"
Expand Down Expand Up @@ -517,6 +518,9 @@ func TestDatabaseScenarios(t *testing.T, warehouse string, configJSON json.RawMe
require.Truef(t, ok, "column of type datetime should be parsed as a datetime %q: %v", col.Name, actualRow[col.Name])
_, err := time.Parse(time.RFC3339, datetime)
require.NoErrorf(t, err, "column of type datetime should be a RFC3339 string %q: %v", col.Name, actualRow[col.Name])
case "array":
require.Truef(t, reflect.TypeOf(actualRow[col.Name]).Kind() == reflect.Slice, "column of type array should be a slice %q: %v", col.Name, actualRow[col.Name])

case "json":
// this can be anything
default:
Expand Down
1 change: 1 addition & 0 deletions sqlconnect/internal/snowflake/legacy_mappings.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ func legacyColumnTypeMapper(columnType base.ColumnType) string {
"TIMESTAMP_LTZ": "datetime",
"TIMESTAMP_TZ": "datetime",
"VARIANT": "json",
"ARRAY": "array",
}
databaseTypeName := strings.ToUpper(re.ReplaceAllString(columnType.DatabaseTypeName(), ""))
if mappedType, ok := columnTypeMappings[strings.ToUpper(databaseTypeName)]; ok {
Expand Down
2 changes: 1 addition & 1 deletion sqlconnect/internal/snowflake/mappings.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ var columnTypeMappings = map[string]string{
"TIMESTAMP_TZ": "datetime",
"VARIANT": "json",
"OBJECT": "json",
"ARRAY": "json",
"ARRAY": "array",
}

var (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
"_TIMESTAMPTZ": "datetime",
"_VARIANT": "json",
"_OBJECT": "json",
"_ARRAY": "json"
"_ARRAY": "array"
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
"_TIMESTAMPTZ": "datetime",
"_VARIANT": "json",
"_OBJECT": "OBJECT",
"_ARRAY": "ARRAY"
"_ARRAY": "array"
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@
"_TIMESTAMPTZ": "datetime",
"_VARIANT": "json",
"_OBJECT": "OBJECT",
"_ARRAY": "ARRAY"
"_ARRAY": "array"
}

0 comments on commit b564a72

Please sign in to comment.