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

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


The following commit(s) were added to refs/heads/master by this push:
     new f2ce2b9b0 bugfix: fix error when `get_coerced_window_frame` meet 
`utf8` (#5234)
f2ce2b9b0 is described below

commit f2ce2b9b0237e5d18af7b366307e35027c99d33b
Author: jakevin <[email protected]>
AuthorDate: Sat Feb 11 02:39:25 2023 +0800

    bugfix: fix error when `get_coerced_window_frame` meet `utf8` (#5234)
---
 datafusion/expr/src/type_coercion.rs      | 4 ++++
 datafusion/optimizer/src/type_coercion.rs | 4 ++--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/datafusion/expr/src/type_coercion.rs 
b/datafusion/expr/src/type_coercion.rs
index 02702b113..502925e9b 100644
--- a/datafusion/expr/src/type_coercion.rs
+++ b/datafusion/expr/src/type_coercion.rs
@@ -72,6 +72,10 @@ pub fn is_date(dt: &DataType) -> bool {
     matches!(dt, DataType::Date32 | DataType::Date64)
 }
 
+pub fn is_uft8(dt: &DataType) -> bool {
+    matches!(dt, DataType::Utf8)
+}
+
 pub mod aggregates;
 pub mod binary;
 pub mod functions;
diff --git a/datafusion/optimizer/src/type_coercion.rs 
b/datafusion/optimizer/src/type_coercion.rs
index 82c563765..6b6cea82f 100644
--- a/datafusion/optimizer/src/type_coercion.rs
+++ b/datafusion/optimizer/src/type_coercion.rs
@@ -34,7 +34,7 @@ use datafusion_expr::type_coercion::functions::data_types;
 use datafusion_expr::type_coercion::other::{
     get_coerce_type_for_case_when, get_coerce_type_for_list,
 };
-use datafusion_expr::type_coercion::{is_date, is_numeric, is_timestamp};
+use datafusion_expr::type_coercion::{is_date, is_numeric, is_timestamp, 
is_uft8};
 use datafusion_expr::utils::from_plan;
 use datafusion_expr::{
     aggregate_function, function, is_false, is_not_false, is_not_true, 
is_not_unknown,
@@ -478,7 +478,7 @@ fn get_coerced_window_frame(
     expressions: &[Expr],
 ) -> Result<WindowFrame> {
     fn get_coerced_type(column_type: &DataType) -> Result<DataType> {
-        if is_numeric(column_type) {
+        if is_numeric(column_type) | is_uft8(column_type) {
             Ok(column_type.clone())
         } else if is_timestamp(column_type) || is_date(column_type) {
             Ok(DataType::Interval(IntervalUnit::MonthDayNano))

Reply via email to