@@ -48,14 +48,16 @@ private static ClickHouseColumn update(ClickHouseColumn column) {
4848 column .precision = column .dataType .getMaxPrecision ();
4949 switch (column .dataType ) {
5050 case Array :
51- column .arrayLevel = 1 ;
52- column .arrayBaseColumn = column .nested .get (0 );
53- while (column .arrayLevel < 255 ) {
54- if (column .arrayBaseColumn .dataType == ClickHouseDataType .Array ) {
55- column .arrayLevel ++;
56- column .arrayBaseColumn = column .arrayBaseColumn .nested .get (0 );
57- } else {
58- break ;
51+ if (!column .nested .isEmpty ()) {
52+ column .arrayLevel = 1 ;
53+ column .arrayBaseColumn = column .nested .get (0 );
54+ while (column .arrayLevel < 255 ) {
55+ if (column .arrayBaseColumn .dataType == ClickHouseDataType .Array ) {
56+ column .arrayLevel ++;
57+ column .arrayBaseColumn = column .arrayBaseColumn .nested .get (0 );
58+ } else {
59+ break ;
60+ }
5961 }
6062 }
6163 break ;
@@ -101,10 +103,14 @@ private static ClickHouseColumn update(ClickHouseColumn column) {
101103 case Decimal64 :
102104 case Decimal128 :
103105 case Decimal256 :
104- column .scale = Integer .parseInt (column .parameters .get (0 ));
106+ if (size > 0 ) {
107+ column .scale = Integer .parseInt (column .parameters .get (0 ));
108+ }
105109 break ;
106110 case FixedString :
107- column .precision = Integer .parseInt (column .parameters .get (0 ));
111+ if (size > 0 ) {
112+ column .precision = Integer .parseInt (column .parameters .get (0 ));
113+ }
108114 break ;
109115 default :
110116 break ;
@@ -307,13 +313,14 @@ public static ClickHouseColumn of(String columnName, ClickHouseDataType dataType
307313
308314 public static ClickHouseColumn of (String columnName , ClickHouseDataType dataType , boolean nullable ,
309315 boolean lowCardinality , String ... parameters ) {
310- return new ClickHouseColumn (dataType , columnName , null , nullable , lowCardinality , Arrays . asList ( parameters ) ,
311- null );
316+ return update ( new ClickHouseColumn (dataType , columnName , null , nullable , lowCardinality ,
317+ Arrays . asList ( parameters ), null ) );
312318 }
313319
314320 public static ClickHouseColumn of (String columnName , ClickHouseDataType dataType , boolean nullable ,
315321 ClickHouseColumn ... nestedColumns ) {
316- return new ClickHouseColumn (dataType , columnName , null , nullable , false , null , Arrays .asList (nestedColumns ));
322+ return update (
323+ new ClickHouseColumn (dataType , columnName , null , nullable , false , null , Arrays .asList (nestedColumns )));
317324 }
318325
319326 public static ClickHouseColumn of (String columnName , String columnType ) {
0 commit comments