siddharthteotia commented on code in PR #8993:
URL: https://github.com/apache/pinot/pull/8993#discussion_r910680710


##########
pinot-core/src/test/java/org/apache/pinot/queries/MultiValueRawQueriesTest.java:
##########
@@ -338,6 +338,445 @@ public void testSelectQueries() {
     }
   }
 
+  @Test
+  public void testNonAggregateMVGroupBY() {
+    {
+      // TODO: Today ORDER BY on MV columns (irrespective of whether it's 
dictionary based or raw) doesn't work
+      //       Fix ORDER BY only for MV columns
+      String query = "SELECT mvFloatCol from testTable WHERE mvFloatCol < 5 
ORDER BY mvFloatCol LIMIT 10";
+      BrokerResponseNative brokerResponseNative = getBrokerResponse(query);
+      assertEquals(brokerResponseNative.getProcessingExceptions().size(), 2);
+    }
+    {
+      // Test a group by query on some raw MV rows. Order by on SV column 
added for determinism
+      String query = "SELECT svIntCol, mvRawFloatCol, mvRawDoubleCol, 
mvRawStringCol from testTable GROUP BY "
+          + "svIntCol, mvRawFloatCol, mvRawDoubleCol, mvRawStringCol ORDER BY 
svIntCol LIMIT 10";
+      ResultTable resultTable = getBrokerResponse(query).getResultTable();
+      assertNotNull(resultTable);
+      DataSchema dataSchema = new DataSchema(new String[]{
+          "svIntCol", "mvRawFloatCol", "mvRawDoubleCol", "mvRawStringCol"
+      }, new DataSchema.ColumnDataType[]{
+          DataSchema.ColumnDataType.INT, DataSchema.ColumnDataType.FLOAT, 
DataSchema.ColumnDataType.DOUBLE,
+          DataSchema.ColumnDataType.STRING
+      });
+      assertEquals(resultTable.getDataSchema(), dataSchema);
+      List<Object[]> recordRows = resultTable.getRows();
+      assertEquals(recordRows.size(), 10);
+
+      int[] expectedSVInts = new int[]{0, 0, 0, 0, 0, 0, 0, 0, 1, 1};
+
+      for (int i = 0; i < 10; i++) {
+        Object[] values = recordRows.get(i);
+        assertEquals(values.length, 4);
+        assertEquals((int) values[0], expectedSVInts[i]);
+      }
+    }
+    {
+      // Test a group by order by query on some raw MV rows (order by on int 
and double)
+      String query = "SELECT mvRawIntCol, mvRawDoubleCol, mvRawStringCol from 
testTable GROUP BY mvRawIntCol, "
+          + "mvRawDoubleCol, mvRawStringCol ORDER BY mvRawIntCol, 
mvRawDoubleCol LIMIT 20";
+      ResultTable resultTable = getBrokerResponse(query).getResultTable();
+      assertNotNull(resultTable);
+      DataSchema dataSchema = new DataSchema(new String[]{
+          "mvRawIntCol", "mvRawDoubleCol", "mvRawStringCol"
+      }, new DataSchema.ColumnDataType[]{
+          DataSchema.ColumnDataType.INT, DataSchema.ColumnDataType.DOUBLE, 
DataSchema.ColumnDataType.STRING
+      });
+      assertEquals(resultTable.getDataSchema(), dataSchema);
+      List<Object[]> recordRows = resultTable.getRows();
+      assertEquals(recordRows.size(), 20);
+
+      int intValue = -1;
+      double doubleValue = -1;
+      for (int i = 0; i < 20; i++) {
+        Object[] values = recordRows.get(i);
+        assertEquals(values.length, 3);
+        int intValueCur = (int) values[0];
+        double doubleValueCur = (double) values[1];
+        assertTrue(intValueCur >= intValue);
+        if (intValueCur == intValue) {
+          assertTrue(doubleValueCur >= doubleValue);
+        }
+
+        intValue = intValueCur;
+        doubleValue = doubleValueCur;
+      }
+    }
+    {
+      // Test a group by order by query on some raw MV rows (order by on 
string)
+      String query = "SELECT mvRawIntCol, mvRawDoubleCol, mvRawStringCol from 
testTable GROUP BY mvRawIntCol, "
+          + "mvRawDoubleCol, mvRawStringCol ORDER BY mvRawStringCol LIMIT 10";
+      ResultTable resultTable = getBrokerResponse(query).getResultTable();
+      assertNotNull(resultTable);
+      DataSchema dataSchema = new DataSchema(new String[]{
+          "mvRawIntCol", "mvRawDoubleCol", "mvRawStringCol"
+      }, new DataSchema.ColumnDataType[]{
+          DataSchema.ColumnDataType.INT, DataSchema.ColumnDataType.DOUBLE, 
DataSchema.ColumnDataType.STRING
+      });
+      assertEquals(resultTable.getDataSchema(), dataSchema);
+      List<Object[]> recordRows = resultTable.getRows();
+      assertEquals(recordRows.size(), 10);
+
+      String stringVal = null;
+      for (int i = 0; i < 10; i++) {
+        Object[] values = recordRows.get(i);
+        assertEquals(values.length, 3);
+        String stringValueCur = (String) values[2];
+        if (stringVal != null && !stringValueCur.equals(stringVal)) {
+          assertTrue(stringValueCur.compareTo(stringVal) > 0);
+        }
+        stringVal = stringValueCur;
+      }
+    }
+    {
+      // Test a select with a VALUEIN transform function with group by
+      String query = "SELECT VALUEIN(mvRawIntCol, '0') from testTable WHERE 
mvRawIntCol IN (0) GROUP BY "
+          + "VALUEIN(mvRawIntCol, '0') LIMIT 10";
+      ResultTable resultTable = getBrokerResponse(query).getResultTable();
+      assertNotNull(resultTable);
+      DataSchema dataSchema = new DataSchema(new 
String[]{"valuein(mvRawIntCol,'0')"},
+          new DataSchema.ColumnDataType[]{DataSchema.ColumnDataType.INT});
+      assertEquals(resultTable.getDataSchema(), dataSchema);
+      List<Object[]> recordRows = resultTable.getRows();
+      assertEquals(recordRows.size(), 1);
+      Object[] values = recordRows.get(0);
+      assertEquals(values.length, 1);
+      int intRawVal = (int) values[0];
+      assertEquals(intRawVal, 0);
+    }
+    {
+      // Test a select with a VALUEIN transform function with group by order by
+      String query = "SELECT VALUEIN(mvRawDoubleCol, '0.0') from testTable 
WHERE mvRawDoubleCol IN (0.0) GROUP BY "
+          + "VALUEIN(mvRawDoubleCol, '0.0') ORDER BY VALUEIN(mvRawDoubleCol, 
'0.0') LIMIT 10";
+      ResultTable resultTable = getBrokerResponse(query).getResultTable();
+      assertNotNull(resultTable);
+      DataSchema dataSchema = new DataSchema(new 
String[]{"valuein(mvRawDoubleCol,'0.0')"},
+          new DataSchema.ColumnDataType[]{DataSchema.ColumnDataType.DOUBLE});
+      assertEquals(resultTable.getDataSchema(), dataSchema);
+      List<Object[]> recordRows = resultTable.getRows();
+      assertEquals(recordRows.size(), 1);
+      Object[] values = recordRows.get(0);
+      assertEquals(values.length, 1);
+      double doubleRawVal = (double) values[0];
+      assertEquals(doubleRawVal, 0.0);
+    }
+  }
+
+  @Test
+  public void testSelectWithFilterQueries() {

Review Comment:
   Let's ensure that we have covered all the MV column types and the filter 
operators =, IN, RANGE (<, > <=, >=), !=



-- 
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.

To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@pinot.apache.org
For additional commands, e-mail: commits-h...@pinot.apache.org

Reply via email to