Skip to content

Commit 271dd9c

Browse files
committed
Fix UUID test scaffolding for CI
1 parent ee9f0b8 commit 271dd9c

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

pinot-core/src/test/java/org/apache/pinot/core/common/datablock/DataBlockTestUtils.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,13 @@
2424
import java.util.List;
2525
import java.util.Map;
2626
import java.util.Random;
27+
import java.util.UUID;
2728
import org.apache.commons.lang3.RandomStringUtils;
2829
import org.apache.pinot.common.datablock.DataBlock;
2930
import org.apache.pinot.common.utils.DataSchema;
3031
import org.apache.pinot.common.utils.DataSchema.ColumnDataType;
3132
import org.apache.pinot.spi.utils.ByteArray;
33+
import org.apache.pinot.spi.utils.UuidUtils;
3234
import org.roaringbitmap.RoaringBitmap;
3335

3436

@@ -73,6 +75,9 @@ public static Object[] getRandomRow(DataSchema dataSchema, int nullPercentile) {
7375
case BYTES:
7476
row[colId] = new ByteArray(RandomStringUtils.random(RANDOM.nextInt(20)).getBytes());
7577
break;
78+
case UUID:
79+
row[colId] = new ByteArray(UuidUtils.toBytes(new UUID(RANDOM.nextLong(), RANDOM.nextLong())));
80+
break;
7681
case INT_ARRAY:
7782
int length = RANDOM.nextInt(ARRAY_SIZE);
7883
int[] intArray = new int[length];

pinot-core/src/test/java/org/apache/pinot/core/common/datatable/DataTableSerDeTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.HashMap;
2525
import java.util.Map;
2626
import java.util.Random;
27+
import java.util.UUID;
2728
import org.apache.commons.lang3.RandomStringUtils;
2829
import org.apache.commons.lang3.StringUtils;
2930
import org.apache.pinot.common.datatable.DataTable;
@@ -33,6 +34,7 @@
3334
import org.apache.pinot.spi.accounting.ThreadResourceUsageProvider;
3435
import org.apache.pinot.spi.exception.QueryErrorCode;
3536
import org.apache.pinot.spi.utils.ByteArray;
37+
import org.apache.pinot.spi.utils.UuidUtils;
3638
import org.roaringbitmap.RoaringBitmap;
3739
import org.testng.Assert;
3840
import 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;

pinot-core/src/test/java/org/apache/pinot/core/data/manager/TableIndexingTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,10 @@ private void readExpectedResults()
159159

160160
protected void createSchemas() {
161161
for (DataType type : DataType.values()) {
162-
if (type == DataType.UNKNOWN || type == DataType.LIST || type == DataType.MAP || type == DataType.STRUCT) {
162+
if (type == DataType.UNKNOWN || type == DataType.LIST || type == DataType.MAP || type == DataType.STRUCT
163+
|| type == DataType.UUID) {
164+
// UUID v1 is SV-only and its supported behavior is covered by dedicated UUID tests rather than this static
165+
// all-type/all-index expectation matrix.
163166
continue;
164167
}
165168

0 commit comments

Comments
 (0)