shuwenwei opened a new pull request, #18191: URL: https://github.com/apache/iotdb/pull/18191
## Problem When projection pruning removes tag columns from the scan node's assignments, `constructExternalTsFileDeviceFilter` builds a `TsTable` from the pruned assignments and recomputes tag indices via `getTagColumnIndex`. This causes subsequent tag columns to be assigned wrong indices. For example, with tags `[tag1, tag2]` and a query like: ```sql SELECT time, value FROM read_tsfile(...) WHERE tag2 = 'x' ``` The optimizer: 1. Prunes `tag1` and `tag2` from the scan node's assignments (they are not in SELECT) 2. Rebuilds a `TsTable` containing only `tag2` 3. Recomputes tag index: `tag2` → 0 (should be 1) 4. `ExternalTsFileDeviceFilterVisitor` reads `deviceID.segment(0 + 1)` = `tag1` instead of `deviceID.segment(1 + 1)` = `tag2` Result: `WHERE tag2 = 'x'` actually evaluates `WHERE tag1 = 'x'`. ## Fix Use `ExternalTsFileQueryResource.getTableColumnSchema()` instead of the pruned scan node `getAssignments()` when constructing the `TsTable` for device filter. The query resource always holds the complete, unpruned column schema with correct tag ordering from the initial planning phase. ## Changes - **`PushPredicateIntoTableScan.java`**: Change `constructExternalTsFileDeviceFilter` to build `TsTable` from the complete table column schema - **`IoTDBReadTsFileTableFunctionIT.java`**: Add `testReadTsFileWithTagFilterAndProjectionPruning` to verify correct tag filtering when projection prunes tag columns -- 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]
