This is an automated email from the ASF dual-hosted git repository.

yiguolei 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 c715facafae [fix](window_function) window function 
first_value/last_value should be always nullable (#26014)
c715facafae is described below

commit c715facafae6d80852aeead07358b8a32b2fdb89
Author: Jerry Hu <mrh...@gmail.com>
AuthorDate: Fri Oct 27 20:53:48 2023 +0800

    [fix](window_function) window function first_value/last_value should be 
always nullable (#26014)
---
 .../src/main/java/org/apache/doris/catalog/AggregateFunction.java  | 3 ++-
 .../trees/expressions/functions/window/FirstOrLastValue.java       | 4 ++--
 regression-test/data/correctness_p0/test_first_value_window.out    | 7 +++++++
 .../suites/correctness_p0/test_first_value_window.groovy           | 7 +++++++
 4 files changed, 18 insertions(+), 3 deletions(-)

diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/catalog/AggregateFunction.java 
b/fe/fe-core/src/main/java/org/apache/doris/catalog/AggregateFunction.java
index 19894668360..d954ab41a95 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/catalog/AggregateFunction.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/catalog/AggregateFunction.java
@@ -58,7 +58,8 @@ public class AggregateFunction extends Function {
             FunctionSet.ARRAY_AGG, FunctionSet.COLLECT_LIST, 
FunctionSet.COLLECT_SET);
 
     public static ImmutableSet<String> 
ALWAYS_NULLABLE_AGGREGATE_FUNCTION_NAME_SET =
-            ImmutableSet.of("stddev_samp", "variance_samp", "var_samp", 
"percentile_approx");
+            ImmutableSet.of("stddev_samp", "variance_samp", "var_samp", 
"percentile_approx", "first_value",
+                    "last_value");
 
     public static ImmutableSet<String> CUSTOM_AGGREGATE_FUNCTION_NAME_SET =
             ImmutableSet.of("group_concat");
diff --git 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/window/FirstOrLastValue.java
 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/window/FirstOrLastValue.java
index 0cbccad58de..463fe41aab2 100644
--- 
a/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/window/FirstOrLastValue.java
+++ 
b/fe/fe-core/src/main/java/org/apache/doris/nereids/trees/expressions/functions/window/FirstOrLastValue.java
@@ -19,8 +19,8 @@ package 
org.apache.doris.nereids.trees.expressions.functions.window;
 
 import org.apache.doris.catalog.FunctionSignature;
 import org.apache.doris.nereids.trees.expressions.Expression;
+import org.apache.doris.nereids.trees.expressions.functions.AlwaysNullable;
 import 
org.apache.doris.nereids.trees.expressions.functions.ExplicitlyCastableSignature;
-import org.apache.doris.nereids.trees.expressions.functions.PropagateNullable;
 import org.apache.doris.nereids.trees.expressions.shape.UnaryExpression;
 import org.apache.doris.nereids.types.coercion.AnyDataType;
 
@@ -30,7 +30,7 @@ import java.util.List;
 
 /** parent class for first_value() and last_value() */
 public abstract class FirstOrLastValue extends WindowFunction
-        implements UnaryExpression, PropagateNullable, 
ExplicitlyCastableSignature {
+        implements UnaryExpression, AlwaysNullable, 
ExplicitlyCastableSignature {
 
     private static final List<FunctionSignature> SIGNATURES = ImmutableList.of(
             
FunctionSignature.retArgType(0).args(AnyDataType.INSTANCE_WITHOUT_INDEX)
diff --git a/regression-test/data/correctness_p0/test_first_value_window.out 
b/regression-test/data/correctness_p0/test_first_value_window.out
index d0cecdaccf8..cabae5b19ab 100644
--- a/regression-test/data/correctness_p0/test_first_value_window.out
+++ b/regression-test/data/correctness_p0/test_first_value_window.out
@@ -13,3 +13,10 @@
 23     04-23-10        ["p7", "year4"] ["p7", "year4"]
 24     02-24-10-21     [""]    [""]
 
+-- !select_always_nullable --
+21     04-21-11        ["amory", "clever"]     \N      \N
+22     04-22-10-21     ["doris", "aws", "greate"]      \N      \N
+22     04-22-10-21     ["is ", "cute", "tea"]  1       999
+23     04-23-10        ["p7", "year4"] \N      \N
+24     02-24-10-21     [""]    \N      \N
+
diff --git 
a/regression-test/suites/correctness_p0/test_first_value_window.groovy 
b/regression-test/suites/correctness_p0/test_first_value_window.groovy
index 637b9f71616..25246445fbb 100644
--- a/regression-test/suites/correctness_p0/test_first_value_window.groovy
+++ b/regression-test/suites/correctness_p0/test_first_value_window.groovy
@@ -74,4 +74,11 @@ suite("test_first_value_window") {
 
     qt_select_default """ select *,first_value(state) over(partition by myday 
order by time_col range between current row and unbounded following) from 
${tableName1} order by myday, time_col; """
 
+    qt_select_always_nullable """
+        select
+            *,
+            first_value(1) over(partition by myday order by time_col rows  
between 1 preceding and 1 preceding) first_value,
+            last_value(999) over(partition by myday order by time_col rows  
between 1 preceding and 1 preceding) last_value
+        from test_first_value_window_array order by myday, time_col;
+    """
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to