@@ -169,15 +169,49 @@ 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 null ; // Return null if no valid value set
198+ }
199+
200+ private static <T > List <T > getColumnValuesWithNulls (List <T > values , byte [] nulls ) {
201+ List <T > result = new ArrayList <>();
202+ if (nulls != null ) {
203+ BitSet nullBits = BitSet .valueOf (nulls );
204+ for (int i = 0 ; i < values .size (); i ++) {
205+ if (nullBits .get (i )) {
206+ result .add (null ); // Add null if the value is null
207+ } else {
208+ result .add (values .get (i ));
209+ }
210+ }
211+ } else {
212+ result .addAll (values );
213+ }
214+ return result ;
181215 }
182216
183217 /**
0 commit comments