You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@arrow.apache.org by al...@apache.org on 2023/12/07 22:34:04 UTC

(arrow-datafusion) branch main updated: fix: ORDER BY window definition should work on null (#8444)

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/arrow-datafusion.git


The following commit(s) were added to refs/heads/main by this push:
     new 9be9073703 fix: ORDER BY window definition should work on null (#8444)
9be9073703 is described below

commit 9be9073703e439eef8fe25c375a32bc40da7ce21
Author: Liang-Chi Hsieh <vi...@gmail.com>
AuthorDate: Thu Dec 7 14:33:58 2023 -0800

    fix: ORDER BY window definition should work on null (#8444)
---
 datafusion/optimizer/src/analyzer/type_coercion.rs | 5 ++++-
 datafusion/sqllogictest/test_files/window.slt      | 8 ++++++++
 2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/datafusion/optimizer/src/analyzer/type_coercion.rs b/datafusion/optimizer/src/analyzer/type_coercion.rs
index e3b86f5db7..91611251d9 100644
--- a/datafusion/optimizer/src/analyzer/type_coercion.rs
+++ b/datafusion/optimizer/src/analyzer/type_coercion.rs
@@ -503,7 +503,10 @@ fn coerce_window_frame(
     let target_type = match window_frame.units {
         WindowFrameUnits::Range => {
             if let Some(col_type) = current_types.first() {
-                if col_type.is_numeric() || is_utf8_or_large_utf8(col_type) {
+                if col_type.is_numeric()
+                    || is_utf8_or_large_utf8(col_type)
+                    || matches!(col_type, DataType::Null)
+                {
                     col_type
                 } else if is_datetime(col_type) {
                     &DataType::Interval(IntervalUnit::MonthDayNano)
diff --git a/datafusion/sqllogictest/test_files/window.slt b/datafusion/sqllogictest/test_files/window.slt
index 0179431ac8..5b69ead0ff 100644
--- a/datafusion/sqllogictest/test_files/window.slt
+++ b/datafusion/sqllogictest/test_files/window.slt
@@ -3785,3 +3785,11 @@ select a,
 ----
 1 1
 2 1
+
+query II
+select a,
+       rank() over (order by null RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING) rnk
+       from (select 1 a union select 2 a) q ORDER BY a
+----
+1 1
+2 1