Copilot commented on code in PR #17178:
URL: https://github.com/apache/iotdb/pull/17178#discussion_r2772641149


##########
integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBDebugQueryIT.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * 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.iotdb.relational.it.query.recent;
+
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.env.cluster.node.DataNodeWrapper;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.TableLocalStandaloneIT;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.io.IOException;
+
+import static org.apache.iotdb.db.it.utils.TestUtils.prepareData;
+import static org.apache.iotdb.db.it.utils.TestUtils.prepareTableData;
+import static org.apache.iotdb.db.it.utils.TestUtils.resultSetEqualTest;
+import static org.apache.iotdb.db.it.utils.TestUtils.tableResultSetEqualTest;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({TableLocalStandaloneIT.class})
+public class IoTDBDebugQueryIT {
+  private static final String DATABASE_NAME = "test_db";
+  private static final String[] createTableSqls =
+      new String[] {
+        "CREATE DATABASE " + DATABASE_NAME,
+        "USE " + DATABASE_NAME,
+        "create table table1(device string tag, value int32 field)",
+        "insert into table1(time,device,value) values(2020-01-01 
00:00:01.000,'d1',1)",
+        "FLUSH",
+      };
+  private static final String[] createTreeSqls =
+      new String[] {
+        "create timeseries root.test.departments.department_id TEXT",
+        "create timeseries root.test.departments.dep_name TEXT",
+        "insert into root.test.departments(time, department_id, dep_name) 
values(1, 'D001', '研发部')",
+        "FLUSH",
+      };
+  private static DataNodeWrapper dataNodeWrapper;
+
+  @BeforeClass
+  public static void setUp() throws Exception {
+    EnvFactory.getEnv().initClusterEnvironment();
+    dataNodeWrapper = EnvFactory.getEnv().getDataNodeWrapperList().get(0);
+    prepareTableData(createTableSqls);
+    prepareData(createTreeSqls);
+  }
+
+  @AfterClass
+  public static void tearDown() throws Exception {
+    EnvFactory.getEnv().cleanClusterEnvironment();
+  }
+
+  @Test
+  public void treeTest() throws IOException {
+    // clear log content to reduce lines spanned in logContains check
+    dataNodeWrapper.clearLogContent();
+
+    String[] expectedHeader = new String[] {"time", "device", "value"};
+    String[] retArray = new String[] {"2020-01-01T00:00:01.000Z,d1,1,"};
+    tableResultSetEqualTest(
+        "debug select time,device,value from table1", expectedHeader, 
retArray, DATABASE_NAME);
+
+    assertTrue(dataNodeWrapper.logContains("Cache miss: table1.d1"));
+  }
+
+  @Test
+  public void tableTest() throws IOException {
+    // clear log content to reduce lines spanned in logContains check
+    dataNodeWrapper.clearLogContent();
+
+    String[] expectedHeader =
+        new String[] {
+          "Time", "root.test.departments.department_id", 
"root.test.departments.dep_name"
+        };
+    String[] retArray = new String[] {"1,D001,研发部,"};
+    resultSetEqualTest(
+        "debug select department_id, dep_name from root.test.departments",
+        expectedHeader,
+        retArray);
+
+    assertTrue(dataNodeWrapper.logContains("Cache miss: 
root.test.departments"));
+  }

Review Comment:
   Test method name is misleading. The method is named "tableTest" but it's 
actually testing the tree model query with "debug select department_id, 
dep_name from root.test.departments". Consider renaming to "treeTest" for 
clarity.



##########
integration-test/src/test/java/org/apache/iotdb/relational/it/query/recent/IoTDBDebugQueryIT.java:
##########
@@ -0,0 +1,105 @@
+/*
+ * 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.iotdb.relational.it.query.recent;
+
+import org.apache.iotdb.it.env.EnvFactory;
+import org.apache.iotdb.it.env.cluster.node.DataNodeWrapper;
+import org.apache.iotdb.it.framework.IoTDBTestRunner;
+import org.apache.iotdb.itbase.category.TableLocalStandaloneIT;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.experimental.categories.Category;
+import org.junit.runner.RunWith;
+
+import java.io.IOException;
+
+import static org.apache.iotdb.db.it.utils.TestUtils.prepareData;
+import static org.apache.iotdb.db.it.utils.TestUtils.prepareTableData;
+import static org.apache.iotdb.db.it.utils.TestUtils.resultSetEqualTest;
+import static org.apache.iotdb.db.it.utils.TestUtils.tableResultSetEqualTest;
+import static org.junit.Assert.assertTrue;
+
+@RunWith(IoTDBTestRunner.class)
+@Category({TableLocalStandaloneIT.class})
+public class IoTDBDebugQueryIT {
+  private static final String DATABASE_NAME = "test_db";
+  private static final String[] createTableSqls =
+      new String[] {
+        "CREATE DATABASE " + DATABASE_NAME,
+        "USE " + DATABASE_NAME,
+        "create table table1(device string tag, value int32 field)",
+        "insert into table1(time,device,value) values(2020-01-01 
00:00:01.000,'d1',1)",
+        "FLUSH",
+      };
+  private static final String[] createTreeSqls =
+      new String[] {
+        "create timeseries root.test.departments.department_id TEXT",
+        "create timeseries root.test.departments.dep_name TEXT",
+        "insert into root.test.departments(time, department_id, dep_name) 
values(1, 'D001', '研发部')",
+        "FLUSH",
+      };
+  private static DataNodeWrapper dataNodeWrapper;
+
+  @BeforeClass
+  public static void setUp() throws Exception {
+    EnvFactory.getEnv().initClusterEnvironment();
+    dataNodeWrapper = EnvFactory.getEnv().getDataNodeWrapperList().get(0);
+    prepareTableData(createTableSqls);
+    prepareData(createTreeSqls);
+  }
+
+  @AfterClass
+  public static void tearDown() throws Exception {
+    EnvFactory.getEnv().cleanClusterEnvironment();
+  }
+
+  @Test
+  public void treeTest() throws IOException {
+    // clear log content to reduce lines spanned in logContains check
+    dataNodeWrapper.clearLogContent();
+
+    String[] expectedHeader = new String[] {"time", "device", "value"};
+    String[] retArray = new String[] {"2020-01-01T00:00:01.000Z,d1,1,"};
+    tableResultSetEqualTest(
+        "debug select time,device,value from table1", expectedHeader, 
retArray, DATABASE_NAME);
+
+    assertTrue(dataNodeWrapper.logContains("Cache miss: table1.d1"));
+  }

Review Comment:
   Test method name is misleading. The method is named "treeTest" but it's 
actually testing the table model query with "debug select time,device,value 
from table1". Consider renaming to "tableTest" for clarity.



##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/Coordinator.java:
##########
@@ -305,6 +306,9 @@ private ExecutionResult execution(
       if (LOGGER.isDebugEnabled() && sql != null && !sql.isEmpty()) {
         LOGGER.debug("[QueryStart] sql: {}", sql);
       }
+      if (userQuery) {
+        System.out.println("--------------" + debug);

Review Comment:
   Debug print statement should be removed before merging to production. This 
System.out.println was likely added for development testing but should not be 
part of the final code.
   ```suggestion
         if (userQuery && LOGGER.isDebugEnabled()) {
           LOGGER.debug("[QueryDebugFlag] debug: {}", debug);
   ```



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

Reply via email to