99import com .clickhouse .jdbc .types .Array ;
1010import com .google .common .collect .ImmutableMap ;
1111
12- import java .math .BigInteger ;
1312import java .net .Inet4Address ;
1413import java .net .Inet6Address ;
1514import java .net .InetAddress ;
@@ -44,9 +43,9 @@ public class JdbcUtils {
4443
4544 public static final Map <String , SQLType > CLICKHOUSE_TYPE_NAME_TO_SQL_TYPE_MAP = Collections .unmodifiableMap (generateTypeMap ().entrySet ()
4645 .stream ().collect (
47- HashMap ::new ,
48- (map , entry ) -> map .put (entry .getKey ().name (), entry .getValue ()),
49- HashMap ::putAll
46+ HashMap ::new ,
47+ (map , entry ) -> map .put (entry .getKey ().name (), entry .getValue ()),
48+ HashMap ::putAll
5049 ));
5150
5251 private static Map <ClickHouseDataType , SQLType > generateTypeMap () {
@@ -55,14 +54,14 @@ private static Map<ClickHouseDataType, SQLType> generateTypeMap() {
5554 map .put (ClickHouseDataType .Int16 , JDBCType .SMALLINT );
5655 map .put (ClickHouseDataType .Int32 , JDBCType .INTEGER );
5756 map .put (ClickHouseDataType .Int64 , JDBCType .BIGINT );
58- map .put (ClickHouseDataType .Int128 , JDBCType .OTHER );
59- map .put (ClickHouseDataType .Int256 , JDBCType .OTHER );
57+ map .put (ClickHouseDataType .Int128 , JDBCType .NUMERIC );
58+ map .put (ClickHouseDataType .Int256 , JDBCType .NUMERIC );
6059 map .put (ClickHouseDataType .UInt8 , JDBCType .SMALLINT );
6160 map .put (ClickHouseDataType .UInt16 , JDBCType .INTEGER );
6261 map .put (ClickHouseDataType .UInt32 , JDBCType .BIGINT );
63- map .put (ClickHouseDataType .UInt64 , JDBCType .OTHER );
64- map .put (ClickHouseDataType .UInt128 , JDBCType .OTHER );
65- map .put (ClickHouseDataType .UInt256 , JDBCType .OTHER );
62+ map .put (ClickHouseDataType .UInt64 , JDBCType .NUMERIC );
63+ map .put (ClickHouseDataType .UInt128 , JDBCType .NUMERIC );
64+ map .put (ClickHouseDataType .UInt256 , JDBCType .NUMERIC );
6665 map .put (ClickHouseDataType .Float32 , JDBCType .FLOAT );
6766 map .put (ClickHouseDataType .Float64 , JDBCType .DOUBLE );
6867 map .put (ClickHouseDataType .BFloat16 , JDBCType .FLOAT );
@@ -130,7 +129,7 @@ private static Map<SQLType, Class<?>> generateClassMap() {
130129 map .put (JDBCType .CHAR , String .class );
131130 map .put (JDBCType .VARCHAR , String .class );
132131 map .put (JDBCType .LONGVARCHAR , String .class );
133- map .put (JDBCType .NUMERIC , java .math .BigDecimal .class );
132+ map .put (JDBCType .NUMERIC , java .math .BigInteger .class );
134133 map .put (JDBCType .DECIMAL , java .math .BigDecimal .class );
135134 map .put (JDBCType .BIT , Boolean .class );
136135 map .put (JDBCType .BOOLEAN , Boolean .class );
@@ -173,21 +172,6 @@ private static Map<ClickHouseDataType, Class<?>> getDataTypeClassMap() {
173172 for (Map .Entry <ClickHouseDataType , SQLType > e : CLICKHOUSE_TO_SQL_TYPE_MAP .entrySet ()) {
174173 if (e .getValue ().equals (JDBCType .OTHER )) {
175174 switch (e .getKey ()) {
176- case UInt64 :
177- map .put (e .getKey (), BigInteger .class );
178- break ;
179- case UInt128 :
180- map .put (e .getKey (), BigInteger .class );
181- break ;
182- case UInt256 :
183- map .put (e .getKey (), BigInteger .class );
184- break ;
185- case Int128 :
186- map .put (e .getKey (), BigInteger .class );
187- break ;
188- case Int256 :
189- map .put (e .getKey (), BigInteger .class );
190- break ;
191175 case Point :
192176 map .put (e .getKey (), double [].class );
193177 break ;
@@ -361,6 +345,8 @@ static Object convertObject(Object value, Class<?> type, ClickHouseColumn column
361345 return Double .parseDouble (value .toString ());
362346 } else if (type == java .math .BigDecimal .class ) {
363347 return new java .math .BigDecimal (value .toString ());
348+ } else if (type == java .math .BigInteger .class ) {
349+ return new java .math .BigInteger (value .toString ());
364350 } else if (type == Duration .class && value instanceof LocalDateTime ) {
365351 return DataTypeUtils .localDateTimeToDuration ((LocalDateTime ) value );
366352 } else if (value instanceof TemporalAccessor ) {
0 commit comments