Apache DataFusion SQL Query Engine
consistent logical & physical NTILE return types (#8270)
Eduard Karacharov47b4972329be
diff --git a/datafusion/expr/src/window_function.rs b/datafusion/expr/src/window_function.rsindex 35b7bded70..946a80dd84 100644--- a/datafusion/expr/src/window_function.rs+++ b/datafusion/expr/src/window_function.rs@@ -205,7 +205,7 @@ impl BuiltInWindowFunction {BuiltInWindowFunction::PercentRank | BuiltInWindowFunction::CumeDist => {Ok(DataType::Float64)}- BuiltInWindowFunction::Ntile => Ok(DataType::UInt32),+ BuiltInWindowFunction::Ntile => Ok(DataType::UInt64),BuiltInWindowFunction::Lag| BuiltInWindowFunction::Lead| BuiltInWindowFunction::FirstValue@@ -369,6 +369,15 @@ mod tests {Ok(())}+ #[test]+ fn test_ntile_return_type() -> Result<()> {+ let fun = find_df_window_func("ntile").unwrap();+ let observed = fun.return_type(&[DataType::Int16])?;+ assert_eq!(DataType::UInt64, observed);++ Ok(())+ }+#[test]fn test_window_function_case_insensitive() -> Result<()> {let names = vec![diff --git a/datafusion/sqllogictest/test_files/window.slt b/datafusion/sqllogictest/test_files/window.sltindex a3c57a67a6..1ef0ba0d10 100644--- a/datafusion/sqllogictest/test_files/window.slt+++ b/datafusion/sqllogictest/test_files/window.slt@@ -3522,3 +3522,10 @@ SortPreservingMergeExec: [c@3 ASC NULLS LAST]--------SortPreservingRepartitionExec: partitioning=Hash([d@4], 2), input_partitions=2, sort_exprs=a@1 ASC NULLS LAST,b@2 ASC NULLS LAST----------RepartitionExec: partitioning=RoundRobinBatch(2), input_partitions=1------------StreamingTableExec: partition_sizes=1, projection=[a0, a, b, c, d], infinite_source=true, output_ordering=[a@1 ASC NULLS LAST, b@2 ASC NULLS LAST]++# CTAS with NTILE function+statement ok+CREATE TABLE new_table AS SELECT NTILE(2) OVER(ORDER BY c1) AS ntile_2 FROM aggregate_test_100;++statement ok+DROP TABLE new_table;