walterddr commented on code in PR #10819:
URL: https://github.com/apache/pinot/pull/10819#discussion_r1210997249
##########
pinot-query-runtime/src/test/java/org/apache/pinot/query/runtime/operator/SortOperatorTest.java:
##########
@@ -420,14 +452,68 @@ public void
shouldConsumeAndSortTwoInputBlocksWithOneRowEachInputSorted() {
Assert.assertTrue(block2.isEndOfStreamBlock(), "expected EOS block to
propagate");
}
+ @Test
+ public void shouldHaveNullAtLast() {
+ // Given:
+ List<RexExpression> collation = collation(0);
+ List<Direction> directions = ImmutableList.of(Direction.ASCENDING);
+ List<NullDirection> nullDirections = ImmutableList.of(NullDirection.LAST);
+ DataSchema schema = new DataSchema(new String[]{"sort"}, new
DataSchema.ColumnDataType[]{INT});
+ SortOperator op =
+ new SortOperator(OperatorTestUtil.getDefaultContext(), _input,
collation, directions, nullDirections, 10, 0,
+ schema, false);
+
+ Mockito.when(_input.nextBlock()).thenReturn(block(schema, new Object[]{2},
new Object[]{1}, new Object[]{null}))
+ .thenReturn(TransferableBlockUtils.getEndOfStreamTransferableBlock());
+
+ // When:
+ TransferableBlock block = op.nextBlock(); // construct
+ TransferableBlock block2 = op.nextBlock(); // eos
+
+ // Then:
+ Assert.assertEquals(block.getNumRows(), 3);
+ Assert.assertEquals(block.getContainer().get(0), new Object[]{1});
+ Assert.assertEquals(block.getContainer().get(1), new Object[]{2});
+ Assert.assertEquals(block.getContainer().get(2), new Object[]{null});
+ Assert.assertTrue(block2.isEndOfStreamBlock(), "expected EOS block to
propagate");
+ }
+
+ @Test
+ public void shouldHaveNullAtFIRST() {
Review Comment:
```suggestion
public void shouldHaveNullAtFirst() {
```
##########
pinot-query-runtime/src/test/resources/queries/NullHandling.json:
##########
@@ -45,6 +45,16 @@
{
"description": "LEFT JOIN and GROUP BY with AGGREGATE",
"sql": "SELECT {tbl1}.strCol2, COUNT({tbl2}.intCol1),
MIN({tbl2}.intCol1), MAX({tbl2}.doubleCol1), SUM({tbl2}.doubleCol1) FROM {tbl1}
LEFT OUTER JOIN {tbl2} ON {tbl1}.strCol1 = {tbl2}.strCol1 GROUP BY
{tbl1}.strCol2"
+ },
+ {
+ "description": "LEFT JOIN and SORT (by default, H2 treats null as the
smallest value, which is different from Postgres, thus we don't test the
default ordering)",
+ "sql": "SELECT {tbl2}.doubleCol1 AS col FROM {tbl1} LEFT OUTER JOIN
{tbl2} ON {tbl1}.strCol1 = {tbl2}.strCol1 ORDER BY col NULLS FIRST",
+ "keepOutputRowOrder": true
+ },
+ {
+ "description": "LEFT JOIN and GROUP BY with AGGREGATE AND SORT",
+ "sql": "SELECT {tbl1}.strCol2, COUNT({tbl2}.intCol1),
MIN({tbl2}.intCol1) AS minCol, MAX({tbl2}.doubleCol1), SUM({tbl2}.doubleCol1)
FROM {tbl1} LEFT OUTER JOIN {tbl2} ON {tbl1}.strCol1 = {tbl2}.strCol1 GROUP BY
{tbl1}.strCol2 ORDER BY minCol DESC NULLS LAST",
+ "keepOutputRowOrder": true
Review Comment:
can we add
1. multiple column order by
2. multiple column order by with mixed NULL FIRST LAST usage
3. multiple column order by asc/desc
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]