xiangmy21 opened a new pull request, #16549:
URL: https://github.com/apache/iotdb/pull/16549

   ## Bug Fix: count device operation
   ### Problem Description
   
   When a node (assumed to be root.db) in the tree model is both a database and 
a device, `count devices root.db.**`, will incorrectly count root.db into 
device, causing the result to be 1 greater than the correct result.
   
   ### Problem Cause
   The SchemaCountOperator operator pre-checks whether the query path fully 
contains the current schemaRegion. If it does, it directly returns the 
statistical information. When determining containment, it uses the logic of 
"the query path contains the databasePath of this schemaRegion."
   When processing the schemaRegion where the device root.db is located, the 
query path `root.db.**` is judged to be able to utilize schemaRegion's 
statistics, causing the device root.db to be included in the results. 
   <img width="1143" height="906" alt="image" 
src="https://github.com/user-attachments/assets/ce74cff9-a113-4f81-af5d-9f3bf860658d";
 />
   <img width="1186" height="281" alt="image" 
src="https://github.com/user-attachments/assets/71561a33-f9b6-4bb3-a1c3-e08e19f29fdd";
 />
   
   ### Solution
   After passing the hasSchemaStatistic check to ensure that statistical 
information can be directly obtained, further determine whether the database of 
the schemaRegion is also included in the query's pathPattern. If it is not 
included, then it is necessary to check whether the database is a device (if 
so, subtract 1 from the answer). The way to check is: create a query plan with 
the database as the path, and call schemaRegion.getDeviceReader to read the 
first device.
   
   Code changes are shown below.
   - [x] IoTDBCountDeviceIT.java added and passed.
   - [x] mvn spotless::apply -P with-integration-tests excuted. 
   


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