Skip to content

Commit e531acb

Browse files
authored
branch 3.0: [fix](regression) topn-filter unstable case #47797 (#48367)
### What problem does this PR solve? Pick #47797
1 parent 92ab9be commit e531acb

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

fe/fe-core/src/main/java/org/apache/doris/nereids/processor/post/TopnFilterPushDownVisitor.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ public Boolean visitPhysicalRelation(PhysicalRelation relation, PushDownContext
220220
&& relation.getOutputSet().containsAll(ctx.probeExpr.getInputSlots())) {
221221
// in ut, relation.getStats() may return null
222222
if (relation.getStats() == null
223-
|| relation.getStats().getRowCount() > ctx.topn.getLimit() + ctx.topn.getOffset()) {
223+
|| Math.max(relation.getStats().getRowCount(), 1) > ctx.topn.getLimit() + ctx.topn.getOffset()) {
224224
topnFilterContext.addTopnFilter(ctx.topn, relation, ctx.probeExpr);
225225
return true;
226226
}

regression-test/suites/query_p0/test_array_orderby_limit.groovy

+7-3
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,12 @@
1515
// specific language governing permissions and limitations
1616
// under the License.
1717

18-
suite("test_array_char_orderby", "query") {
18+
suite("test_array_orderby_limit", "query") {
1919
// define a sql table
2020
def testTable = "test_array_char_orderby"
2121

2222
sql """
23+
drop table if exists test_array_char_orderby;
2324
CREATE TABLE IF NOT EXISTS test_array_char_orderby (
2425
`k1` INT(11) NULL,
2526
`k2` array<array<char(50)>> NULL
@@ -32,13 +33,16 @@ suite("test_array_char_orderby", "query") {
3233
"in_memory" = "false",
3334
"storage_format" = "V2",
3435
"disable_auto_compaction" = "false"
35-
)
36+
);
3637
"""
3738
// prepare data
3839
sql """ INSERT INTO test_array_char_orderby VALUES (100, [['abc']]), (200, [['xyz']]) """
39-
sql "analyze table test_array_char_orderby with sync"
40+
sql '''
41+
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');
42+
'''
4043
// set topn_opt_limit_threshold = 1024 to make sure _internal_service to be request with proto request
4144
sql """ set topn_opt_limit_threshold = 1024 """
45+
def table_stats = sql("show table stats test_array_char_orderby")
4246

4347
explain{
4448
sql("select * from test_array_char_orderby order by k1 limit 1")

0 commit comments

Comments
 (0)