From 645428f59b838d0b6a2d3289089ec038932de93a Mon Sep 17 00:00:00 2001 From: jakevin Date: Sat, 25 Feb 2023 23:14:39 +0800 Subject: [PATCH] minor: support forgotten large_utf8 (#5393) --- datafusion/expr/src/type_coercion.rs | 6 +++--- datafusion/optimizer/src/type_coercion.rs | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/datafusion/expr/src/type_coercion.rs b/datafusion/expr/src/type_coercion.rs index ca624a877793..373f4a7a2d4a 100644 --- a/datafusion/expr/src/type_coercion.rs +++ b/datafusion/expr/src/type_coercion.rs @@ -72,9 +72,9 @@ pub fn is_date(dt: &DataType) -> bool { matches!(dt, DataType::Date32 | DataType::Date64) } -/// Determine whether the given data type `dt` is a `Utf8`. -pub fn is_utf8(dt: &DataType) -> bool { - matches!(dt, DataType::Utf8) +/// Determine whether the given data type `dt` is a `Utf8` or `LargeUtf8`. +pub fn is_utf8_or_large_utf8(dt: &DataType) -> bool { + matches!(dt, DataType::Utf8 | DataType::LargeUtf8) } pub mod aggregates; diff --git a/datafusion/optimizer/src/type_coercion.rs b/datafusion/optimizer/src/type_coercion.rs index a5f99e74ffb6..4031edcac6ca 100644 --- a/datafusion/optimizer/src/type_coercion.rs +++ b/datafusion/optimizer/src/type_coercion.rs @@ -34,7 +34,9 @@ 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, is_utf8}; +use datafusion_expr::type_coercion::{ + is_date, is_numeric, is_timestamp, is_utf8_or_large_utf8, +}; use datafusion_expr::utils::from_plan; use datafusion_expr::{ aggregate_function, function, is_false, is_not_false, is_not_true, is_not_unknown, @@ -525,7 +527,7 @@ fn coerce_window_frame( let target_type = match window_frame.units { WindowFrameUnits::Range => { if let Some(col_type) = current_types.first() { - if is_numeric(col_type) || is_utf8(col_type) { + if is_numeric(col_type) || is_utf8_or_large_utf8(col_type) { col_type } else if is_timestamp(col_type) || is_date(col_type) { &DataType::Interval(IntervalUnit::MonthDayNano)