bziobrowski commented on code in PR #14690:
URL: https://github.com/apache/pinot/pull/14690#discussion_r1894189931


##########
pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/custom/TimestampIndexTest.java:
##########
@@ -0,0 +1,183 @@
+/**
+ * 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.integration.tests.custom;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.pinot.integration.tests.BaseClusterIntegrationTest;
+import org.apache.pinot.integration.tests.ClusterIntegrationTestUtils;
+import org.apache.pinot.integration.tests.ExplainIntegrationTestTrait;
+import org.apache.pinot.spi.config.table.FieldConfig;
+import org.apache.pinot.spi.config.table.TableConfig;
+import org.apache.pinot.spi.config.table.TimestampConfig;
+import org.apache.pinot.spi.config.table.TimestampIndexGranularity;
+import org.apache.pinot.spi.data.Schema;
+import org.apache.pinot.spi.env.PinotConfiguration;
+import org.apache.pinot.spi.utils.CommonConstants;
+import org.apache.pinot.util.TestUtils;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+
+public class TimestampIndexTest extends BaseClusterIntegrationTest implements 
ExplainIntegrationTestTrait {
+  @BeforeClass
+  public void setUp()
+      throws Exception {
+    TestUtils.ensureDirectoriesExistAndEmpty(_tempDir, _segmentDir, _tarDir);
+
+    // Start the Pinot cluster
+    startZk();
+    startController();
+    startBroker();
+    startServers(2);
+
+    // Create and upload the schema and table config
+    Schema schema = createSchema();
+    addSchema(schema);
+    TableConfig tableConfig = createOfflineTableConfig();
+    addTableConfig(tableConfig);
+
+    // Unpack the Avro files
+    List<File> avroFiles = unpackAvroData(_tempDir);
+
+    // Create and upload segments
+    ClusterIntegrationTestUtils.buildSegmentsFromAvro(avroFiles, tableConfig, 
schema, 0, _segmentDir, _tarDir);
+    uploadSegments(getTableName(), _tarDir);
+
+    // Wait for all documents loaded
+    waitForAllDocsLoaded(600_000L);
+  }
+
+  protected void overrideBrokerConf(PinotConfiguration brokerConf) {
+    String property = 
CommonConstants.MultiStageQueryRunner.KEY_OF_MULTISTAGE_EXPLAIN_INCLUDE_SEGMENT_PLAN;
+    brokerConf.setProperty(property, "true");
+  }
+
+  @Test
+  public void timestampIndexSubstitutedInProjectionsMSE() {
+    setUseMultiStageQueryEngine(true);
+    explain("SELECT datetrunc('SECOND',ArrTime) FROM mytable",
+        "Execution Plan\n"
+            + "PinotLogicalExchange(distribution=[broadcast])\n"
+            + "  LeafStageCombineOperator(table=[mytable])\n"
+            + "    StreamingInstanceResponse\n"
+            + "      StreamingCombineSelect\n"
+            + "        SelectStreaming(table=[mytable], totalDocs=[115545])\n"
+            + "          Project(columns=[[$ArrTime$SECOND]])\n"
+            + "            DocIdSet(maxDocs=[120000])\n"
+            + "              FilterMatchEntireSegment(numDocs=[115545])\n");
+  }
+
+  @Test
+  public void timestampIndexSubstitutedInFiltersMSE() {
+    setUseMultiStageQueryEngine(true);
+    explain("SELECT 1 FROM mytable where datetrunc('SECOND',ArrTime) > 1",
+        "Execution Plan\n"
+            + "PinotLogicalExchange(distribution=[broadcast])\n"
+            + "  LeafStageCombineOperator(table=[mytable])\n"
+            + "    StreamingInstanceResponse\n"
+            + "      StreamingCombineSelect\n"
+            + "        SelectStreaming(table=[mytable], totalDocs=[115545])\n"
+            + "          Transform(expressions=[['1']])\n"
+            + "            Project(columns=[[]])\n"
+            + "              DocIdSet(maxDocs=[120000])\n"
+            + "                FilterRangeIndex(predicate=[$ArrTime$SECOND > 
'1'], "
+            + "indexLookUp=[range_index], operator=[RANGE])\n");
+  }
+

Review Comment:
   I checked HAVING on a few queries locally and think it's fine because HAVING 
expression is applied after aggregation by matching expression to group by 
output (so no additional aggregates are computed if it matches group by 
element).



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

Reply via email to