This is an automated email from the ASF dual-hosted git repository. findepi pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/datafusion.git
The following commit(s) were added to refs/heads/main by this push: new 541a67d12c Remove elements deprecated since v 45 (#17075) 541a67d12c is described below commit 541a67d12c3c94278facec3a1fc60fb959d4eb62 Author: Piotr Findeisen <piotr.findei...@gmail.com> AuthorDate: Fri Aug 8 07:53:11 2025 +0200 Remove elements deprecated since v 45 (#17075) They were deprecated since 45.0.0, which was released 6 months ago. --- datafusion/common/src/utils/mod.rs | 116 -------- datafusion/core/src/execution/session_state.rs | 11 - datafusion/core/src/lib.rs | 7 - datafusion/doc/src/lib.rs | 9 - datafusion/execution/src/runtime_env.rs | 19 +- datafusion/expr-common/src/operator.rs | 9 - datafusion/expr/src/expr.rs | 10 - datafusion/functions-aggregate-common/src/utils.rs | 61 +--- datafusion/functions/src/strings.rs | 39 +-- datafusion/optimizer/src/analyzer/mod.rs | 8 - .../physical-expr-common/src/physical_expr.rs | 15 - datafusion/physical-expr/src/aggregate.rs | 5 +- datafusion/physical-expr/src/window/mod.rs | 6 - .../physical-optimizer/src/join_selection.rs | 52 +--- datafusion/physical-plan/src/lib.rs | 1 - datafusion/physical-plan/src/values.rs | 330 --------------------- datafusion/sql/src/unparser/dialect.rs | 11 - 17 files changed, 12 insertions(+), 697 deletions(-) diff --git a/datafusion/common/src/utils/mod.rs b/datafusion/common/src/utils/mod.rs index ad2bab879a..404f13b4df 100644 --- a/datafusion/common/src/utils/mod.rs +++ b/datafusion/common/src/utils/mod.rs @@ -444,94 +444,6 @@ impl SingleRowListArrayBuilder { } } -/// Wrap an array into a single element `ListArray`. -/// For example `[1, 2, 3]` would be converted into `[[1, 2, 3]]` -/// The field in the list array is nullable. -#[deprecated( - since = "44.0.0", - note = "please use `SingleRowListArrayBuilder` instead" -)] -pub fn array_into_list_array_nullable(arr: ArrayRef) -> ListArray { - SingleRowListArrayBuilder::new(arr) - .with_nullable(true) - .build_list_array() -} - -/// Wrap an array into a single element `ListArray`. -/// For example `[1, 2, 3]` would be converted into `[[1, 2, 3]]` -#[deprecated( - since = "44.0.0", - note = "please use `SingleRowListArrayBuilder` instead" -)] -pub fn array_into_list_array(arr: ArrayRef, nullable: bool) -> ListArray { - SingleRowListArrayBuilder::new(arr) - .with_nullable(nullable) - .build_list_array() -} - -#[deprecated( - since = "44.0.0", - note = "please use `SingleRowListArrayBuilder` instead" -)] -pub fn array_into_list_array_with_field_name( - arr: ArrayRef, - nullable: bool, - field_name: &str, -) -> ListArray { - SingleRowListArrayBuilder::new(arr) - .with_nullable(nullable) - .with_field_name(Some(field_name.to_string())) - .build_list_array() -} - -/// Wrap an array into a single element `LargeListArray`. -/// For example `[1, 2, 3]` would be converted into `[[1, 2, 3]]` -#[deprecated( - since = "44.0.0", - note = "please use `SingleRowListArrayBuilder` instead" -)] -pub fn array_into_large_list_array(arr: ArrayRef) -> LargeListArray { - SingleRowListArrayBuilder::new(arr).build_large_list_array() -} - -#[deprecated( - since = "44.0.0", - note = "please use `SingleRowListArrayBuilder` instead" -)] -pub fn array_into_large_list_array_with_field_name( - arr: ArrayRef, - field_name: &str, -) -> LargeListArray { - SingleRowListArrayBuilder::new(arr) - .with_field_name(Some(field_name.to_string())) - .build_large_list_array() -} - -#[deprecated( - since = "44.0.0", - note = "please use `SingleRowListArrayBuilder` instead" -)] -pub fn array_into_fixed_size_list_array( - arr: ArrayRef, - list_size: usize, -) -> FixedSizeListArray { - SingleRowListArrayBuilder::new(arr).build_fixed_size_list_array(list_size) -} - -#[deprecated( - since = "44.0.0", - note = "please use `SingleRowListArrayBuilder` instead" -)] -pub fn array_into_fixed_size_list_array_with_field_name( - arr: ArrayRef, - list_size: usize, - field_name: &str, -) -> FixedSizeListArray { - SingleRowListArrayBuilder::new(arr) - .with_field_name(Some(field_name.to_string())) - .build_fixed_size_list_array(list_size) -} - /// Wrap arrays into a single element `ListArray`. /// /// Example: @@ -832,21 +744,6 @@ pub fn set_difference<T: Borrow<usize>, S: Borrow<usize>>( .collect() } -/// Checks whether the given index sequence is monotonically non-decreasing. -#[deprecated(since = "45.0.0", note = "Use std::Iterator::is_sorted instead")] -pub fn is_sorted<T: Borrow<usize>>(sequence: impl IntoIterator<Item = T>) -> bool { - // TODO: Remove this function when `is_sorted` graduates from Rust nightly. - let mut previous = 0; - for item in sequence.into_iter() { - let current = *item.borrow(); - if current < previous { - return false; - } - previous = current; - } - true -} - /// Find indices of each element in `targets` inside `items`. If one of the /// elements is absent in `items`, returns an error. pub fn find_indices<T: PartialEq, S: Borrow<T>>( @@ -1274,19 +1171,6 @@ mod tests { assert_eq!(set_difference([3, 4, 0], [4, 1, 2]), vec![3, 0]); } - #[test] - #[expect(deprecated)] - fn test_is_sorted() { - assert!(is_sorted::<usize>([])); - assert!(is_sorted([0])); - assert!(is_sorted([0, 3, 4])); - assert!(is_sorted([0, 1, 2])); - assert!(is_sorted([0, 1, 4])); - assert!(is_sorted([0usize; 0])); - assert!(is_sorted([1, 2])); - assert!(!is_sorted([3, 2])); - } - #[test] fn test_find_indices() -> Result<()> { assert_eq!(find_indices(&[0, 3, 4], [0, 3, 4])?, vec![0, 1, 2]); diff --git a/datafusion/core/src/execution/session_state.rs b/datafusion/core/src/execution/session_state.rs index b1229d5063..a7b3bdeeac 100644 --- a/datafusion/core/src/execution/session_state.rs +++ b/datafusion/core/src/execution/session_state.rs @@ -274,17 +274,6 @@ impl Session for SessionState { } impl SessionState { - /// Returns new [`SessionState`] using the provided - /// [`SessionConfig`] and [`RuntimeEnv`]. - #[deprecated(since = "41.0.0", note = "Use SessionStateBuilder")] - pub fn new_with_config_rt(config: SessionConfig, runtime: Arc<RuntimeEnv>) -> Self { - SessionStateBuilder::new() - .with_config(config) - .with_runtime_env(runtime) - .with_default_features() - .build() - } - pub(crate) fn resolve_table_ref( &self, table_ref: impl Into<TableReference>, diff --git a/datafusion/core/src/lib.rs b/datafusion/core/src/lib.rs index dc9f7cf1cc..67309dcfdb 100644 --- a/datafusion/core/src/lib.rs +++ b/datafusion/core/src/lib.rs @@ -828,13 +828,6 @@ pub mod functions_nested { pub use datafusion_functions_nested::*; } -/// re-export of [`datafusion_functions_nested`] crate as [`functions_array`] for backward compatibility, if "nested_expressions" feature is enabled -#[deprecated(since = "41.0.0", note = "use datafusion-functions-nested instead")] -pub mod functions_array { - #[cfg(feature = "nested_expressions")] - pub use datafusion_functions_nested::*; -} - /// re-export of [`datafusion_functions_aggregate`] crate pub mod functions_aggregate { pub use datafusion_functions_aggregate::*; diff --git a/datafusion/doc/src/lib.rs b/datafusion/doc/src/lib.rs index c86a40ece2..9a2c5656ba 100644 --- a/datafusion/doc/src/lib.rs +++ b/datafusion/doc/src/lib.rs @@ -212,15 +212,6 @@ pub struct DocumentationBuilder { } impl DocumentationBuilder { - #[allow(clippy::new_without_default)] - #[deprecated( - since = "44.0.0", - note = "please use `DocumentationBuilder::new_with_details` instead" - )] - pub fn new() -> Self { - Self::new_with_details(DocSection::default(), "<no description>", "<no example>") - } - /// Creates a new [`DocumentationBuilder`] with all required fields pub fn new_with_details( doc_section: DocSection, diff --git a/datafusion/execution/src/runtime_env.rs b/datafusion/execution/src/runtime_env.rs index fc26f997a2..9115665dce 100644 --- a/datafusion/execution/src/runtime_env.rs +++ b/datafusion/execution/src/runtime_env.rs @@ -87,18 +87,6 @@ impl Debug for RuntimeEnv { } impl RuntimeEnv { - #[deprecated(since = "43.0.0", note = "please use `RuntimeEnvBuilder` instead")] - #[allow(deprecated)] - pub fn new(config: RuntimeConfig) -> Result<Self> { - Self::try_new(config) - } - /// Create env based on configuration - #[deprecated(since = "44.0.0", note = "please use `RuntimeEnvBuilder` instead")] - #[allow(deprecated)] - pub fn try_new(config: RuntimeConfig) -> Result<Self> { - config.build() - } - /// Registers a custom `ObjectStore` to be used with a specific url. /// This allows DataFusion to create external tables from urls that do not have /// built in support such as `hdfs://namenode:port/...`. @@ -162,15 +150,10 @@ impl Default for RuntimeEnv { } } -/// Please see: <https://github.com/apache/datafusion/issues/12156> -/// This a type alias for backwards compatibility. -#[deprecated(since = "43.0.0", note = "please use `RuntimeEnvBuilder` instead")] -pub type RuntimeConfig = RuntimeEnvBuilder; - -#[derive(Clone)] /// Execution runtime configuration builder. /// /// See example on [`RuntimeEnv`] +#[derive(Clone)] pub struct RuntimeEnvBuilder { #[allow(deprecated)] /// DiskManager to manage temporary disk file usage diff --git a/datafusion/expr-common/src/operator.rs b/datafusion/expr-common/src/operator.rs index 19fc6b8074..bfc5ee9a36 100644 --- a/datafusion/expr-common/src/operator.rs +++ b/datafusion/expr-common/src/operator.rs @@ -229,15 +229,6 @@ impl Operator { ) } - /// Return true if the comparison operator can be used in interval arithmetic and constraint - /// propagation - /// - /// For example, 'Binary(a, >, b)' expression supports propagation. - #[deprecated(since = "43.0.0", note = "please use `supports_propagation` instead")] - pub fn is_comparison_operator(&self) -> bool { - self.supports_propagation() - } - /// Return true if the operator is a logic operator. /// /// For example, 'Binary(Binary(a, >, b), AND, Binary(a, <, b + 3))' would diff --git a/datafusion/expr/src/expr.rs b/datafusion/expr/src/expr.rs index efe8a63908..bb376b5916 100644 --- a/datafusion/expr/src/expr.rs +++ b/datafusion/expr/src/expr.rs @@ -1429,12 +1429,6 @@ impl Expr { } } - /// Returns a full and complete string representation of this expression. - #[deprecated(since = "42.0.0", note = "use format! instead")] - pub fn canonical_name(&self) -> String { - format!("{self}") - } - /// Return String representation of the variant represented by `self` /// Useful for non-rust based bindings pub fn variant_name(&self) -> &str { @@ -3556,27 +3550,23 @@ mod test { } #[test] - #[allow(deprecated)] fn format_case_when() -> Result<()> { let expr = case(col("a")) .when(lit(1), lit(true)) .when(lit(0), lit(false)) .otherwise(lit(ScalarValue::Null))?; let expected = "CASE a WHEN Int32(1) THEN Boolean(true) WHEN Int32(0) THEN Boolean(false) ELSE NULL END"; - assert_eq!(expected, expr.canonical_name()); assert_eq!(expected, format!("{expr}")); Ok(()) } #[test] - #[allow(deprecated)] fn format_cast() -> Result<()> { let expr = Expr::Cast(Cast { expr: Box::new(Expr::Literal(ScalarValue::Float32(Some(1.23)), None)), data_type: DataType::Utf8, }); let expected_canonical = "CAST(Float32(1.23) AS Utf8)"; - assert_eq!(expected_canonical, expr.canonical_name()); assert_eq!(expected_canonical, format!("{expr}")); // Note that CAST intentionally has a name that is different from its `Display` // representation. CAST does not change the name of expressions. diff --git a/datafusion/functions-aggregate-common/src/utils.rs b/datafusion/functions-aggregate-common/src/utils.rs index 2f20e91674..3e527bafe9 100644 --- a/datafusion/functions-aggregate-common/src/utils.rs +++ b/datafusion/functions-aggregate-common/src/utils.rs @@ -15,22 +15,15 @@ // specific language governing permissions and limitations // under the License. -use std::sync::Arc; - -use arrow::array::{ArrayRef, AsArray}; -use arrow::datatypes::{ArrowNativeType, FieldRef}; -use arrow::{ - array::ArrowNativeTypeOp, - compute::SortOptions, - datatypes::{ - DataType, Decimal128Type, DecimalType, Field, TimeUnit, TimestampMicrosecondType, - TimestampMillisecondType, TimestampNanosecondType, TimestampSecondType, - ToByteSlice, - }, +use arrow::array::{ArrayRef, ArrowNativeTypeOp}; +use arrow::compute::SortOptions; +use arrow::datatypes::{ + ArrowNativeType, DataType, DecimalType, Field, FieldRef, ToByteSlice, }; use datafusion_common::{exec_err, DataFusionError, Result}; use datafusion_expr_common::accumulator::Accumulator; use datafusion_physical_expr_common::sort_expr::{LexOrdering, PhysicalSortExpr}; +use std::sync::Arc; /// Convert scalar values from an accumulator into arrays. pub fn get_accum_scalar_values_as_arrays( @@ -43,50 +36,6 @@ pub fn get_accum_scalar_values_as_arrays( .collect() } -/// Adjust array type metadata if needed -/// -/// Since `Decimal128Arrays` created from `Vec<NativeType>` have -/// default precision and scale, this function adjusts the output to -/// match `data_type`, if necessary -#[deprecated(since = "44.0.0", note = "use PrimitiveArray::with_datatype")] -pub fn adjust_output_array(data_type: &DataType, array: ArrayRef) -> Result<ArrayRef> { - let array = match data_type { - DataType::Decimal128(p, s) => Arc::new( - array - .as_primitive::<Decimal128Type>() - .clone() - .with_precision_and_scale(*p, *s)?, - ) as ArrayRef, - DataType::Timestamp(TimeUnit::Nanosecond, tz) => Arc::new( - array - .as_primitive::<TimestampNanosecondType>() - .clone() - .with_timezone_opt(tz.clone()), - ), - DataType::Timestamp(TimeUnit::Microsecond, tz) => Arc::new( - array - .as_primitive::<TimestampMicrosecondType>() - .clone() - .with_timezone_opt(tz.clone()), - ), - DataType::Timestamp(TimeUnit::Millisecond, tz) => Arc::new( - array - .as_primitive::<TimestampMillisecondType>() - .clone() - .with_timezone_opt(tz.clone()), - ), - DataType::Timestamp(TimeUnit::Second, tz) => Arc::new( - array - .as_primitive::<TimestampSecondType>() - .clone() - .with_timezone_opt(tz.clone()), - ), - // no adjustment needed for other arrays - _ => array, - }; - Ok(array) -} - /// Construct corresponding fields for the expressions in an ORDER BY clause. pub fn ordering_fields( order_bys: &[PhysicalSortExpr], diff --git a/datafusion/functions/src/strings.rs b/datafusion/functions/src/strings.rs index 6299b353d5..108c20e136 100644 --- a/datafusion/functions/src/strings.rs +++ b/datafusion/functions/src/strings.rs @@ -18,47 +18,12 @@ use std::mem::size_of; use arrow::array::{ - make_view, Array, ArrayAccessor, ArrayDataBuilder, ArrayIter, ByteView, - GenericStringArray, LargeStringArray, NullBufferBuilder, OffsetSizeTrait, - StringArray, StringViewArray, StringViewBuilder, + make_view, Array, ArrayAccessor, ArrayDataBuilder, ByteView, LargeStringArray, + NullBufferBuilder, StringArray, StringViewArray, StringViewBuilder, }; use arrow::buffer::{MutableBuffer, NullBuffer}; use arrow::datatypes::DataType; -/// Abstracts iteration over different types of string arrays. -#[deprecated(since = "45.0.0", note = "Use arrow::array::StringArrayType instead")] -pub trait StringArrayType<'a>: ArrayAccessor<Item = &'a str> + Sized { - /// Return an [`ArrayIter`] over the values of the array. - /// - /// This iterator iterates returns `Option<&str>` for each item in the array. - fn iter(&self) -> ArrayIter<Self>; - - /// Check if the array is ASCII only. - fn is_ascii(&self) -> bool; -} - -#[allow(deprecated)] -impl<'a, T: OffsetSizeTrait> StringArrayType<'a> for &'a GenericStringArray<T> { - fn iter(&self) -> ArrayIter<Self> { - GenericStringArray::<T>::iter(self) - } - - fn is_ascii(&self) -> bool { - GenericStringArray::<T>::is_ascii(self) - } -} - -#[allow(deprecated)] -impl<'a> StringArrayType<'a> for &'a StringViewArray { - fn iter(&self) -> ArrayIter<Self> { - StringViewArray::iter(self) - } - - fn is_ascii(&self) -> bool { - StringViewArray::is_ascii(self) - } -} - /// Optimized version of the StringBuilder in Arrow that: /// 1. Precalculating the expected length of the result, avoiding reallocations. /// 2. Avoids creating / incrementally creating a `NullBufferBuilder` diff --git a/datafusion/optimizer/src/analyzer/mod.rs b/datafusion/optimizer/src/analyzer/mod.rs index 2517e3c3a4..272692f983 100644 --- a/datafusion/optimizer/src/analyzer/mod.rs +++ b/datafusion/optimizer/src/analyzer/mod.rs @@ -38,14 +38,6 @@ pub mod function_rewrite; pub mod resolve_grouping_function; pub mod type_coercion; -pub mod subquery { - #[deprecated( - since = "44.0.0", - note = "please use `datafusion_expr::check_subquery_expr` instead" - )] - pub use datafusion_expr::check_subquery_expr; -} - /// [`AnalyzerRule`]s transform [`LogicalPlan`]s in some way to make /// the plan valid prior to the rest of the DataFusion optimization process. /// diff --git a/datafusion/physical-expr-common/src/physical_expr.rs b/datafusion/physical-expr-common/src/physical_expr.rs index 84db63ca3b..0ab8e56c0b 100644 --- a/datafusion/physical-expr-common/src/physical_expr.rs +++ b/datafusion/physical-expr-common/src/physical_expr.rs @@ -442,21 +442,6 @@ pub fn with_new_children_if_necessary( } } -#[deprecated(since = "44.0.0")] -pub fn down_cast_any_ref(any: &dyn Any) -> &dyn Any { - if any.is::<Arc<dyn PhysicalExpr>>() { - any.downcast_ref::<Arc<dyn PhysicalExpr>>() - .unwrap() - .as_any() - } else if any.is::<Box<dyn PhysicalExpr>>() { - any.downcast_ref::<Box<dyn PhysicalExpr>>() - .unwrap() - .as_any() - } else { - any - } -} - /// Returns [`Display`] able a list of [`PhysicalExpr`] /// /// Example output: `[a + 1, b]` diff --git a/datafusion/physical-expr/src/aggregate.rs b/datafusion/physical-expr/src/aggregate.rs index ed30481182..0ec1bd5530 100644 --- a/datafusion/physical-expr/src/aggregate.rs +++ b/datafusion/physical-expr/src/aggregate.rs @@ -28,10 +28,9 @@ pub(crate) mod stats { pub use datafusion_functions_aggregate_common::stats::StatsType; } pub mod utils { - #[allow(deprecated)] // allow adjust_output_array pub use datafusion_functions_aggregate_common::utils::{ - adjust_output_array, get_accum_scalar_values_as_arrays, get_sort_options, - ordering_fields, DecimalAverager, Hashable, + get_accum_scalar_values_as_arrays, get_sort_options, ordering_fields, + DecimalAverager, Hashable, }; } diff --git a/datafusion/physical-expr/src/window/mod.rs b/datafusion/physical-expr/src/window/mod.rs index bc7c716783..b45e35440a 100644 --- a/datafusion/physical-expr/src/window/mod.rs +++ b/datafusion/physical-expr/src/window/mod.rs @@ -21,12 +21,6 @@ mod standard; mod standard_window_function_expr; mod window_expr; -#[deprecated(since = "44.0.0", note = "use StandardWindowExpr")] -pub type BuiltInWindowExpr = StandardWindowExpr; - -#[deprecated(since = "44.0.0", note = "use StandardWindowFunctionExpr")] -pub type BuiltInWindowFunctionExpr = dyn StandardWindowFunctionExpr; - pub use aggregate::PlainAggregateWindowExpr; pub use sliding_aggregate::SlidingAggregateWindowExpr; pub use standard::StandardWindowExpr; diff --git a/datafusion/physical-optimizer/src/join_selection.rs b/datafusion/physical-optimizer/src/join_selection.rs index dc22033214..c2cfca681f 100644 --- a/datafusion/physical-optimizer/src/join_selection.rs +++ b/datafusion/physical-optimizer/src/join_selection.rs @@ -23,10 +23,7 @@ //! pipeline-friendly ones. To achieve the second goal, it selects the proper //! `PartitionMode` and the build side using the available statistics for hash joins. -use std::sync::Arc; - use crate::PhysicalOptimizerRule; - use datafusion_common::config::ConfigOptions; use datafusion_common::error::Result; use datafusion_common::tree_node::{Transformed, TransformedResult, TreeNode}; @@ -35,12 +32,13 @@ use datafusion_expr_common::sort_properties::SortProperties; use datafusion_physical_expr::expressions::Column; use datafusion_physical_expr::LexOrdering; use datafusion_physical_plan::execution_plan::EmissionType; -use datafusion_physical_plan::joins::utils::{ColumnIndex, JoinFilter}; +use datafusion_physical_plan::joins::utils::ColumnIndex; use datafusion_physical_plan::joins::{ CrossJoinExec, HashJoinExec, NestedLoopJoinExec, PartitionMode, StreamJoinPartitionMode, SymmetricHashJoinExec, }; use datafusion_physical_plan::{ExecutionPlan, ExecutionPlanProperties}; +use std::sync::Arc; /// The [`JoinSelection`] rule tries to modify a given plan so that it can /// accommodate infinite sources and optimize joins in the plan according to @@ -104,52 +102,6 @@ fn supports_collect_by_thresholds( } } -/// Predicate that checks whether the given join type supports input swapping. -#[deprecated(since = "45.0.0", note = "use JoinType::supports_swap instead")] -#[allow(dead_code)] -pub(crate) fn supports_swap(join_type: JoinType) -> bool { - join_type.supports_swap() -} - -/// This function returns the new join type we get after swapping the given -/// join's inputs. -#[deprecated(since = "45.0.0", note = "use datafusion-functions-nested instead")] -#[allow(dead_code)] -pub(crate) fn swap_join_type(join_type: JoinType) -> JoinType { - join_type.swap() -} - -/// This function swaps the inputs of the given join operator. -/// This function is public so other downstream projects can use it -/// to construct `HashJoinExec` with right side as the build side. -#[deprecated(since = "45.0.0", note = "use HashJoinExec::swap_inputs instead")] -pub fn swap_hash_join( - hash_join: &HashJoinExec, - partition_mode: PartitionMode, -) -> Result<Arc<dyn ExecutionPlan>> { - hash_join.swap_inputs(partition_mode) -} - -/// Swaps inputs of `NestedLoopJoinExec` and wraps it into `ProjectionExec` is required -#[deprecated(since = "45.0.0", note = "use NestedLoopJoinExec::swap_inputs")] -#[allow(dead_code)] -pub(crate) fn swap_nl_join(join: &NestedLoopJoinExec) -> Result<Arc<dyn ExecutionPlan>> { - join.swap_inputs() -} - -/// Swaps join sides for filter column indices and produces new `JoinFilter` (if exists). -#[deprecated(since = "45.0.0", note = "use filter.map(JoinFilter::swap) instead")] -#[allow(dead_code)] -fn swap_join_filter(filter: Option<&JoinFilter>) -> Option<JoinFilter> { - filter.map(JoinFilter::swap) -} - -#[deprecated(since = "45.0.0", note = "use JoinFilter::swap instead")] -#[allow(dead_code)] -pub(crate) fn swap_filter(filter: &JoinFilter) -> JoinFilter { - filter.swap() -} - impl PhysicalOptimizerRule for JoinSelection { fn optimize( &self, diff --git a/datafusion/physical-plan/src/lib.rs b/datafusion/physical-plan/src/lib.rs index 5c0b231915..afe61541fc 100644 --- a/datafusion/physical-plan/src/lib.rs +++ b/datafusion/physical-plan/src/lib.rs @@ -87,7 +87,6 @@ pub mod streaming; pub mod tree_node; pub mod union; pub mod unnest; -pub mod values; pub mod windows; pub mod work_table; pub mod udaf { diff --git a/datafusion/physical-plan/src/values.rs b/datafusion/physical-plan/src/values.rs deleted file mode 100644 index fb27ccf301..0000000000 --- a/datafusion/physical-plan/src/values.rs +++ /dev/null @@ -1,330 +0,0 @@ -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. - -//! Values execution plan - -use std::any::Any; -use std::sync::Arc; - -use crate::execution_plan::{Boundedness, EmissionType}; -use crate::memory::MemoryStream; -use crate::{common, DisplayAs, PlanProperties, SendableRecordBatchStream, Statistics}; -use crate::{ - ColumnarValue, DisplayFormatType, ExecutionPlan, Partitioning, PhysicalExpr, -}; -use arrow::datatypes::{Schema, SchemaRef}; -use arrow::record_batch::{RecordBatch, RecordBatchOptions}; -use datafusion_common::{internal_err, plan_err, Result, ScalarValue}; -use datafusion_execution::TaskContext; -use datafusion_physical_expr::EquivalenceProperties; - -/// Execution plan for values list based relation (produces constant rows) -#[deprecated( - since = "45.0.0", - note = "Use `MemorySourceConfig::try_new_as_values` instead" -)] -#[derive(Debug, Clone)] -pub struct ValuesExec { - /// The schema - schema: SchemaRef, - /// The data - data: Vec<RecordBatch>, - /// Cache holding plan properties like equivalences, output partitioning etc. - cache: PlanProperties, -} - -#[allow(deprecated)] -impl ValuesExec { - /// Create a new values exec from data as expr - #[deprecated(since = "45.0.0", note = "Use `MemoryExec::try_new` instead")] - pub fn try_new( - schema: SchemaRef, - data: Vec<Vec<Arc<dyn PhysicalExpr>>>, - ) -> Result<Self> { - if data.is_empty() { - return plan_err!("Values list cannot be empty"); - } - let n_row = data.len(); - let n_col = schema.fields().len(); - // We have this single row batch as a placeholder to satisfy evaluation argument - // and generate a single output row - let batch = RecordBatch::try_new_with_options( - Arc::new(Schema::empty()), - vec![], - &RecordBatchOptions::new().with_row_count(Some(1)), - )?; - - let arr = (0..n_col) - .map(|j| { - (0..n_row) - .map(|i| { - let r = data[i][j].evaluate(&batch); - - match r { - Ok(ColumnarValue::Scalar(scalar)) => Ok(scalar), - Ok(ColumnarValue::Array(a)) if a.len() == 1 => { - ScalarValue::try_from_array(&a, 0) - } - Ok(ColumnarValue::Array(a)) => { - plan_err!( - "Cannot have array values {a:?} in a values list" - ) - } - Err(err) => Err(err), - } - }) - .collect::<Result<Vec<_>>>() - .and_then(ScalarValue::iter_to_array) - }) - .collect::<Result<Vec<_>>>()?; - let batch = RecordBatch::try_new_with_options( - Arc::clone(&schema), - arr, - &RecordBatchOptions::new().with_row_count(Some(n_row)), - )?; - let data: Vec<RecordBatch> = vec![batch]; - Self::try_new_from_batches(schema, data) - } - - /// Create a new plan using the provided schema and batches. - /// - /// Errors if any of the batches don't match the provided schema, or if no - /// batches are provided. - #[deprecated( - since = "45.0.0", - note = "Use `MemoryExec::try_new_from_batches` instead" - )] - pub fn try_new_from_batches( - schema: SchemaRef, - batches: Vec<RecordBatch>, - ) -> Result<Self> { - if batches.is_empty() { - return plan_err!("Values list cannot be empty"); - } - - for batch in &batches { - let batch_schema = batch.schema(); - if batch_schema != schema { - return plan_err!( - "Batch has invalid schema. Expected: {schema}, got: {batch_schema}" - ); - } - } - - let cache = Self::compute_properties(Arc::clone(&schema)); - #[allow(deprecated)] - Ok(ValuesExec { - schema, - data: batches, - cache, - }) - } - - /// Provides the data - pub fn data(&self) -> Vec<RecordBatch> { - #[allow(deprecated)] - self.data.clone() - } - - /// This function creates the cache object that stores the plan properties such as schema, equivalence properties, ordering, partitioning, etc. - fn compute_properties(schema: SchemaRef) -> PlanProperties { - PlanProperties::new( - EquivalenceProperties::new(schema), - Partitioning::UnknownPartitioning(1), - EmissionType::Incremental, - Boundedness::Bounded, - ) - } -} - -#[allow(deprecated)] -impl DisplayAs for ValuesExec { - fn fmt_as( - &self, - t: DisplayFormatType, - f: &mut std::fmt::Formatter, - ) -> std::fmt::Result { - match t { - DisplayFormatType::Default | DisplayFormatType::Verbose => { - write!(f, "ValuesExec") - } - DisplayFormatType::TreeRender => { - // TODO: collect info - write!(f, "") - } - } - } -} - -#[allow(deprecated)] -impl ExecutionPlan for ValuesExec { - fn name(&self) -> &'static str { - "ValuesExec" - } - - /// Return a reference to Any that can be used for downcasting - fn as_any(&self) -> &dyn Any { - self - } - - fn properties(&self) -> &PlanProperties { - #[allow(deprecated)] - &self.cache - } - - fn children(&self) -> Vec<&Arc<dyn ExecutionPlan>> { - vec![] - } - - fn with_new_children( - self: Arc<Self>, - _: Vec<Arc<dyn ExecutionPlan>>, - ) -> Result<Arc<dyn ExecutionPlan>> { - #[allow(deprecated)] - ValuesExec::try_new_from_batches(Arc::clone(&self.schema), self.data.clone()) - .map(|e| Arc::new(e) as _) - } - - fn execute( - &self, - partition: usize, - _context: Arc<TaskContext>, - ) -> Result<SendableRecordBatchStream> { - // ValuesExec has a single output partition - if 0 != partition { - return internal_err!( - "ValuesExec invalid partition {partition} (expected 0)" - ); - } - - Ok(Box::pin(MemoryStream::try_new( - self.data(), - #[allow(deprecated)] - Arc::clone(&self.schema), - None, - )?)) - } - - fn statistics(&self) -> Result<Statistics> { - let batch = self.data(); - Ok(common::compute_record_batch_statistics( - &[batch], - #[allow(deprecated)] - &self.schema, - None, - )) - } -} - -#[cfg(test)] -mod tests { - use super::*; - use crate::expressions::lit; - use crate::test::{self, make_partition}; - - use arrow::datatypes::{DataType, Field}; - use datafusion_common::stats::{ColumnStatistics, Precision}; - - #[tokio::test] - async fn values_empty_case() -> Result<()> { - let schema = test::aggr_test_schema(); - #[allow(deprecated)] - let empty = ValuesExec::try_new(schema, vec![]); - assert!(empty.is_err()); - Ok(()) - } - - #[test] - fn new_exec_with_batches() { - let batch = make_partition(7); - let schema = batch.schema(); - let batches = vec![batch.clone(), batch]; - #[allow(deprecated)] - let _exec = ValuesExec::try_new_from_batches(schema, batches).unwrap(); - } - - #[test] - fn new_exec_with_batches_empty() { - let batch = make_partition(7); - let schema = batch.schema(); - #[allow(deprecated)] - let _ = ValuesExec::try_new_from_batches(schema, Vec::new()).unwrap_err(); - } - - #[test] - fn new_exec_with_batches_invalid_schema() { - let batch = make_partition(7); - let batches = vec![batch.clone(), batch]; - - let invalid_schema = Arc::new(Schema::new(vec![ - Field::new("col0", DataType::UInt32, false), - Field::new("col1", DataType::Utf8, false), - ])); - #[allow(deprecated)] - let _ = ValuesExec::try_new_from_batches(invalid_schema, batches).unwrap_err(); - } - - // Test issue: https://github.com/apache/datafusion/issues/8763 - #[test] - fn new_exec_with_non_nullable_schema() { - let schema = Arc::new(Schema::new(vec![Field::new( - "col0", - DataType::UInt32, - false, - )])); - #[allow(deprecated)] - let _ = ValuesExec::try_new(Arc::clone(&schema), vec![vec![lit(1u32)]]).unwrap(); - // Test that a null value is rejected - #[allow(deprecated)] - let _ = ValuesExec::try_new(schema, vec![vec![lit(ScalarValue::UInt32(None))]]) - .unwrap_err(); - } - - #[test] - fn values_stats_with_nulls_only() -> Result<()> { - let data = vec![ - vec![lit(ScalarValue::Null)], - vec![lit(ScalarValue::Null)], - vec![lit(ScalarValue::Null)], - ]; - let rows = data.len(); - #[allow(deprecated)] - let values = ValuesExec::try_new( - Arc::new(Schema::new(vec![Field::new("col0", DataType::Null, true)])), - data, - )?; - - #[allow(deprecated)] - let stats = values.statistics()?; - assert_eq!( - stats, - Statistics { - num_rows: Precision::Exact(rows), - total_byte_size: Precision::Exact(8), // not important - column_statistics: vec![ColumnStatistics { - null_count: Precision::Exact(rows), // there are only nulls - distinct_count: Precision::Absent, - max_value: Precision::Absent, - min_value: Precision::Absent, - sum_value: Precision::Absent, - },], - } - ); - - Ok(()) - } -} diff --git a/datafusion/sql/src/unparser/dialect.rs b/datafusion/sql/src/unparser/dialect.rs index 3c8de7e740..423610b05f 100644 --- a/datafusion/sql/src/unparser/dialect.rs +++ b/datafusion/sql/src/unparser/dialect.rs @@ -603,17 +603,6 @@ impl Default for CustomDialect { } } -impl CustomDialect { - // Create a CustomDialect - #[deprecated(since = "41.0.0", note = "please use `CustomDialectBuilder` instead")] - pub fn new(identifier_quote_style: Option<char>) -> Self { - Self { - identifier_quote_style, - ..Default::default() - } - } -} - impl Dialect for CustomDialect { fn identifier_quote_style(&self, _: &str) -> Option<char> { self.identifier_quote_style --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@datafusion.apache.org For additional commands, e-mail: commits-h...@datafusion.apache.org