Skip to content

Commit

Permalink
feat(snowflake): add coverage for all common and many exotic Snowflak…
Browse files Browse the repository at this point in the history
…e data types (#95)

Co-authored-by: Scotty Pate <[email protected]>
  • Loading branch information
paulojblack and scottypate authored Nov 11, 2024
1 parent 62aca65 commit 5de778f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
1 change: 1 addition & 0 deletions internal/engine/columns.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ func processModelColumn(expr *sqlparser.AliasedExpr, cp *columnParser) error {
if _, ok := cp.columns[cp.tableName]; !ok {
cp.columns[cp.tableName] = make(map[ColumnName]Column)
}

col := Column{
TableName: &cp.tableName,
Position: cp.selectIdx,
Expand Down
8 changes: 5 additions & 3 deletions internal/engine/snowflake.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,19 @@ func processSnowflakeColumns(rows *sql.Rows) ([]any, error) {
valuePtrs[i] = new(duckdbDecimal)
case "BIGINT":
valuePtrs[i] = new(int64)
case "BOOLEAN":
valuePtrs[i] = new(bool)
case "INT", "MEDIUMINT":
valuePtrs[i] = new(int32)
case "SMALLINT", "YEAR":
valuePtrs[i] = new(int16)
case "TINYINT":
valuePtrs[i] = new(int8)
case "BIT", "BINARY", "VARBINARY", "TINYBLOB", "MEDIUMBLOB", "LONGBLOB", "BLOB":
case "BINARY", "VARBINARY", "VARIANT", "OBJECT", "ARRAY":
valuePtrs[i] = new([]byte)
case "DATE", "DATETIME", "TIMESTAMP", "TIMESTAMP_NTZ":
case "DATE", "DATETIME", "TIMESTAMP_TZ", "TIMESTAMP_LTZ", "TIMESTAMP_NTZ":
valuePtrs[i] = new(time.Time)
case "CHAR", "VARCHAR", "TEXT", "TINYTEXT", "MEDIUMTEXT", "LONGTEXT", "ENUM", "SET", "JSON", "TIME":
case "CHAR", "CHARACTER", "NCHAR", "VARCHAR", "TEXT", "STRING", "NVARCHAR", "NVARCHAR2", "CHAR VARYING", "NCHAR VARYING", "ENUM", "SET", "JSON", "TIME":
Debug(fmt.Sprintf("Column type is a string: %s", columnType.DatabaseTypeName()))
valuePtrs[i] = new(string)
default:
Expand Down
4 changes: 4 additions & 0 deletions internal/engine/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ var duckdbTypeMap = map[string]string{
"date": "date",
"timestamp": "timestamp",
"datetime": "timestamp",
"timestamp_tz": "timestamp", //snowflake
"timestamp_ltz": "timestamp", //snowflake
"timestamp_ntz": "timestamp", //snowflake
"timestamp without time zone": "timestamp",
"timestamp with time zone": "timestamp",
Expand All @@ -225,6 +227,8 @@ var duckdbTypeMap = map[string]string{
"mediumblob": "blob",
"longblob": "blob",
"bytea": "blob",
"variant": "blob", // snowflake
"object": "json", // snowflake
"json": "json",
"jsonb": "json",
"inet": "varchar",
Expand Down

0 comments on commit 5de778f

Please sign in to comment.