|
6 | 6 | import com.clickhouse.jdbc.types.Array; |
7 | 7 | import com.google.common.collect.ImmutableMap; |
8 | 8 |
|
| 9 | +import java.awt.*; |
| 10 | +import java.math.BigInteger; |
9 | 11 | import java.net.Inet4Address; |
10 | 12 | import java.net.Inet6Address; |
11 | 13 | import java.sql.Date; |
12 | 14 | import java.sql.JDBCType; |
13 | 15 | import java.sql.SQLException; |
14 | 16 | import java.sql.SQLType; |
| 17 | +import java.sql.Types; |
15 | 18 | import java.time.LocalDate; |
16 | 19 | import java.time.LocalDateTime; |
17 | 20 | import java.time.LocalTime; |
@@ -42,6 +45,14 @@ private static Map<ClickHouseDataType, SQLType> generateTypeMap() { |
42 | 45 | map.put(ClickHouseDataType.Int16, JDBCType.SMALLINT); |
43 | 46 | map.put(ClickHouseDataType.Int32, JDBCType.INTEGER); |
44 | 47 | map.put(ClickHouseDataType.Int64, JDBCType.BIGINT); |
| 48 | + map.put(ClickHouseDataType.Int128, JDBCType.OTHER); |
| 49 | + map.put(ClickHouseDataType.Int256, JDBCType.OTHER); |
| 50 | + map.put(ClickHouseDataType.UInt8, JDBCType.SMALLINT); |
| 51 | + map.put(ClickHouseDataType.UInt16, JDBCType.INTEGER); |
| 52 | + map.put(ClickHouseDataType.UInt32, JDBCType.BIGINT); |
| 53 | + map.put(ClickHouseDataType.UInt64, JDBCType.OTHER); |
| 54 | + map.put(ClickHouseDataType.UInt128, JDBCType.OTHER); |
| 55 | + map.put(ClickHouseDataType.UInt256, JDBCType.OTHER); |
45 | 56 | map.put(ClickHouseDataType.Float32, JDBCType.FLOAT); |
46 | 57 | map.put(ClickHouseDataType.Float64, JDBCType.DOUBLE); |
47 | 58 | map.put(ClickHouseDataType.Bool, JDBCType.BOOLEAN); |
@@ -81,8 +92,8 @@ private static Map<SQLType, Class<?>> generateClassMap() { |
81 | 92 | map.put(JDBCType.DECIMAL, java.math.BigDecimal.class); |
82 | 93 | map.put(JDBCType.BIT, Boolean.class); |
83 | 94 | map.put(JDBCType.BOOLEAN, Boolean.class); |
84 | | - map.put(JDBCType.TINYINT, Integer.class); |
85 | | - map.put(JDBCType.SMALLINT, Integer.class); |
| 95 | + map.put(JDBCType.TINYINT, Byte.class); |
| 96 | + map.put(JDBCType.SMALLINT, Short.class); |
86 | 97 | map.put(JDBCType.INTEGER, Integer.class); |
87 | 98 | map.put(JDBCType.BIGINT, Long.class); |
88 | 99 | map.put(JDBCType.REAL, Float.class); |
@@ -115,9 +126,44 @@ private static Map<SQLType, Class<?>> generateClassMap() { |
115 | 126 | private static Map<ClickHouseDataType, Class<?>> getDataTypeClassMap() { |
116 | 127 | Map<ClickHouseDataType, Class<?>> map = new HashMap<>(); |
117 | 128 | for (Map.Entry<ClickHouseDataType, SQLType> e : CLICKHOUSE_TO_SQL_TYPE_MAP.entrySet()) { |
118 | | - map.put(e.getKey(), SQL_TYPE_TO_CLASS_MAP.get(e.getValue())); |
| 129 | + if (e.getValue().equals(JDBCType.OTHER)) { |
| 130 | + switch (e.getKey()) { |
| 131 | + case UInt64: |
| 132 | + map.put(e.getKey(), BigInteger.class); |
| 133 | + break; |
| 134 | + case UInt128: |
| 135 | + map.put(e.getKey(), BigInteger.class); |
| 136 | + break; |
| 137 | + case UInt256: |
| 138 | + map.put(e.getKey(), BigInteger.class); |
| 139 | + break; |
| 140 | + case Int128: |
| 141 | + map.put(e.getKey(), BigInteger.class); |
| 142 | + break; |
| 143 | + case Int256: |
| 144 | + map.put(e.getKey(), BigInteger.class); |
| 145 | + break; |
| 146 | + case Point: |
| 147 | + map.put(e.getKey(), double[].class); |
| 148 | + break; |
| 149 | + case LineString: |
| 150 | + case Ring: |
| 151 | + map.put(e.getKey(), double[][].class); |
| 152 | + break; |
| 153 | + case Polygon: |
| 154 | + case MultiLineString: |
| 155 | + map.put(e.getKey(), double[][][].class); |
| 156 | + break; |
| 157 | + case MultiPolygon: |
| 158 | + map.put(e.getKey(), double[][][][].class); |
| 159 | + break; |
| 160 | + default: |
| 161 | + map.put(e.getKey(), Object.class); |
| 162 | + } |
| 163 | + } else { |
| 164 | + map.put(e.getKey(), SQL_TYPE_TO_CLASS_MAP.get(e.getValue())); |
| 165 | + } |
119 | 166 | } |
120 | | - |
121 | 167 | return map; |
122 | 168 | } |
123 | 169 |
|
|
0 commit comments