Copilot commented on code in PR #17697:
URL: https://github.com/apache/pinot/pull/17697#discussion_r2806133709


##########
pinot-integration-test-base/src/test/java/org/apache/pinot/integration/tests/BaseClusterIntegrationTest.java:
##########
@@ -406,26 +415,71 @@ protected TableConfig createRealtimeTableConfig(File 
sampleAvroFile) {
     return getTableConfigBuilder(TableType.REALTIME).build();
   }
 
+  private List<String> getTimeBoundaryTable(List<String> offlineTables) {
+    String timeBoundaryTable = null;
+    long maxEndTimeMillis = Long.MIN_VALUE;
+    try {
+      for (String tableName : offlineTables) {
+        String url = 
_controllerRequestURLBuilder.forSegmentMetadata(tableName, TableType.OFFLINE);
+        String response = ControllerTest.sendGetRequest(url);
+        JsonNode jsonNode = JsonUtils.stringToJsonNode(response);
+        Iterator<String> stringIterator = jsonNode.fieldNames();
+        while (stringIterator.hasNext()) {
+          String segmentName = stringIterator.next();
+          JsonNode segmentJsonNode = jsonNode.get(segmentName);
+          long endTimeMillis = segmentJsonNode.get("endTimeMillis").asLong();
+          if (endTimeMillis > maxEndTimeMillis) {
+            maxEndTimeMillis = endTimeMillis;
+            timeBoundaryTable = tableName;
+          }
+        }
+      }
+    } catch (IOException e) {
+      throw new RuntimeException("Failed to get the time boundary table", e);
+    }
+    return timeBoundaryTable != null ? 
List.of(TableNameBuilder.OFFLINE.tableNameWithType(timeBoundaryTable))
+        : List.of();

Review Comment:
   `getTimeBoundaryTable()` iterates over `offlineTables` and sets 
`timeBoundaryTable = tableName`, but then returns 
`TableNameBuilder.OFFLINE.tableNameWithType(timeBoundaryTable)`. In current 
call sites (`createLogicalTableConfig()` and 
`BaseLogicalTableIntegrationTest`), `offlineTables` are already 
table-name-with-type (e.g. `o_1_OFFLINE`), so this produces an invalid name 
like `o_1_OFFLINE_OFFLINE` and breaks the includedTables in 
`TimeBoundaryConfig`.
   ```suggestion
       return timeBoundaryTable != null ? List.of(timeBoundaryTable) : 
List.of();
   ```



##########
pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/logicaltable/LogicalTableMultiStageEngineIntegrationTest.java:
##########
@@ -0,0 +1,116 @@
+/**
+ * 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.logicaltable;
+
+import java.io.File;
+import java.util.List;
+import java.util.stream.Collectors;
+import org.apache.pinot.integration.tests.MultiStageEngineIntegrationTest;
+import org.apache.pinot.spi.data.LogicalTableConfig;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+
+
+public class LogicalTableMultiStageEngineIntegrationTest extends 
MultiStageEngineIntegrationTest {
+
+  @BeforeClass
+  @Override
+  public void setUp()
+      throws Exception {
+    initCluster();
+    List<File> avroFiles = unpackAvroData(_tempDir);
+    initTables(avroFiles);
+    initOtherDependencies(avroFiles);
+  }

Review Comment:
   This `setUp()` override duplicates the exact initialization sequence already 
implemented in `MultiStageEngineIntegrationTest.setUp()`. Since the base 
`setUp()` calls overridable hooks (`initTables`, etc.), this override can be 
removed (or replaced with `super.setUp()`) to reduce duplication and the risk 
of future drift.
   ```suggestion
   
   ```



##########
pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/logicaltable/LogicalTableMultiStageEngineIntegrationTest.java:
##########
@@ -0,0 +1,116 @@
+/**
+ * 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.logicaltable;
+
+import java.io.File;
+import java.util.List;
+import java.util.stream.Collectors;
+import org.apache.pinot.integration.tests.MultiStageEngineIntegrationTest;
+import org.apache.pinot.spi.data.LogicalTableConfig;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+
+
+public class LogicalTableMultiStageEngineIntegrationTest extends 
MultiStageEngineIntegrationTest {
+
+  @BeforeClass
+  @Override
+  public void setUp()
+      throws Exception {
+    initCluster();
+    List<File> avroFiles = unpackAvroData(_tempDir);
+    initTables(avroFiles);
+    initOtherDependencies(avroFiles);
+  }
+
+  @Override
+  public void initTables(List<File> avroFiles)
+      throws Exception {
+    uploadDataToOfflineTables(getOfflineTablesCreated(), avroFiles);
+    createLogicalTableAndSchema();
+  }
+
+  @Override
+  protected List<String> getOfflineTablesCreated() {
+    return List.of("physicalTable_0", "physicalTable_1");
+  }
+
+  @Override
+  protected String getLogicalTableName() {
+    return getTableName();
+  }
+
+  @Override
+  protected LogicalTableConfig createLogicalTableConfig() {
+    List<String> offlineTableNames = 
getOfflineTablesCreated().stream().map(TableNameBuilder.OFFLINE::tableNameWithType)
+        .collect(Collectors.toList());
+    return createLogicalTableConfig(offlineTableNames, List.of());
+  }
+
+  @DataProvider(name = "polymorphicScalarComparisonFunctionsDataProvider")
+  public Object[][] polymorphicScalarComparisonFunctionsDataProvider() {
+    return super.polymorphicScalarComparisonFunctionsDataProvider();
+  }
+
+  @AfterClass
+  @Override
+  public void tearDown()
+      throws Exception {
+    dropLogicalTable(getTableName());
+    super.tearDown();
+  }
+
+  @Override
+  @Test
+  public void testBetween()
+      throws Exception {
+    testBetween(false);
+    // TODO - Explain plan result is different for logical table vs physical 
table.
+    //  That is why we're overriding the test and avoiding explain plan 
validation.
+    //  This needs to be fixed
+  }
+
+  // These validate tests are applicable only for physical table and not 
logical table, so ignoring them here.
+  // These tests get the table config of the physical table and send it in the 
request,
+  // which doesn't work for logical table.
+  @Override
+  @Ignore
+  public void testValidateQueryApiBatchMixedResults() {
+  }
+
+  @Override
+  @Ignore
+  public void testValidateQueryApiSuccessfulQueries() {
+  }
+
+  @Override
+  @Ignore
+  public void testValidateQueryApiUnsuccessfulQueries() {
+  }
+
+  @Override
+  @Ignore

Review Comment:
   These overrides are annotated with `@Ignore` but not `@Test`. In TestNG, 
overriding a `@Test` method without `@Test` removes it from the test run 
entirely (it won't show as skipped/ignored). If the intent is to skip these 
inherited tests explicitly, add `@Test` (or `@Test(enabled = false)`) alongside 
`@Ignore` on each override.
   ```suggestion
     @Ignore
     @Test(enabled = false)
     public void testValidateQueryApiBatchMixedResults() {
     }
   
     @Override
     @Ignore
     @Test(enabled = false)
     public void testValidateQueryApiSuccessfulQueries() {
     }
   
     @Override
     @Ignore
     @Test(enabled = false)
     public void testValidateQueryApiUnsuccessfulQueries() {
     }
   
     @Override
     @Ignore
     @Test(enabled = false)
   ```



##########
pinot-integration-test-base/src/test/java/org/apache/pinot/integration/tests/BaseClusterIntegrationTest.java:
##########
@@ -406,26 +415,71 @@ protected TableConfig createRealtimeTableConfig(File 
sampleAvroFile) {
     return getTableConfigBuilder(TableType.REALTIME).build();
   }
 
+  private List<String> getTimeBoundaryTable(List<String> offlineTables) {
+    String timeBoundaryTable = null;
+    long maxEndTimeMillis = Long.MIN_VALUE;
+    try {
+      for (String tableName : offlineTables) {
+        String url = 
_controllerRequestURLBuilder.forSegmentMetadata(tableName, TableType.OFFLINE);
+        String response = ControllerTest.sendGetRequest(url);
+        JsonNode jsonNode = JsonUtils.stringToJsonNode(response);
+        Iterator<String> stringIterator = jsonNode.fieldNames();
+        while (stringIterator.hasNext()) {
+          String segmentName = stringIterator.next();
+          JsonNode segmentJsonNode = jsonNode.get(segmentName);
+          long endTimeMillis = segmentJsonNode.get("endTimeMillis").asLong();
+          if (endTimeMillis > maxEndTimeMillis) {
+            maxEndTimeMillis = endTimeMillis;
+            timeBoundaryTable = tableName;
+          }
+        }
+      }
+    } catch (IOException e) {
+      throw new RuntimeException("Failed to get the time boundary table", e);
+    }
+    return timeBoundaryTable != null ? 
List.of(TableNameBuilder.OFFLINE.tableNameWithType(timeBoundaryTable))
+        : List.of();
+  }
+
+  protected LogicalTableConfig createLogicalTableConfig(List<String> 
offlineTables, List<String> realtimeTables) {
+    Map<String, PhysicalTableConfig> physicalTableConfigMap = new HashMap<>();
+    for (String physicalTableName : offlineTables) {
+      physicalTableConfigMap.put(physicalTableName, new PhysicalTableConfig());
+    }
+    for (String physicalTableName : realtimeTables) {
+      physicalTableConfigMap.put(physicalTableName, new PhysicalTableConfig());
+    }
+    String offlineTableName = offlineTables.stream().findFirst().orElse(null);
+    String realtimeTableName = 
realtimeTables.stream().findFirst().orElse(null);
+    LogicalTableConfigBuilder builder =
+        new LogicalTableConfigBuilder().setTableName(getLogicalTableName())
+            .setBrokerTenant(getBrokerTenant())
+            .setRefOfflineTableName(offlineTableName)
+            .setRefRealtimeTableName(realtimeTableName)
+            .setPhysicalTableConfigMap(physicalTableConfigMap);
+    if (!offlineTables.isEmpty() && !realtimeTables.isEmpty()) {
+      builder.setTimeBoundaryConfig(
+          new TimeBoundaryConfig("min", Map.of("includedTables", 
getTimeBoundaryTable(offlineTables)))
+      );
+    }
+    return builder.build();
+  }
+
   /**
    * Creates a LogicalTableConfig backed by the OFFLINE and REALTIME physical 
tables.
    */
   protected LogicalTableConfig createLogicalTableConfig() {
     String offlineTableName = 
TableNameBuilder.OFFLINE.tableNameWithType(getTableName());
     String realtimeTableName = 
TableNameBuilder.REALTIME.tableNameWithType(getTableName());
+    return createLogicalTableConfig(List.of(offlineTableName), 
List.of(realtimeTableName));
+  }
 
-    Map<String, PhysicalTableConfig> physicalTableConfigMap = new HashMap<>();
-    physicalTableConfigMap.put(offlineTableName, new PhysicalTableConfig());
-    physicalTableConfigMap.put(realtimeTableName, new PhysicalTableConfig());
-
-    return new LogicalTableConfigBuilder()
-        .setTableName(getLogicalTableName())
-        .setBrokerTenant(getBrokerTenant())
-        .setRefOfflineTableName(offlineTableName)
-        .setRefRealtimeTableName(realtimeTableName)
-        .setPhysicalTableConfigMap(physicalTableConfigMap)
-        .setTimeBoundaryConfig(
-            new TimeBoundaryConfig("min", Map.of("includedTables", 
physicalTableConfigMap.keySet())))
-        .build();
+  protected void createLogicalTableAndSchema()
+      throws IOException {
+    Schema schema = createSchema(getSchemaFileName());
+    schema.setSchemaName(getTableName());

Review Comment:
   `createLogicalTableAndSchema()` sets the schema name to `getTableName()`, 
but the schema for a logical table should be created with the logical table 
name (i.e., `getLogicalTableName()`). If a subclass uses a logical table name 
different from the physical table name, the controller will not find the 
expected schema for the logical table.
   ```suggestion
       schema.setSchemaName(getLogicalTableName());
   ```



##########
pinot-integration-tests/src/test/java/org/apache/pinot/integration/tests/logicaltable/LogicalTableMultiStageEngineIntegrationTest.java:
##########
@@ -0,0 +1,116 @@
+/**
+ * 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.logicaltable;
+
+import java.io.File;
+import java.util.List;
+import java.util.stream.Collectors;
+import org.apache.pinot.integration.tests.MultiStageEngineIntegrationTest;
+import org.apache.pinot.spi.data.LogicalTableConfig;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.DataProvider;
+import org.testng.annotations.Ignore;
+import org.testng.annotations.Test;
+
+
+
+public class LogicalTableMultiStageEngineIntegrationTest extends 
MultiStageEngineIntegrationTest {
+
+  @BeforeClass
+  @Override
+  public void setUp()
+      throws Exception {
+    initCluster();
+    List<File> avroFiles = unpackAvroData(_tempDir);
+    initTables(avroFiles);
+    initOtherDependencies(avroFiles);
+  }
+
+  @Override
+  public void initTables(List<File> avroFiles)
+      throws Exception {
+    uploadDataToOfflineTables(getOfflineTablesCreated(), avroFiles);
+    createLogicalTableAndSchema();
+  }
+
+  @Override
+  protected List<String> getOfflineTablesCreated() {
+    return List.of("physicalTable_0", "physicalTable_1");
+  }
+
+  @Override
+  protected String getLogicalTableName() {
+    return getTableName();
+  }
+
+  @Override
+  protected LogicalTableConfig createLogicalTableConfig() {
+    List<String> offlineTableNames = 
getOfflineTablesCreated().stream().map(TableNameBuilder.OFFLINE::tableNameWithType)
+        .collect(Collectors.toList());
+    return createLogicalTableConfig(offlineTableNames, List.of());
+  }
+
+  @DataProvider(name = "polymorphicScalarComparisonFunctionsDataProvider")
+  public Object[][] polymorphicScalarComparisonFunctionsDataProvider() {
+    return super.polymorphicScalarComparisonFunctionsDataProvider();
+  }
+
+  @AfterClass
+  @Override
+  public void tearDown()
+      throws Exception {
+    dropLogicalTable(getTableName());
+    super.tearDown();
+  }
+
+  @Override
+  @Test
+  public void testBetween()
+      throws Exception {
+    testBetween(false);
+    // TODO - Explain plan result is different for logical table vs physical 
table.
+    //  That is why we're overriding the test and avoiding explain plan 
validation.
+    //  This needs to be fixed
+  }

Review Comment:
   `testBetween()` in the logical-table suite skips the NOT BETWEEN 
explain-plan assertions entirely. This reduces coverage for an 
optimizer/planner-sensitive case and may allow regressions to slip in 
unnoticed. Consider validating a logical-table-appropriate invariant for the 
NOT BETWEEN plan (even if different from physical tables), or making the 
assertion accept both known plan shapes instead of disabling it.



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