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 47b4972329 consistent logical & physical NTILE return types (#8270)
47b4972329 is described below

commit 47b4972329be053d20801887e34d978cd5f99448
Author: Eduard Karacharov <[email protected]>
AuthorDate: Tue Nov 21 22:20:23 2023 +0200

    consistent logical & physical NTILE return types (#8270)
---
 datafusion/expr/src/window_function.rs        | 11 ++++++++++-
 datafusion/sqllogictest/test_files/window.slt |  7 +++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/datafusion/expr/src/window_function.rs 
b/datafusion/expr/src/window_function.rs
index 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.slt
index 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;

Reply via email to