2424import java .util .HashMap ;
2525import java .util .Map ;
2626import java .util .Random ;
27+ import java .util .UUID ;
2728import org .apache .commons .lang3 .RandomStringUtils ;
2829import org .apache .commons .lang3 .StringUtils ;
2930import org .apache .pinot .common .datatable .DataTable ;
3334import org .apache .pinot .spi .accounting .ThreadResourceUsageProvider ;
3435import org .apache .pinot .spi .exception .QueryErrorCode ;
3536import org .apache .pinot .spi .utils .ByteArray ;
37+ import org .apache .pinot .spi .utils .UuidUtils ;
3638import org .roaringbitmap .RoaringBitmap ;
3739import org .testng .Assert ;
3840import org .testng .annotations .DataProvider ;
@@ -59,6 +61,7 @@ public class DataTableSerDeTest {
5961 private static final String [] STRINGS = new String [NUM_ROWS ];
6062 private static final String [] JSONS = new String [NUM_ROWS ];
6163 private static final byte [][] BYTES = new byte [NUM_ROWS ][];
64+ private static final byte [][] UUIDS = new byte [NUM_ROWS ][];
6265 private static final Object [] OBJECTS = new Object [NUM_ROWS ];
6366 private static final int [][] INT_ARRAYS = new int [NUM_ROWS ][];
6467 private static final long [][] LONG_ARRAYS = new long [NUM_ROWS ][];
@@ -364,6 +367,11 @@ private void fillDataTableWithRandomData(DataTableBuilder dataTableBuilder,
364367 BYTES [rowId ] = isNull ? new byte [0 ] : RandomStringUtils .random (RANDOM .nextInt (20 )).getBytes ();
365368 dataTableBuilder .setColumn (colId , new ByteArray (BYTES [rowId ]));
366369 break ;
370+ case UUID :
371+ UUIDS [rowId ] = isNull ? UuidUtils .NIL_UUID_BYTES .clone ()
372+ : UuidUtils .toBytes (new UUID (RANDOM .nextLong (), RANDOM .nextLong ()));
373+ dataTableBuilder .setColumn (colId , new ByteArray (UUIDS [rowId ]));
374+ break ;
367375 case INT_ARRAY :
368376 int length = RANDOM .nextInt (20 );
369377 int [] intArray = new int [length ];
@@ -501,6 +509,10 @@ private void verifyDataIsSame(DataTable newDataTable, DataSchema.ColumnDataType[
501509 Assert .assertEquals (newDataTable .getBytes (rowId , colId ).getBytes (), isNull ? new byte [0 ] : BYTES [rowId ],
502510 ERROR_MESSAGE );
503511 break ;
512+ case UUID :
513+ Assert .assertEquals (newDataTable .getBytes (rowId , colId ).getBytes (),
514+ isNull ? UuidUtils .NIL_UUID_BYTES : UUIDS [rowId ], ERROR_MESSAGE );
515+ break ;
504516 case INT_ARRAY :
505517 Assert .assertTrue (Arrays .equals (newDataTable .getIntArray (rowId , colId ), INT_ARRAYS [rowId ]), ERROR_MESSAGE );
506518 break ;
0 commit comments