mqliang commented on a change in pull request #6710:
URL: https://github.com/apache/incubator-pinot/pull/6710#discussion_r604397222



##########
File path: 
pinot-core/src/test/java/org/apache/pinot/core/common/datatable/DataTableSerDeTest.java
##########
@@ -96,22 +99,130 @@ public void testAllDataTypes()
     for (int i = 0; i < numColumns; i++) {
       columnNames[i] = columnDataTypes[i].name();
     }
-    DataSchema dataSchema = new DataSchema(columnNames, columnDataTypes);
 
+    int[] ints = new int[NUM_ROWS];
+    long[] longs = new long[NUM_ROWS];
+    float[] floats = new float[NUM_ROWS];
+    double[] doubles = new double[NUM_ROWS];
+    String[] strings = new String[NUM_ROWS];
+    byte[][] bytes = new byte[NUM_ROWS][];
+    Object[] objects = new Object[NUM_ROWS];
+    int[][] intArrays = new int[NUM_ROWS][];
+    long[][] longArrays = new long[NUM_ROWS][];
+    float[][] floatArrays = new float[NUM_ROWS][];
+    double[][] doubleArrays = new double[NUM_ROWS][];
+    String[][] stringArrays = new String[NUM_ROWS][];
+
+    DataSchema dataSchema = new DataSchema(columnNames, columnDataTypes);
     DataTableBuilder dataTableBuilder = new DataTableBuilder(dataSchema);
+    fillDataTableWithRandomData(dataTableBuilder, columnDataTypes, numColumns, 
ints, longs, floats, doubles, strings,
+        bytes, objects, intArrays, longArrays, floatArrays, doubleArrays, 
stringArrays);
+
+    DataTable dataTable = dataTableBuilder.build();
+    DataTable newDataTable = 
DataTableFactory.getDataTable(dataTable.toBytes());
+    Assert.assertEquals(newDataTable.getDataSchema(), dataSchema, 
ERROR_MESSAGE);
+    Assert.assertEquals(newDataTable.getNumberOfRows(), NUM_ROWS, 
ERROR_MESSAGE);
+    verifyDataIsSame(newDataTable, columnDataTypes, numColumns, ints, longs, 
floats, doubles, strings, bytes, objects,
+        intArrays, longArrays, floatArrays, doubleArrays, stringArrays);
+  }
+
+  @Test
+  public void testV2V3Compatibility()
+      throws IOException {
+    DataSchema.ColumnDataType[] columnDataTypes = 
DataSchema.ColumnDataType.values();
+    int numColumns = columnDataTypes.length;
+    String[] columnNames = new String[numColumns];
+    for (int i = 0; i < numColumns; i++) {
+      columnNames[i] = columnDataTypes[i].name();
+    }
 
     int[] ints = new int[NUM_ROWS];
     long[] longs = new long[NUM_ROWS];
     float[] floats = new float[NUM_ROWS];
     double[] doubles = new double[NUM_ROWS];
     String[] strings = new String[NUM_ROWS];
+    byte[][] bytes = new byte[NUM_ROWS][];
     Object[] objects = new Object[NUM_ROWS];
     int[][] intArrays = new int[NUM_ROWS][];
     long[][] longArrays = new long[NUM_ROWS][];
     float[][] floatArrays = new float[NUM_ROWS][];
     double[][] doubleArrays = new double[NUM_ROWS][];
     String[][] stringArrays = new String[NUM_ROWS][];
 
+    DataSchema dataSchema = new DataSchema(columnNames, columnDataTypes);
+    DataTableBuilder.setCurrentDataTableVersion(DataTableBuilder.VERSION_2);
+    DataTableBuilder dataTableBuilderV2 = new DataTableBuilder(dataSchema);
+    fillDataTableWithRandomData(dataTableBuilderV2, columnDataTypes, 
numColumns, ints, longs, floats, doubles, strings,
+        bytes, objects, intArrays, longArrays, floatArrays, doubleArrays, 
stringArrays);
+
+    // Verify V3 broker can deserialize data table send by V2 server
+    DataTable dataTableV2 = dataTableBuilderV2.build(); // create a V2 data 
table
+    // Deserialize data table bytes as V3
+    DataTable newDataTable = 
DataTableFactory.getDataTable(dataTableV2.toBytes());
+    Assert.assertEquals(newDataTable.getDataSchema(), dataSchema, 
ERROR_MESSAGE);

Review comment:
       Oh, that's from previous implementation, where we have a convert to 
convert V2 to V3. Will change the comments here.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to