in go/adbc/driver/snowflake/statement.go [121:168]
func toSnowflakeType(dt arrow.DataType) string {
switch dt.ID() {
case arrow.EXTENSION:
return toSnowflakeType(dt.(arrow.ExtensionType).StorageType())
case arrow.DICTIONARY:
return toSnowflakeType(dt.(*arrow.DictionaryType).ValueType)
case arrow.RUN_END_ENCODED:
return toSnowflakeType(dt.(*arrow.RunEndEncodedType).Encoded())
case arrow.INT8, arrow.INT16, arrow.INT32, arrow.INT64,
arrow.UINT8, arrow.UINT16, arrow.UINT32, arrow.UINT64:
return "integer"
case arrow.FLOAT32, arrow.FLOAT16, arrow.FLOAT64:
return "double"
case arrow.DECIMAL, arrow.DECIMAL256:
dec := dt.(arrow.DecimalType)
return fmt.Sprintf("NUMERIC(%d,%d)", dec.GetPrecision(), dec.GetScale())
case arrow.STRING, arrow.LARGE_STRING:
return "text"
case arrow.BINARY, arrow.LARGE_BINARY:
return "binary"
case arrow.FIXED_SIZE_BINARY:
fsb := dt.(*arrow.FixedSizeBinaryType)
return fmt.Sprintf("binary(%d)", fsb.ByteWidth)
case arrow.BOOL:
return "boolean"
case arrow.TIME32, arrow.TIME64:
t := dt.(arrow.TemporalWithUnit)
prec := int(t.TimeUnit()) * 3
return fmt.Sprintf("time(%d)", prec)
case arrow.DATE32, arrow.DATE64:
return "date"
case arrow.TIMESTAMP:
ts := dt.(*arrow.TimestampType)
prec := int(ts.Unit) * 3
if ts.TimeZone == "" {
return fmt.Sprintf("timestamp_ntz(%d)", prec)
}
return fmt.Sprintf("timestamp_tz(%d)", prec)
case arrow.DENSE_UNION, arrow.SPARSE_UNION:
return "variant"
case arrow.LIST, arrow.LARGE_LIST, arrow.FIXED_SIZE_LIST:
return "array"
case arrow.STRUCT, arrow.MAP:
return "object"
}
return ""
}