This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new e531acbd585 branch 3.0: [fix](regression) topn-filter unstable case
#47797 (#48367)
e531acbd585 is described below
commit e531acbd58563a16e88b7b65cb2dc23d5cb174ac
Author: minghong <[email protected]>
AuthorDate: Mon Mar 10 12:06:07 2025 +0800
branch 3.0: [fix](regression) topn-filter unstable case #47797 (#48367)
### What problem does this PR solve?
Pick #47797
---
.../nereids/processor/post/TopnFilterPushDownVisitor.java | 2 +-
.../suites/query_p0/test_array_orderby_limit.groovy | 10 +++++++---
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git
a/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/TopnFilterPushDownVisitor.java
b/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/TopnFilterPushDownVisitor.java
index 2d8989d9147..548d1b5f6b4 100644
---
a/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/TopnFilterPushDownVisitor.java
+++
b/fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/TopnFilterPushDownVisitor.java
@@ -220,7 +220,7 @@ public class TopnFilterPushDownVisitor extends
PlanVisitor<Boolean, PushDownCont
&&
relation.getOutputSet().containsAll(ctx.probeExpr.getInputSlots())) {
// in ut, relation.getStats() may return null
if (relation.getStats() == null
- || relation.getStats().getRowCount() > ctx.topn.getLimit()
+ ctx.topn.getOffset()) {
+ || Math.max(relation.getStats().getRowCount(), 1) >
ctx.topn.getLimit() + ctx.topn.getOffset()) {
topnFilterContext.addTopnFilter(ctx.topn, relation,
ctx.probeExpr);
return true;
}
diff --git a/regression-test/suites/query_p0/test_array_orderby_limit.groovy
b/regression-test/suites/query_p0/test_array_orderby_limit.groovy
index a1de7219f9a..1780835ed2e 100644
--- a/regression-test/suites/query_p0/test_array_orderby_limit.groovy
+++ b/regression-test/suites/query_p0/test_array_orderby_limit.groovy
@@ -15,11 +15,12 @@
// specific language governing permissions and limitations
// under the License.
-suite("test_array_char_orderby", "query") {
+suite("test_array_orderby_limit", "query") {
// define a sql table
def testTable = "test_array_char_orderby"
sql """
+ drop table if exists test_array_char_orderby;
CREATE TABLE IF NOT EXISTS test_array_char_orderby (
`k1` INT(11) NULL,
`k2` array<array<char(50)>> NULL
@@ -32,13 +33,16 @@ suite("test_array_char_orderby", "query") {
"in_memory" = "false",
"storage_format" = "V2",
"disable_auto_compaction" = "false"
- )
+ );
"""
// prepare data
sql """ INSERT INTO test_array_char_orderby VALUES (100, [['abc']]), (200,
[['xyz']]) """
- sql "analyze table test_array_char_orderby with sync"
+ sql '''
+ alter table test_array_char_orderby modify column k1 set stats
('ndv'='10', 'num_nulls'='0', 'min_value'='1', 'max_value'='100',
'row_count'='100');
+ '''
// set topn_opt_limit_threshold = 1024 to make sure _internal_service to
be request with proto request
sql """ set topn_opt_limit_threshold = 1024 """
+ def table_stats = sql("show table stats test_array_char_orderby")
explain{
sql("select * from test_array_char_orderby order by k1 limit 1")
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]