From 8cf82f077a6a685bfc589827d054dc97a4e53e76 Mon Sep 17 00:00:00 2001 From: buraksenb Date: Sun, 3 Nov 2024 23:17:54 +0300 Subject: [PATCH] continue --- .../expr/src/built_in_window_function.rs | 105 +------ datafusion/functions-window/src/lib.rs | 3 + datafusion/functions-window/src/nth_value.rs | 290 +++++++++++------- datafusion/proto/src/generated/prost.rs | 84 +++-- datafusion/sql/src/expr/function.rs | 7 +- 5 files changed, 220 insertions(+), 269 deletions(-) diff --git a/datafusion/expr/src/built_in_window_function.rs b/datafusion/expr/src/built_in_window_function.rs index ab41395ad371..b1ba6d239ada 100644 --- a/datafusion/expr/src/built_in_window_function.rs +++ b/datafusion/expr/src/built_in_window_function.rs @@ -17,115 +17,12 @@ //! Built-in functions module contains all the built-in functions definitions. -use std::fmt; -use std::str::FromStr; - -use crate::type_coercion::functions::data_types; -use crate::utils; -use crate::{Signature, Volatility}; -use datafusion_common::{plan_datafusion_err, plan_err, DataFusionError, Result}; - -use arrow::datatypes::DataType; - use strum_macros::EnumIter; -impl fmt::Display for BuiltInWindowFunction { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{}", self.name()) - } -} - /// A [window function] built in to DataFusion /// /// [Window Function]: https://en.wikipedia.org/wiki/Window_function_(SQL) #[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Hash, EnumIter)] pub enum BuiltInWindowFunction { - /// returns value evaluated at the row that is the first row of the window frame - FirstValue, - /// Returns value evaluated at the row that is the last row of the window frame - LastValue, - /// Returns value evaluated at the row that is the nth row of the window frame (counting from 1); returns null if no such row - NthValue, -} - -impl BuiltInWindowFunction { - pub fn name(&self) -> &str { - use BuiltInWindowFunction::*; - match self { - FirstValue => "first_value", - LastValue => "last_value", - NthValue => "NTH_VALUE", - } - } -} - -impl FromStr for BuiltInWindowFunction { - type Err = DataFusionError; - fn from_str(name: &str) -> Result { - Ok(match name.to_uppercase().as_str() { - "FIRST_VALUE" => BuiltInWindowFunction::FirstValue, - "LAST_VALUE" => BuiltInWindowFunction::LastValue, - "NTH_VALUE" => BuiltInWindowFunction::NthValue, - _ => return plan_err!("There is no built-in window function named {name}"), - }) - } -} - -/// Returns the datatype of the built-in window function -impl BuiltInWindowFunction { - pub fn return_type(&self, input_expr_types: &[DataType]) -> Result { - // Note that this function *must* return the same type that the respective physical expression returns - // or the execution panics. - - // Verify that this is a valid set of data types for this function - data_types(input_expr_types, &self.signature()) - // Original errors are all related to wrong function signature - // Aggregate them for better error message - .map_err(|_| { - plan_datafusion_err!( - "{}", - utils::generate_signature_error_msg( - &format!("{self}"), - self.signature(), - input_expr_types, - ) - ) - })?; - - match self { - BuiltInWindowFunction::FirstValue - | BuiltInWindowFunction::LastValue - | BuiltInWindowFunction::NthValue => Ok(input_expr_types[0].clone()), - } - } - - /// The signatures supported by the built-in window function `fun`. - pub fn signature(&self) -> Signature { - // Note: The physical expression must accept the type returned by this function or the execution panics. - match self { - BuiltInWindowFunction::FirstValue | BuiltInWindowFunction::LastValue => { - Signature::any(1, Volatility::Immutable) - } - BuiltInWindowFunction::NthValue => Signature::any(2, Volatility::Immutable), - } - } -} - -#[cfg(test)] -mod tests { - use super::*; - use strum::IntoEnumIterator; - #[test] - // Test for BuiltInWindowFunction's Display and from_str() implementations. - // For each variant in BuiltInWindowFunction, it converts the variant to a string - // and then back to a variant. The test asserts that the original variant and - // the reconstructed variant are the same. This assertion is also necessary for - // function suggestion. See https://github.com/apache/datafusion/issues/8082 - fn test_display_and_from_str() { - for func_original in BuiltInWindowFunction::iter() { - let func_name = func_original.to_string(); - let func_from_str = BuiltInWindowFunction::from_str(&func_name).unwrap(); - assert_eq!(func_from_str, func_original); - } - } + Stub, } diff --git a/datafusion/functions-window/src/lib.rs b/datafusion/functions-window/src/lib.rs index 145457f32e2c..de6e25bd454f 100644 --- a/datafusion/functions-window/src/lib.rs +++ b/datafusion/functions-window/src/lib.rs @@ -22,6 +22,9 @@ //! //! [DataFusion]: https://crates.io/crates/datafusion //! + +extern crate core; + use std::sync::Arc; use log::debug; diff --git a/datafusion/functions-window/src/nth_value.rs b/datafusion/functions-window/src/nth_value.rs index e4e5e47600a1..5e36c15ce91d 100644 --- a/datafusion/functions-window/src/nth_value.rs +++ b/datafusion/functions-window/src/nth_value.rs @@ -17,17 +17,18 @@ //! `nth_value` window function implementation +use crate::utils::{get_scalar_value_from_args, get_signed_integer}; + use std::any::Any; use std::cmp::Ordering; use std::fmt::Debug; use std::ops::Range; use std::sync::OnceLock; -use crate::utils::{get_scalar_value_from_args, get_signed_integer}; use datafusion_common::arrow::array::ArrayRef; use datafusion_common::arrow::datatypes::{DataType, Field}; use datafusion_common::{Result, ScalarValue}; -use datafusion_expr::window_doc_sections::DOC_SECTION_RANKING; +use datafusion_expr::window_doc_sections::DOC_SECTION_ANALYTICAL; use datafusion_expr::window_state::WindowAggState; use datafusion_expr::{ Documentation, PartitionEvaluator, ReversedUDWF, Signature, TypeSignature, @@ -35,25 +36,26 @@ use datafusion_expr::{ }; use datafusion_functions_window_common::field; use datafusion_functions_window_common::partition::PartitionEvaluatorArgs; + use field::WindowUDFFieldArgs; define_udwf_and_expr!( First, first_value, "returns the first value in the window frame", - NthValue::first + NthValue::first_value ); define_udwf_and_expr!( Last, last_value, "returns the last value in the window frame", - NthValue::last + NthValue::last_value ); define_udwf_and_expr!( NthValue, nth_value, "returns the nth value in the window frame", - NthValue::nth + NthValue::nth_value ); /// Tag to differentiate special use cases of the NTH_VALUE built-in window function. @@ -67,9 +69,9 @@ pub enum NthValueKind { impl NthValueKind { fn name(&self) -> &'static str { match self { - NthValueKind::First => "first", - NthValueKind::Last => "last", - NthValueKind::Nth => "nth", + NthValueKind::First => "first_value", + NthValueKind::Last => "last_value", + NthValueKind::Nth => "nth_value", } } } @@ -87,7 +89,8 @@ impl NthValue { signature: Signature::one_of( vec![ TypeSignature::Any(0), - TypeSignature::Exact(vec![DataType::UInt64]), + TypeSignature::Any(1), + TypeSignature::Any(2), ], Volatility::Immutable, ), @@ -95,27 +98,69 @@ impl NthValue { } } - pub fn first() -> Self { + pub fn first_value() -> Self { Self::new(NthValueKind::First) } - pub fn last() -> Self { + pub fn last_value() -> Self { Self::new(NthValueKind::Last) } - pub fn nth() -> Self { + pub fn nth_value() -> Self { Self::new(NthValueKind::Nth) } } -static DOCUMENTATION: OnceLock = OnceLock::new(); +static FIRST_VALUE_DOCUMENTATION: OnceLock = OnceLock::new(); + +fn get_first_value_doc() -> &'static Documentation { + FIRST_VALUE_DOCUMENTATION.get_or_init(|| { + Documentation::builder() + .with_doc_section(DOC_SECTION_ANALYTICAL) + .with_description( + "Returns value evaluated at the row that is the first row of the window \ + frame.", + ) + .with_syntax_example("first_value(expression)") + .with_argument("expression", "Expression to operate on") + .build() + .unwrap() + }) +} + +static LAST_VALUE_DOCUMENTATION: OnceLock = OnceLock::new(); -fn get_ntile_doc() -> &'static Documentation { - DOCUMENTATION.get_or_init(|| { +fn get_last_value_doc() -> &'static Documentation { + LAST_VALUE_DOCUMENTATION.get_or_init(|| { Documentation::builder() - .with_doc_section(DOC_SECTION_RANKING) + .with_doc_section(DOC_SECTION_ANALYTICAL) .with_description( - "Integer ranging from 1 to the argument value, dividing the partition as equally as possible", + "Returns value evaluated at the row that is the last row of the window \ + frame.", ) + .with_syntax_example("last_value(expression)") + .with_argument("expression", "Expression to operate on") + .build() + .unwrap() + }) +} + +static NTH_VALUE_DOCUMENTATION: OnceLock = OnceLock::new(); + +fn get_nth_value_doc() -> &'static Documentation { + NTH_VALUE_DOCUMENTATION.get_or_init(|| { + Documentation::builder() + .with_doc_section(DOC_SECTION_ANALYTICAL) + .with_description( + "Returns value evaluated at the row that is the nth row of the window \ + frame (counting from 1); null if no such row.", + ) + .with_syntax_example("nth_value(expression, n)") + .with_argument( + "expression", + "The name the column of which nth \ + value to retrieve", + ) + .with_argument("n", "Integer. Specifies the n in nth") .build() .unwrap() }) @@ -166,7 +211,7 @@ impl WindowUDFImpl for NthValue { } fn field(&self, field_args: WindowUDFFieldArgs) -> Result { - let nullable = false; + let nullable = true; Ok(Field::new(field_args.name(), DataType::UInt64, nullable)) } @@ -180,7 +225,11 @@ impl WindowUDFImpl for NthValue { } fn documentation(&self) -> Option<&Documentation> { - Some(get_ntile_doc()) + match self.kind { + NthValueKind::First => Some(get_first_value_doc()), + NthValueKind::Last => Some(get_last_value_doc()), + NthValueKind::Nth => Some(get_nth_value_doc()), + } } } @@ -362,102 +411,111 @@ impl PartitionEvaluator for NthValueEvaluator { #[cfg(test)] mod tests { + use super::*; + use arrow::array::*; + use datafusion_common::cast::as_int32_array; + use datafusion_physical_expr::expressions::{Column, Literal}; + use datafusion_physical_expr_common::physical_expr::PhysicalExpr; + use std::sync::Arc; - // fn test_i32_result(expr: NthValue, expected: Int32Array) -> Result<()> { - // let arr: ArrayRef = Arc::new(Int32Array::from(vec![1, -2, 3, -4, 5, -6, 7, 8])); - // let values = vec![arr]; - // let schema = Schema::new(vec![Field::new("arr", DataType::Int32, false)]); - // let batch = RecordBatch::try_new(Arc::new(schema), values.clone())?; - // let mut ranges: Vec> = vec![]; - // for i in 0..8 { - // ranges.push(Range { - // start: 0, - // end: i + 1, - // }) - // } - // let mut evaluator = expr.create_evaluator()?; - // let values = expr.evaluate_args(&batch)?; - // let result = ranges - // .iter() - // .map(|range| evaluator.evaluate(&values, range)) - // .collect::>>()?; - // let result = ScalarValue::iter_to_array(result.into_iter())?; - // let result = as_int32_array(&result)?; - // assert_eq!(expected, *result); - // Ok(()) - // } - // - // // #[test] - // // fn first_value() -> Result<()> { - // // let first_value = NthValue::first( - // // "first_value".to_owned(), - // // Arc::new(Column::new("arr", 0)), - // // DataType::Int32, - // // false, - // // ); - // // test_i32_result(first_value, Int32Array::from(vec![1; 8]))?; - // // Ok(()) - // // } - // // - // // #[test] - // // fn last_value() -> Result<()> { - // // let last_value = NthValue::last( - // // "last_value".to_owned(), - // // Arc::new(Column::new("arr", 0)), - // // DataType::Int32, - // // false, - // // ); - // // test_i32_result( - // // last_value, - // // Int32Array::from(vec![ - // // Some(1), - // // Some(-2), - // // Some(3), - // // Some(-4), - // // Some(5), - // // Some(-6), - // // Some(7), - // // Some(8), - // // ]), - // // )?; - // // Ok(()) - // // } - // // - // // #[test] - // // fn nth_value_1() -> Result<()> { - // // let nth_value = NthValue::nth( - // // "nth_value".to_owned(), - // // Arc::new(Column::new("arr", 0)), - // // DataType::Int32, - // // 1, - // // false, - // // )?; - // // test_i32_result(nth_value, Int32Array::from(vec![1; 8]))?; - // // Ok(()) - // // } - // // - // // #[test] - // // fn nth_value_2() -> Result<()> { - // // let nth_value = NthValue::nth( - // // "nth_value".to_owned(), - // // Arc::new(Column::new("arr", 0)), - // // DataType::Int32, - // // 2, - // // false, - // // )?; - // // test_i32_result( - // // nth_value, - // // Int32Array::from(vec![ - // // None, - // // Some(-2), - // // Some(-2), - // // Some(-2), - // // Some(-2), - // // Some(-2), - // // Some(-2), - // // Some(-2), - // // ]), - // // )?; - // // Ok(()) - // // } + fn test_i32_result( + expr: NthValue, + partition_evaluator_args: PartitionEvaluatorArgs, + expected: Int32Array, + ) -> Result<()> { + let arr: ArrayRef = Arc::new(Int32Array::from(vec![1, -2, 3, -4, 5, -6, 7, 8])); + let values = vec![arr]; + let mut ranges: Vec> = vec![]; + for i in 0..8 { + ranges.push(Range { + start: 0, + end: i + 1, + }) + } + let mut evaluator = expr.partition_evaluator(partition_evaluator_args)?; + let result = ranges + .iter() + .map(|range| evaluator.evaluate(&values, range)) + .collect::>>()?; + let result = ScalarValue::iter_to_array(result.into_iter())?; + let result = as_int32_array(&result)?; + assert_eq!(expected, *result); + Ok(()) + } + + #[test] + fn first_value() -> Result<()> { + let expr = Arc::new(Column::new("c3", 0)) as Arc; + test_i32_result( + NthValue::first_value(), + PartitionEvaluatorArgs::new(&[expr], &[DataType::Int32], false, false), + Int32Array::from(vec![1; 8]).iter().collect::(), + ) + } + + #[test] + fn last_value() -> Result<()> { + let expr = Arc::new(Column::new("c3", 0)) as Arc; + test_i32_result( + NthValue::last_value(), + PartitionEvaluatorArgs::new(&[expr], &[DataType::Int32], false, false), + Int32Array::from(vec![ + Some(1), + Some(-2), + Some(3), + Some(-4), + Some(5), + Some(-6), + Some(7), + Some(8), + ]), + ) + } + + #[test] + fn nth_value_1() -> Result<()> { + let expr = Arc::new(Column::new("c3", 0)) as Arc; + let n_value = + Arc::new(Literal::new(ScalarValue::Int32(Some(1)))) as Arc; + + test_i32_result( + NthValue::nth_value(), + PartitionEvaluatorArgs::new( + &[expr, n_value], + &[DataType::Int32], + false, + false, + ), + Int32Array::from(vec![1; 8]), + )?; + Ok(()) + } + + #[test] + fn nth_value_2() -> Result<()> { + let expr = Arc::new(Column::new("c3", 0)) as Arc; + let n_value = + Arc::new(Literal::new(ScalarValue::Int32(Some(2)))) as Arc; + + test_i32_result( + NthValue::nth_value(), + PartitionEvaluatorArgs::new( + &[expr, n_value], + &[DataType::Int32], + false, + false, + ), + Int32Array::from(vec![ + None, + Some(-2), + Some(-2), + Some(-2), + Some(-2), + Some(-2), + Some(-2), + Some(-2), + ]), + )?; + Ok(()) + } } diff --git a/datafusion/proto/src/generated/prost.rs b/datafusion/proto/src/generated/prost.rs index 228f20d98b9a..dfc30e809108 100644 --- a/datafusion/proto/src/generated/prost.rs +++ b/datafusion/proto/src/generated/prost.rs @@ -117,11 +117,10 @@ pub struct ListingTableScanNode { pub target_partitions: u32, #[prost(message, repeated, tag = "13")] pub file_sort_order: ::prost::alloc::vec::Vec, - #[prost( - oneof = "listing_table_scan_node::FileFormatType", - tags = "10, 11, 12, 15" - )] - pub file_format_type: ::core::option::Option, + #[prost(oneof = "listing_table_scan_node::FileFormatType", tags = "10, 11, 12, 15")] + pub file_format_type: ::core::option::Option< + listing_table_scan_node::FileFormatType, + >, } /// Nested message and enum types in `ListingTableScanNode`. pub mod listing_table_scan_node { @@ -257,8 +256,10 @@ pub struct CreateExternalTableNode { #[prost(message, optional, tag = "12")] pub constraints: ::core::option::Option, #[prost(map = "string, message", tag = "13")] - pub column_defaults: - ::std::collections::HashMap<::prost::alloc::string::String, LogicalExprNode>, + pub column_defaults: ::std::collections::HashMap< + ::prost::alloc::string::String, + LogicalExprNode, + >, } #[derive(Clone, PartialEq, ::prost::Message)] pub struct PrepareNode { @@ -744,6 +745,8 @@ pub struct WindowExprNode { pub mod window_expr_node { #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum WindowFunction { + #[prost(enumeration = "super::BuiltInWindowFunction", tag = "2")] + BuiltInFunction(i32), #[prost(string, tag = "3")] Udaf(::prost::alloc::string::String), #[prost(string, tag = "9")] @@ -950,7 +953,9 @@ pub struct FullTableReference { #[derive(Clone, PartialEq, ::prost::Message)] pub struct TableReference { #[prost(oneof = "table_reference::TableReferenceEnum", tags = "1, 2, 3")] - pub table_reference_enum: ::core::option::Option, + pub table_reference_enum: ::core::option::Option< + table_reference::TableReferenceEnum, + >, } /// Nested message and enum types in `TableReference`. pub mod table_reference { @@ -1068,8 +1073,9 @@ pub struct JsonSink { #[prost(message, optional, tag = "1")] pub config: ::core::option::Option, #[prost(message, optional, tag = "2")] - pub writer_options: - ::core::option::Option, + pub writer_options: ::core::option::Option< + super::datafusion_common::JsonWriterOptions, + >, } #[derive(Clone, PartialEq, ::prost::Message)] pub struct JsonSinkExecNode { @@ -1087,8 +1093,9 @@ pub struct CsvSink { #[prost(message, optional, tag = "1")] pub config: ::core::option::Option, #[prost(message, optional, tag = "2")] - pub writer_options: - ::core::option::Option, + pub writer_options: ::core::option::Option< + super::datafusion_common::CsvWriterOptions, + >, } #[derive(Clone, PartialEq, ::prost::Message)] pub struct CsvSinkExecNode { @@ -1106,8 +1113,9 @@ pub struct ParquetSink { #[prost(message, optional, tag = "1")] pub config: ::core::option::Option, #[prost(message, optional, tag = "2")] - pub parquet_options: - ::core::option::Option, + pub parquet_options: ::core::option::Option< + super::datafusion_common::TableParquetOptions, + >, } #[derive(Clone, PartialEq, ::prost::Message)] pub struct ParquetSinkExecNode { @@ -1227,8 +1235,9 @@ pub struct PhysicalAggregateExprNode { #[prost(bytes = "vec", optional, tag = "7")] pub fun_definition: ::core::option::Option<::prost::alloc::vec::Vec>, #[prost(oneof = "physical_aggregate_expr_node::AggregateFunction", tags = "4")] - pub aggregate_function: - ::core::option::Option, + pub aggregate_function: ::core::option::Option< + physical_aggregate_expr_node::AggregateFunction, + >, } /// Nested message and enum types in `PhysicalAggregateExprNode`. pub mod physical_aggregate_expr_node { @@ -1253,13 +1262,16 @@ pub struct PhysicalWindowExprNode { #[prost(bytes = "vec", optional, tag = "9")] pub fun_definition: ::core::option::Option<::prost::alloc::vec::Vec>, #[prost(oneof = "physical_window_expr_node::WindowFunction", tags = "2, 3")] - pub window_function: - ::core::option::Option, + pub window_function: ::core::option::Option< + physical_window_expr_node::WindowFunction, + >, } /// Nested message and enum types in `PhysicalWindowExprNode`. pub mod physical_window_expr_node { #[derive(Clone, PartialEq, ::prost::Oneof)] pub enum WindowFunction { + #[prost(enumeration = "super::BuiltInWindowFunction", tag = "2")] + BuiltInFunction(i32), #[prost(string, tag = "3")] UserDefinedAggrFunction(::prost::alloc::string::String), } @@ -1771,7 +1783,9 @@ pub struct PartitionedFile { #[prost(uint64, tag = "3")] pub last_modified_ns: u64, #[prost(message, repeated, tag = "4")] - pub partition_values: ::prost::alloc::vec::Vec, + pub partition_values: ::prost::alloc::vec::Vec< + super::datafusion_common::ScalarValue, + >, #[prost(message, optional, tag = "5")] pub range: ::core::option::Option, #[prost(message, optional, tag = "6")] @@ -1795,9 +1809,7 @@ pub struct PartitionStats { #[prost(message, repeated, tag = "4")] pub column_stats: ::prost::alloc::vec::Vec, } -#[derive( - Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration, -)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum BuiltInWindowFunction { /// @@ -1838,9 +1850,7 @@ impl BuiltInWindowFunction { } } } -#[derive( - Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration, -)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum WindowFrameUnits { Rows = 0, @@ -1869,9 +1879,7 @@ impl WindowFrameUnits { } } } -#[derive( - Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration, -)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum WindowFrameBoundType { CurrentRow = 0, @@ -1900,9 +1908,7 @@ impl WindowFrameBoundType { } } } -#[derive( - Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration, -)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum DateUnit { Day = 0, @@ -1928,9 +1934,7 @@ impl DateUnit { } } } -#[derive( - Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration, -)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum InsertOp { Append = 0, @@ -1959,9 +1963,7 @@ impl InsertOp { } } } -#[derive( - Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration, -)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum PartitionMode { CollectLeft = 0, @@ -1990,9 +1992,7 @@ impl PartitionMode { } } } -#[derive( - Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration, -)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum StreamPartitionMode { SinglePartition = 0, @@ -2018,9 +2018,7 @@ impl StreamPartitionMode { } } } -#[derive( - Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration, -)] +#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)] #[repr(i32)] pub enum AggregateMode { Partial = 0, diff --git a/datafusion/sql/src/expr/function.rs b/datafusion/sql/src/expr/function.rs index a569119f7d08..cb7255bb7873 100644 --- a/datafusion/sql/src/expr/function.rs +++ b/datafusion/sql/src/expr/function.rs @@ -23,20 +23,16 @@ use datafusion_common::{ DFSchema, Dependency, Result, }; use datafusion_expr::expr::WildcardOptions; +use datafusion_expr::expr::{ScalarFunction, Unnest}; use datafusion_expr::planner::PlannerResult; use datafusion_expr::{ expr, Expr, ExprFunctionExt, ExprSchemable, WindowFrame, WindowFunctionDefinition, }; -use datafusion_expr::{ - expr::{ScalarFunction, Unnest}, - BuiltInWindowFunction, -}; use sqlparser::ast::{ DuplicateTreatment, Expr as SQLExpr, Function as SQLFunction, FunctionArg, FunctionArgExpr, FunctionArgumentClause, FunctionArgumentList, FunctionArguments, NullTreatment, ObjectName, OrderByExpr, WindowType, }; -use strum::IntoEnumIterator; /// Suggest a valid function based on an invalid input function name /// @@ -52,7 +48,6 @@ pub fn suggest_valid_function( let mut funcs = Vec::new(); funcs.extend(ctx.udaf_names()); - funcs.extend(BuiltInWindowFunction::iter().map(|func| func.to_string())); funcs.extend(ctx.udwf_names()); funcs