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

alamb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new 16589b56a1 Fix: handle NULL offset of NTH_VALUE window function 
(#12851)
16589b56a1 is described below

commit 16589b56a161a8ff13d16b3e55d7abbfb9d94f4b
Author: HuSen <[email protected]>
AuthorDate: Mon Oct 14 19:42:31 2024 +0800

    Fix: handle NULL offset of NTH_VALUE window function (#12851)
---
 datafusion/physical-expr/src/window/nth_value.rs | 2 +-
 datafusion/sqllogictest/test_files/window.slt    | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/datafusion/physical-expr/src/window/nth_value.rs 
b/datafusion/physical-expr/src/window/nth_value.rs
index d94983c5ad..6ec3a23fc5 100644
--- a/datafusion/physical-expr/src/window/nth_value.rs
+++ b/datafusion/physical-expr/src/window/nth_value.rs
@@ -185,7 +185,7 @@ impl PartitionEvaluator for NthValueEvaluator {
                         // Negative index represents reverse direction.
                         (n_range >= reverse_index, true)
                     }
-                    Ordering::Equal => (true, false),
+                    Ordering::Equal => (false, false),
                 }
             }
         };
diff --git a/datafusion/sqllogictest/test_files/window.slt 
b/datafusion/sqllogictest/test_files/window.slt
index 40309a1f2d..79cb91e183 100644
--- a/datafusion/sqllogictest/test_files/window.slt
+++ b/datafusion/sqllogictest/test_files/window.slt
@@ -4929,6 +4929,15 @@ SELECT v1, NTH_VALUE(v2, 0) OVER (PARTITION BY v1 ORDER 
BY v2) FROM t;
 2 NULL
 2 NULL
 
+query I
+SELECT NTH_VALUE(tt0.v1, NULL) OVER (PARTITION BY tt0.v2 ORDER BY tt0.v1) FROM 
t AS tt0;
+----
+NULL
+NULL
+NULL
+NULL
+NULL
+
 statement ok
 DROP TABLE t;
 


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to