From 2ec33950879128ef6a5aeca2fa084e4346fc05b9 Mon Sep 17 00:00:00 2001 From: starocean999 <40539150+starocean999@users.noreply.github.com> Date: Thu, 23 Nov 2023 18:40:02 +0800 Subject: [PATCH] [fix](planner)the data type should be the same between input slot and sort slot (#27137) --- .../apache/doris/planner/AnalyticPlanner.java | 5 +++-- .../test_inlineview_with_window_function.out | 6 ++++++ .../test_inlineview_with_window_function.groovy | 16 ++++++++++++++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/fe/fe-core/src/main/java/org/apache/doris/planner/AnalyticPlanner.java b/fe/fe-core/src/main/java/org/apache/doris/planner/AnalyticPlanner.java index 433fe76fd9..7687b5812a 100644 --- a/fe/fe-core/src/main/java/org/apache/doris/planner/AnalyticPlanner.java +++ b/fe/fe-core/src/main/java/org/apache/doris/planner/AnalyticPlanner.java @@ -313,9 +313,10 @@ public class AnalyticPlanner { SlotDescriptor sortSlotDesc = analyzer.getDescTbl().addSlotDescriptor(sortTupleDesc); if (inputSlotDesc.getColumn() != null) { sortSlotDesc.setColumn(inputSlotDesc.getColumn()); - } else { - sortSlotDesc.setType(inputSlotDesc.getType()); } + // always set type as inputSlotDesc's type + sortSlotDesc.setType(inputSlotDesc.getType()); + // all output slots need to be materialized sortSlotDesc.setIsMaterialized(true); sortSlotDesc.setIsNullable(inputSlotDesc.getIsNullable()); diff --git a/regression-test/data/correctness_p0/test_inlineview_with_window_function.out b/regression-test/data/correctness_p0/test_inlineview_with_window_function.out index 281bf5dd1b..778d5d8c71 100644 --- a/regression-test/data/correctness_p0/test_inlineview_with_window_function.out +++ b/regression-test/data/correctness_p0/test_inlineview_with_window_function.out @@ -2,3 +2,9 @@ -- !order -- 2023-06-10 cib2205045_1_1s 0.0000 168939.0 0.0000 0.0 0.0000 0.0 0.0000 day +-- !order2 -- +1 1 1 +2 2 2 +3 3 3 +4 4 4 + diff --git a/regression-test/suites/correctness_p0/test_inlineview_with_window_function.groovy b/regression-test/suites/correctness_p0/test_inlineview_with_window_function.groovy index cdeb65e9ec..1d3c7fdf58 100644 --- a/regression-test/suites/correctness_p0/test_inlineview_with_window_function.groovy +++ b/regression-test/suites/correctness_p0/test_inlineview_with_window_function.groovy @@ -151,4 +151,20 @@ suite("test_inlineview_with_window_function") { group by ordernum )tmp1 on tmp.ordernum=tmp1.ordernum;""" + + sql """set enable_nereids_planner=false;""" + qt_order2 """ + SELECT + row_number() over(partition by add_date order by pc_num desc) + ,row_number() over(partition by add_date order by vc_num desc) + ,row_number() over(partition by add_date order by vt_num desc) + FROM ( + SELECT + cast(dnt as datev2) add_date + ,row_number() over(order by dnt) pc_num + ,row_number() over(order by dnt) vc_num + ,row_number() over(order by dnt) vt_num + FROM test_table_aaa + ) t; + """ }