(t string)
| 85 | } |
| 86 | |
| 87 | func duckDBToArrow(t string) arrow.DataType { |
| 88 | switch { |
| 89 | case strings.HasSuffix(t, "[]"): |
| 90 | return arrow.ListOf(duckDBToArrow(strings.TrimSuffix(t, "[]"))) |
| 91 | case strings.HasPrefix(t, "struct"): |
| 92 | return duckDBStructToArrow(t) |
| 93 | case strings.HasPrefix(t, "map"): |
| 94 | return duckDBMapToArrow(t) |
| 95 | } |
| 96 | |
| 97 | switch t { |
| 98 | case "tinyint", "int1": |
| 99 | return arrow.PrimitiveTypes.Int8 |
| 100 | case "smallint", "int2", "short": |
| 101 | return arrow.PrimitiveTypes.Int16 |
| 102 | case "integer", "int4", "signed", "int": |
| 103 | return arrow.PrimitiveTypes.Int32 |
| 104 | case "bigint", "int8", "long": |
| 105 | return arrow.PrimitiveTypes.Int64 |
| 106 | case "utinyint": |
| 107 | return arrow.PrimitiveTypes.Uint8 |
| 108 | case "usmallint": |
| 109 | return arrow.PrimitiveTypes.Uint16 |
| 110 | case "uinteger", "uint4": |
| 111 | return arrow.PrimitiveTypes.Uint32 |
| 112 | case "ubigint": |
| 113 | return arrow.PrimitiveTypes.Uint64 |
| 114 | case "boolean", "bool", "logical": |
| 115 | return arrow.FixedWidthTypes.Boolean |
| 116 | case "double", "float8", "numeric", "decimal": |
| 117 | return arrow.PrimitiveTypes.Float64 |
| 118 | case "float", "float4", "real": |
| 119 | return arrow.PrimitiveTypes.Float32 |
| 120 | case "blob", "bytea", "binary", "varbinary": |
| 121 | return arrow.BinaryTypes.Binary |
| 122 | case "timestamp", "datetime", "timestamp with time zone", "timestamptz": |
| 123 | return arrow.FixedWidthTypes.Timestamp_us |
| 124 | case "json": |
| 125 | return types.ExtensionTypes.JSON |
| 126 | case "uuid": |
| 127 | return types.ExtensionTypes.UUID |
| 128 | default: |
| 129 | return arrow.BinaryTypes.String |
| 130 | } |
| 131 | } |
| 132 | |
| 133 | func duckDBStructToArrow(spec string) *arrow.StructType { |
| 134 | params := strings.TrimPrefix(spec, "struct") |
no test coverage detected