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

   ## Description
   
   COPY TO TsFile currently fails when a SQL query returns timestamps out of 
order within a target device, for example with `ORDER BY time DESC`. Add an 
outer sort by the target TAG columns and TIME after planning the complete inner 
query, so existing optimizers can use streaming scans, eliminate redundant 
sorts, and merge ordered region results. The inner query's ORDER BY, LIMIT, and 
OFFSET semantics are preserved.
   
   Both table shorthand and SQL query exports use this path. Exports with 
generated timestamps retain their existing behavior, and duplicate timestamps 
for the same target device remain subject to TsFile writer validation. No SQL 
option is added.
   
   ## Validation
   
   - Add planner unit tests covering COPY TO entry points, streaming sort and 
distributed merge, TopK with OFFSET, aliases and target TAG order, and 
generated timestamps.
   - Add five integration tests covering descending timestamps, field-based 
ordering, LIMIT/OFFSET, aliased TIME with reordered TAGs, and exports without 
TAGs. Read back all exported rows and check increasing timestamps per device; 
use small TsBlocks to exercise multiple batches.
   - Set `MEMORY_THRESHOLD 1000000` for the new integration cases, matching 
existing COPY TO tests.
   - All five new integration tests passed according to the user's local 
validation. The agent did not rerun tests or compilation.
   
   This PR has:
   - [x] been self-reviewed.
   - [x] added unit tests.
   - [x] added integration tests.
   


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