gortiz commented on code in PR #14296: URL: https://github.com/apache/pinot/pull/14296#discussion_r1832774090
########## pinot-query-planner/src/test/java/org/apache/pinot/query/planner/logical/GroupedStagesTest.java: ########## @@ -0,0 +1,73 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.pinot.query.planner.logical; + +import org.testng.annotations.Test; + +import static org.testng.Assert.*; + + +public class GroupedStagesTest extends StagesTestBase { + + @Test + public void addOrdered() { + when( + join( + exchange(1, tableScan("T1")), + exchange(2, tableScan("T2")) + ) + ); + + GroupedStages.Mutable mutable = new GroupedStages.Mutable() + .addNewGroup(stage(0)) + .addNewGroup(stage(1)) + .addNewGroup(stage(2)); + assertEquals(mutable.toString(), "[[0], [1], [2]]"); + } + + @Test + public void addUnordered() { + when( + join( + exchange(1, tableScan("T1")), + exchange(2, tableScan("T2")) + ) + ); + GroupedStages.Mutable mutable = new GroupedStages.Mutable() + .addNewGroup(stage(2)) + .addNewGroup(stage(1)) + .addNewGroup(stage(0)); + assertEquals(mutable.toString(), "[[0], [1], [2]]"); + } + + @Test + public void addEquivalence() { + when( + join( + exchange(1, tableScan("T1")), + exchange(2, tableScan("T2")) + ) + ); + GroupedStages.Mutable mutable = new GroupedStages.Mutable() + .addNewGroup(stage(0)) + .addNewGroup(stage(1)) + .addToGroup(stage(0), stage(2)); + assertEquals(mutable.toString(), "[[0, 2], [1]]"); Review Comment: I think we have a different perspective. This tests is not testing the semantic of the equivalence. It is just testing the API of `GroupedStages`. In here you can do crazy things that doesn't make any sense. We are just testing that the API works in the same way we can create a test on a java.util.list that verifies that if we have a list of `[1, 2]` and we call `add(1, 3)` the result will be `[1, 3, 2]`. Whether that list is later being used to store ints order by their value or not is not important for the list and the same happens in this GroupedStages class. -- 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