@@ -169,15 +169,50 @@ public static ColumnInfoTypeName getTypeFromTypeDesc(TTypeDesc typeDesc) {
169169 * @return a list of values from the specified column
170170 */
171171 private static List <?> getColumnValues (TColumn column ) {
172- // TODO : Handle complex data types
173- if (column .isSetBinaryVal ()) return column .getBinaryVal ().getValues ();
174- if (column .isSetBoolVal ()) return column .getBoolVal ().getValues ();
175- if (column .isSetByteVal ()) return column .getByteVal ().getValues ();
176- if (column .isSetDoubleVal ()) return column .getDoubleVal ().getValues ();
177- if (column .isSetI16Val ()) return column .getI16Val ().getValues ();
178- if (column .isSetI32Val ()) return column .getI32Val ().getValues ();
179- if (column .isSetI64Val ()) return column .getI64Val ().getValues ();
180- return column .getStringVal ().getValues (); // Default case
172+ // TODO: Add support for complex data types
173+ if (column .isSetBinaryVal ())
174+ return getColumnValuesWithNulls (
175+ column .getBinaryVal ().getValues (), column .getBinaryVal ().getNulls ());
176+ if (column .isSetBoolVal ())
177+ return getColumnValuesWithNulls (
178+ column .getBoolVal ().getValues (), column .getBoolVal ().getNulls ());
179+ if (column .isSetByteVal ())
180+ return getColumnValuesWithNulls (
181+ column .getByteVal ().getValues (), column .getByteVal ().getNulls ());
182+ if (column .isSetDoubleVal ())
183+ return getColumnValuesWithNulls (
184+ column .getDoubleVal ().getValues (), column .getDoubleVal ().getNulls ());
185+ if (column .isSetI16Val ())
186+ return getColumnValuesWithNulls (
187+ column .getI16Val ().getValues (), column .getI16Val ().getNulls ());
188+ if (column .isSetI32Val ())
189+ return getColumnValuesWithNulls (
190+ column .getI32Val ().getValues (), column .getI32Val ().getNulls ());
191+ if (column .isSetI64Val ())
192+ return getColumnValuesWithNulls (
193+ column .getI64Val ().getValues (), column .getI64Val ().getNulls ());
194+ if (column .isSetStringVal ())
195+ return getColumnValuesWithNulls (
196+ column .getStringVal ().getValues (), column .getStringVal ().getNulls ());
197+ return getColumnValuesWithNulls (
198+ column .getStringVal ().getValues (), column .getStringVal ().getNulls ()); // default to string
199+ }
200+
201+ private static <T > List <T > getColumnValuesWithNulls (List <T > values , byte [] nulls ) {
202+ List <T > result = new ArrayList <>();
203+ if (nulls != null ) {
204+ BitSet nullBits = BitSet .valueOf (nulls );
205+ for (int i = 0 ; i < values .size (); i ++) {
206+ if (nullBits .get (i )) {
207+ result .add (null ); // Add null if the value is null
208+ } else {
209+ result .add (values .get (i ));
210+ }
211+ }
212+ } else {
213+ result .addAll (values );
214+ }
215+ return result ;
181216 }
182217
183218 /**
0 commit comments