Skip to content

Support debug for query#17178

Open
Wei-hao-Li wants to merge 6 commits intomasterfrom
addQueryDebug
Open

Support debug for query#17178
Wei-hao-Li wants to merge 6 commits intomasterfrom
addQueryDebug

Conversation

@Wei-hao-Li
Copy link
Collaborator

No description provided.

Signed-off-by: Weihao Li <18110526956@163.com>
Signed-off-by: Weihao Li <18110526956@163.com>
Signed-off-by: Weihao Li <18110526956@163.com>
Signed-off-by: Weihao Li <18110526956@163.com>

# Conflicts:
#	iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/thrift/impl/ClientRPCServiceImpl.java
Signed-off-by: Weihao Li <18110526956@163.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request adds support for the DEBUG keyword in SQL queries for both tree model and table model. When a query is prefixed with the DEBUG keyword, it enables detailed debug logging throughout the query execution pipeline, which is useful for troubleshooting and understanding query behavior.

Changes:

  • Added DEBUG keyword to ANTLR grammar files for both tree and table models
  • Threaded debug flag through the entire query execution pipeline (Statement, QueryContext, MPPQueryContext, FragmentInstance, FragmentInstanceContext)
  • Updated all QueryContext constructor calls to include the debug parameter
  • Added integration tests to verify DEBUG functionality for both tree and table model queries
  • Added helper methods to AbstractNodeWrapper to clear and check log contents

Reviewed changes

Copilot reviewed 42 out of 42 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
RelationalSql.g4 Added DEBUG token to grammar and included it in nonReserved keywords
Statement.java (relational) Added debug field and getter/setter methods
Statement.java (tree model) Already had debug support - no changes needed
AstBuilder.java Extracts debug flag from parse tree and sets it on Statement
QueryContext.java Made debug field final and added it to all constructors
MPPQueryContext.java Added debug field with getter/setter methods
FragmentInstance.java Added debug field, updated constructors, and implemented serialization/deserialization
FragmentInstanceContext.java Updated all constructors to accept and propagate debug flag
Coordinator.java Updated execution methods with debug parameter and added deprecated compatibility methods
Test files Updated all QueryContext instantiations to pass false for debug flag
IoTDBDebugQueryIT.java Added integration tests for DEBUG keyword functionality
AbstractNodeWrapper.java Added clearLogContent() and logContains() helper methods for log verification
Various other files Updated calls to pass debug flag through the execution pipeline

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 88 to 104
@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"));
}
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Comment on lines 309 to 310
if (userQuery) {
System.out.println("--------------" + debug);
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
if (userQuery) {
System.out.println("--------------" + debug);
if (userQuery && LOGGER.isDebugEnabled()) {
LOGGER.debug("[QueryDebugFlag] debug: {}", debug);

Copilot uses AI. Check for mistakes.
Comment on lines 75 to 86
@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"));
}
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
Signed-off-by: Weihao Li <18110526956@163.com>
@sonarqubecloud
Copy link

sonarqubecloud bot commented Feb 6, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
5.4% Duplication on New Code (required ≤ 5%)

See analysis details on SonarQube Cloud

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants