You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by mo...@apache.org on 2022/06/23 00:40:19 UTC
[doris] branch master updated: [fix][vectorized] Fix bug the of window function result not match plan nullable (#10340)
This is an automated email from the ASF dual-hosted git repository.
morningman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 46d20818f1 [fix][vectorized] Fix bug the of window function result not match plan nullable (#10340)
46d20818f1 is described below
commit 46d20818f1d71431b0c4fa8d097fd3e32b6c1521
Author: HappenLee <ha...@hotmail.com>
AuthorDate: Thu Jun 23 08:40:12 2022 +0800
[fix][vectorized] Fix bug the of window function result not match plan nullable (#10340)
Co-authored-by: lihaopeng <li...@baidu.com>
---
.../org/apache/doris/analysis/AggregateInfoBase.java | 2 +-
.../java/org/apache/doris/analysis/AnalyticInfo.java | 18 ++++++++++++++++++
.../java/org/apache/doris/planner/QueryPlanTest.java | 2 +-
.../window_functions/test_window_function.out | 9 +++++++++
.../window_functions/test_window_function.groovy | 8 +++++++-
5 files changed, 36 insertions(+), 3 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/AggregateInfoBase.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/AggregateInfoBase.java
index f0298afff6..69d833e86f 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/AggregateInfoBase.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/AggregateInfoBase.java
@@ -117,7 +117,7 @@ public abstract class AggregateInfoBase {
* Also updates the appropriate substitution map, and creates and registers auxiliary
* equality predicates between the grouping slots and the grouping exprs.
*/
- private TupleDescriptor createTupleDesc(Analyzer analyzer, boolean isOutputTuple) {
+ protected TupleDescriptor createTupleDesc(Analyzer analyzer, boolean isOutputTuple) {
TupleDescriptor result =
analyzer.getDescTbl().createTupleDescriptor(
tupleDebugName() + (isOutputTuple ? "-out" : "-intermed"));
diff --git a/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticInfo.java b/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticInfo.java
index aa993e34bf..6f79057697 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticInfo.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/analysis/AnalyticInfo.java
@@ -114,6 +114,24 @@ public final class AnalyticInfo extends AggregateInfoBase {
return result;
}
+ /**
+ * Creates the intermediate and output tuple descriptors. If no agg expr has an
+ * intermediate type different from its output type, then only the output tuple
+ * descriptor is created and the intermediate tuple is set to the output tuple.
+ * TODO: Rethink we really need to use Analyticinfo be subclass of AggregateInfoBase,
+ * it seems only use the aggregateExprs
+ */
+ protected void createTupleDescs(Analyzer analyzer) {
+ // Create the intermediate tuple desc first, so that the tuple ids are increasing
+ // from bottom to top in the plan tree.
+ intermediateTupleDesc = createTupleDesc(analyzer, false);
+ if (requiresIntermediateTuple(aggregateExprs, false)) {
+ outputTupleDesc = createTupleDesc(analyzer, true);
+ } else {
+ outputTupleDesc = intermediateTupleDesc;
+ }
+ }
+
/**
* Returns the intersection of the partition exprs of all the
* analytic functions.
diff --git a/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java b/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java
index a2a6c9e107..a71d484d5e 100644
--- a/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java
+++ b/fe/fe-core/src/test/java/org/apache/doris/planner/QueryPlanTest.java
@@ -1927,7 +1927,7 @@ public class QueryPlanTest extends TestWithFeService {
+ " on t1.k1 = a.x where 1 = 0;";
String explainStr = getSQLPlanOrErrorMsg(sql, true);
Assert.assertTrue(UtFrameUtils.checkPlanResultContainsNode(explainStr, 4, "EMPTYSET"));
- Assert.assertTrue(explainStr.contains("tuple ids: 0 1 5"));
+ Assert.assertTrue(explainStr.contains("tuple ids: 0 1 4"));
}
@Ignore
diff --git a/regression-test/data/query/sql_functions/window_functions/test_window_function.out b/regression-test/data/query/sql_functions/window_functions/test_window_function.out
index 57d5dd3e86..aa397abf64 100644
--- a/regression-test/data/query/sql_functions/window_functions/test_window_function.out
+++ b/regression-test/data/query/sql_functions/window_functions/test_window_function.out
@@ -17,6 +17,15 @@ JDR 2014-10-06T00:00 14.03 higher
JDR 2014-10-07T00:00 14.75 flat or lower
JDR 2014-10-08T00:00 13.98 flat or lower
+-- !sql --
+2014-10-07T00:00
+2014-10-06T00:00
+2014-10-05T00:00
+2014-10-04T00:00
+2014-10-03T00:00
+2014-10-02T00:00
+2014-10-02T00:00
+
-- !sql --
JDR 2014-10-02T00:00 12.86 0
JDR 2014-10-03T00:00 12.89 12.86
diff --git a/regression-test/suites/query/sql_functions/window_functions/test_window_function.groovy b/regression-test/suites/query/sql_functions/window_functions/test_window_function.groovy
index 69e4a4726c..da6b76e0f7 100644
--- a/regression-test/suites/query/sql_functions/window_functions/test_window_function.groovy
+++ b/regression-test/suites/query/sql_functions/window_functions/test_window_function.groovy
@@ -20,7 +20,7 @@ suite("test_window_function", "query") {
def windowFunctionTable1 = "test_window_function1"
sql """ DROP TABLE IF EXISTS ${windowFunctionTable1} """
- sql """ create table ${windowFunctionTable1} (stock_symbol varchar(64), closing_price decimal(8,2), closing_date datetime) duplicate key (stock_symbol) distributed by hash (stock_symbol) PROPERTIES("replication_num" = "1") """
+ sql """ create table ${windowFunctionTable1} (stock_symbol varchar(64), closing_price decimal(8,2), closing_date datetime not null) duplicate key (stock_symbol) distributed by hash (stock_symbol) PROPERTIES("replication_num" = "1") """
sql """ INSERT INTO ${windowFunctionTable1} VALUES ('JDR',12.86,'2014-10-02 00:00:00'),('JDR',12.89,'2014-10-03 00:00:00'),('JDR',12.94,'2014-10-04 00:00:00'),('JDR',12.55,'2014-10-05 00:00:00'),('JDR',14.03,'2014-10-06 00:00:00'),('JDR',14.75,'2014-10-07 00:00:00'),('JDR',13.98,'2014-10-08 00:00:00') """
@@ -47,6 +47,12 @@ suite("test_window_function", "query") {
ORDER BY
closing_date;
"""
+
+ // LEAD not nullable coredump
+ qt_sql """
+ select t1.new_time from (select closing_date, lead(closing_date, 1, '2014-10-02 00:00:00') over () as new_time from ${windowFunctionTable1}) as t1 left join ${windowFunctionTable1} t2 on t2.closing_date = t1.closing_date;
+ """
+
// LAG
qt_sql """
SELECT
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org