suxiaogang223 opened a new pull request, #71150:
URL: https://github.com/apache/doris/pull/71150

   ### Background
   
   SQL block rules compare the estimated cardinality of each scan with the
   configured threshold. The planner can set a local limit on a file scan
   while retaining its original cardinality estimate.
   
   ### What problem does this PR solve?
   
   Issue Number: None
   Related PR: None
   PR Type: Bugfix
   
   Problem Summary:
   
   A preview query on a large external table can hit the cardinality rule
   when its file scan already has LIMIT 1. Bound the cardinality used by
   SQL Block with the limit on that scan.
   
   ### Details
   
   - **Frequency:** File scans with a pushed-down limit at or below the
     cardinality threshold and an estimate above it.
   - **Root cause:** The SQL Block check reads the scan estimate before
     accounting for the file scan's local execution limit.
   - **Why existing tests missed it:** The Hive and Iceberg suites checked
     oversized scans, including a Hive sort with a larger query limit.
     Neither exercised a small limit on the scan.
   - **Fix:** Use the smaller of the file scan estimate and its local limit
     for the cardinality check. Each scan supplies its own limit. A limit
     on an aggregate does not affect the file scan's threshold comparison.
   - **Other paths and branches:** The shared check covers external connectors
     that plan a `FileScanNode`. The partition and split rules continue to use
     their original estimates.
   - **Behavior change:** A preview query can pass the cardinality rule when
     the limit on its file scan is within the configured threshold.
   
   ### Testing
   
   - FE build with build.sh on Fedora and FE Checkstyle passed.
   - Ran 10 focused FE tests on Fedora, including a temporary validation
     of the scan limit, unrestricted scan, and split threshold paths.
   - ASAN BE build with build.sh on Fedora passed.
   - Both SQL Block regression suites passed end to end on Fedora
     (`test_external_sql_block_rule` and `test_iceberg_sql_block_rule`).
     The fixture used a single ASAN BE with file cache disabled on Btrfs.
   
   ### Release note
   
   SQL Block accounts for limits pushed to external scans when checking
   cardinality, so small preview queries can pass the row threshold.
   
   ### Check List (For Author)
   
   - Behavior changed: Yes (see Details)
   - Does this need documentation: No
   - Pre-submission status: Ready
   
   ### AI Disclosure
   
   - Tool: OpenAI Codex (GPT-6)
   - Generated: code, regression tests, and PR description
   - Human review: Not yet performed.
   


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to