Skip to content

Commit d0947f1

Browse files
committed
chore: cleanup deprecated API since 40 or earlier
1 parent c0d53ad commit d0947f1

10 files changed

Lines changed: 6 additions & 271 deletions

File tree

datafusion/common/src/dfschema.rs

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -159,22 +159,9 @@ impl DFSchema {
159159
}
160160

161161
/// Create a new `DFSchema` from a list of Arrow [Field]s
162-
#[allow(deprecated)]
163162
pub fn from_unqualified_fields(
164163
fields: Fields,
165164
metadata: HashMap<String, String>,
166-
) -> Result<Self> {
167-
Self::from_unqualifed_fields(fields, metadata)
168-
}
169-
170-
/// Create a new `DFSchema` from a list of Arrow [Field]s
171-
#[deprecated(
172-
since = "40.0.0",
173-
note = "Please use `from_unqualified_fields` instead (this one's name is a typo). This method is subject to be removed soon"
174-
)]
175-
pub fn from_unqualifed_fields(
176-
fields: Fields,
177-
metadata: HashMap<String, String>,
178165
) -> Result<Self> {
179166
let field_count = fields.len();
180167
let schema = Arc::new(Schema::new_with_metadata(fields, metadata));

datafusion/core/src/execution/session_state.rs

Lines changed: 0 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -280,22 +280,6 @@ impl SessionState {
280280
.build()
281281
}
282282

283-
/// Returns new [`SessionState`] using the provided
284-
/// [`SessionConfig`], [`RuntimeEnv`], and [`CatalogProviderList`]
285-
#[deprecated(since = "40.0.0", note = "Use SessionStateBuilder")]
286-
pub fn new_with_config_rt_and_catalog_list(
287-
config: SessionConfig,
288-
runtime: Arc<RuntimeEnv>,
289-
catalog_list: Arc<dyn CatalogProviderList>,
290-
) -> Self {
291-
SessionStateBuilder::new()
292-
.with_config(config)
293-
.with_runtime_env(runtime)
294-
.with_catalog_list(catalog_list)
295-
.with_default_features()
296-
.build()
297-
}
298-
299283
pub(crate) fn resolve_table_ref(
300284
&self,
301285
table_ref: impl Into<TableReference>,
@@ -334,53 +318,6 @@ impl SessionState {
334318
})
335319
}
336320

337-
#[deprecated(since = "40.0.0", note = "Use SessionStateBuilder")]
338-
/// Replace the random session id.
339-
pub fn with_session_id(mut self, session_id: String) -> Self {
340-
self.session_id = session_id;
341-
self
342-
}
343-
344-
#[deprecated(since = "40.0.0", note = "Use SessionStateBuilder")]
345-
/// override default query planner with `query_planner`
346-
pub fn with_query_planner(
347-
mut self,
348-
query_planner: Arc<dyn QueryPlanner + Send + Sync>,
349-
) -> Self {
350-
self.query_planner = query_planner;
351-
self
352-
}
353-
354-
#[deprecated(since = "40.0.0", note = "Use SessionStateBuilder")]
355-
/// Override the [`AnalyzerRule`]s optimizer plan rules.
356-
pub fn with_analyzer_rules(
357-
mut self,
358-
rules: Vec<Arc<dyn AnalyzerRule + Send + Sync>>,
359-
) -> Self {
360-
self.analyzer = Analyzer::with_rules(rules);
361-
self
362-
}
363-
364-
#[deprecated(since = "40.0.0", note = "Use SessionStateBuilder")]
365-
/// Replace the entire list of [`OptimizerRule`]s used to optimize plans
366-
pub fn with_optimizer_rules(
367-
mut self,
368-
rules: Vec<Arc<dyn OptimizerRule + Send + Sync>>,
369-
) -> Self {
370-
self.optimizer = Optimizer::with_rules(rules);
371-
self
372-
}
373-
374-
#[deprecated(since = "40.0.0", note = "Use SessionStateBuilder")]
375-
/// Replace the entire list of [`PhysicalOptimizerRule`]s used to optimize plans
376-
pub fn with_physical_optimizer_rules(
377-
mut self,
378-
physical_optimizers: Vec<Arc<dyn PhysicalOptimizerRule + Send + Sync>>,
379-
) -> Self {
380-
self.physical_optimizers = PhysicalOptimizer::with_rules(physical_optimizers);
381-
self
382-
}
383-
384321
/// Add `analyzer_rule` to the end of the list of
385322
/// [`AnalyzerRule`]s used to rewrite queries.
386323
pub fn add_analyzer_rule(
@@ -391,17 +328,6 @@ impl SessionState {
391328
self
392329
}
393330

394-
#[deprecated(since = "40.0.0", note = "Use SessionStateBuilder")]
395-
/// Add `optimizer_rule` to the end of the list of
396-
/// [`OptimizerRule`]s used to rewrite queries.
397-
pub fn add_optimizer_rule(
398-
mut self,
399-
optimizer_rule: Arc<dyn OptimizerRule + Send + Sync>,
400-
) -> Self {
401-
self.optimizer.rules.push(optimizer_rule);
402-
self
403-
}
404-
405331
// the add_optimizer_rule takes an owned reference
406332
// it should probably be renamed to `with_optimizer_rule` to follow builder style
407333
// and `add_optimizer_rule` that takes &mut self added instead of this
@@ -412,52 +338,11 @@ impl SessionState {
412338
self.optimizer.rules.push(optimizer_rule);
413339
}
414340

415-
#[deprecated(since = "40.0.0", note = "Use SessionStateBuilder")]
416-
/// Add `physical_optimizer_rule` to the end of the list of
417-
/// [`PhysicalOptimizerRule`]s used to rewrite queries.
418-
pub fn add_physical_optimizer_rule(
419-
mut self,
420-
physical_optimizer_rule: Arc<dyn PhysicalOptimizerRule + Send + Sync>,
421-
) -> Self {
422-
self.physical_optimizers.rules.push(physical_optimizer_rule);
423-
self
424-
}
425-
426-
#[deprecated(since = "40.0.0", note = "Use SessionStateBuilder")]
427-
/// Adds a new [`ConfigExtension`] to TableOptions
428-
pub fn add_table_options_extension<T: ConfigExtension>(
429-
mut self,
430-
extension: T,
431-
) -> Self {
432-
self.table_options.extensions.insert(extension);
433-
self
434-
}
435-
436-
#[deprecated(since = "40.0.0", note = "Use SessionStateBuilder")]
437-
/// Registers a [`FunctionFactory`] to handle `CREATE FUNCTION` statements
438-
pub fn with_function_factory(
439-
mut self,
440-
function_factory: Arc<dyn FunctionFactory>,
441-
) -> Self {
442-
self.function_factory = Some(function_factory);
443-
self
444-
}
445-
446341
/// Registers a [`FunctionFactory`] to handle `CREATE FUNCTION` statements
447342
pub fn set_function_factory(&mut self, function_factory: Arc<dyn FunctionFactory>) {
448343
self.function_factory = Some(function_factory);
449344
}
450345

451-
#[deprecated(since = "40.0.0", note = "Use SessionStateBuilder")]
452-
/// Replace the extension [`SerializerRegistry`]
453-
pub fn with_serializer_registry(
454-
mut self,
455-
registry: Arc<dyn SerializerRegistry>,
456-
) -> Self {
457-
self.serializer_registry = registry;
458-
self
459-
}
460-
461346
/// Get the function factory
462347
pub fn function_factory(&self) -> Option<&Arc<dyn FunctionFactory>> {
463348
self.function_factory.as_ref()

datafusion/datasource-parquet/src/file_format.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -802,21 +802,6 @@ fn get_col_stats(
802802
.collect()
803803
}
804804

805-
/// Deprecated
806-
/// Use [`statistics_from_parquet_meta_calc`] instead.
807-
/// This method was deprecated because it didn't need to be async so a new method was created
808-
/// that exposes a synchronous API.
809-
#[deprecated(
810-
since = "40.0.0",
811-
note = "please use `statistics_from_parquet_meta_calc` instead"
812-
)]
813-
pub async fn statistics_from_parquet_meta(
814-
metadata: &ParquetMetaData,
815-
table_schema: SchemaRef,
816-
) -> Result<Statistics> {
817-
statistics_from_parquet_meta_calc(metadata, table_schema)
818-
}
819-
820805
fn summarize_min_max_null_counts(
821806
min_accs: &mut [Option<MinAccumulator>],
822807
max_accs: &mut [Option<MaxAccumulator>],

datafusion/expr/src/expr.rs

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ use std::sync::Arc;
2525

2626
use crate::expr_fn::binary_expr;
2727
use crate::logical_plan::Subquery;
28-
use crate::utils::expr_to_columns;
2928
use crate::Volatility;
3029
use crate::{udaf, ExprSchemable, Operator, Signature, WindowFrame, WindowUDF};
3130

@@ -35,7 +34,7 @@ use datafusion_common::tree_node::{
3534
Transformed, TransformedResult, TreeNode, TreeNodeContainer, TreeNodeRecursion,
3635
};
3736
use datafusion_common::{
38-
plan_err, Column, DFSchema, HashMap, Result, ScalarValue, Spans, TableReference,
37+
Column, DFSchema, HashMap, Result, ScalarValue, Spans, TableReference,
3938
};
4039
use datafusion_functions_window_common::field::WindowUDFFieldArgs;
4140
use sqlparser::ast::{
@@ -1090,11 +1089,6 @@ impl PlannedReplaceSelectItem {
10901089
}
10911090

10921091
impl Expr {
1093-
#[deprecated(since = "40.0.0", note = "use schema_name instead")]
1094-
pub fn display_name(&self) -> Result<String> {
1095-
Ok(self.schema_name().to_string())
1096-
}
1097-
10981092
/// The name of the column (field) that this `Expr` will produce.
10991093
///
11001094
/// For example, for a projection (e.g. `SELECT <expr>`) the resulting arrow
@@ -1444,15 +1438,6 @@ impl Expr {
14441438
Box::new(high),
14451439
))
14461440
}
1447-
1448-
#[deprecated(since = "39.0.0", note = "use try_as_col instead")]
1449-
pub fn try_into_col(&self) -> Result<Column> {
1450-
match self {
1451-
Expr::Column(it) => Ok(it.clone()),
1452-
_ => plan_err!("Could not coerce '{self}' into Column!"),
1453-
}
1454-
}
1455-
14561441
/// Return a reference to the inner `Column` if any
14571442
///
14581443
/// returns `None` if the expression is not a `Column`
@@ -1495,15 +1480,6 @@ impl Expr {
14951480
}
14961481
}
14971482

1498-
/// Return all referenced columns of this expression.
1499-
#[deprecated(since = "40.0.0", note = "use Expr::column_refs instead")]
1500-
pub fn to_columns(&self) -> Result<HashSet<Column>> {
1501-
let mut using_columns = HashSet::new();
1502-
expr_to_columns(self, &mut using_columns)?;
1503-
1504-
Ok(using_columns)
1505-
}
1506-
15071483
/// Return all references to columns in this expression.
15081484
///
15091485
/// # Example

datafusion/expr/src/logical_plan/extension.rs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -82,17 +82,6 @@ pub trait UserDefinedLogicalNode: fmt::Debug + Send + Sync {
8282
/// For example: `TopK: k=10`
8383
fn fmt_for_explain(&self, f: &mut fmt::Formatter) -> fmt::Result;
8484

85-
#[deprecated(since = "39.0.0", note = "use with_exprs_and_inputs instead")]
86-
#[allow(clippy::wrong_self_convention)]
87-
fn from_template(
88-
&self,
89-
exprs: &[Expr],
90-
inputs: &[LogicalPlan],
91-
) -> Arc<dyn UserDefinedLogicalNode> {
92-
self.with_exprs_and_inputs(exprs.to_vec(), inputs.to_vec())
93-
.unwrap()
94-
}
95-
9685
/// Create a new `UserDefinedLogicalNode` with the specified children
9786
/// and expressions. This function is used during optimization
9887
/// when the plan is being rewritten and a new instance of the
@@ -282,13 +271,6 @@ pub trait UserDefinedLogicalNodeCore:
282271
/// For example: `TopK: k=10`
283272
fn fmt_for_explain(&self, f: &mut fmt::Formatter) -> fmt::Result;
284273

285-
#[deprecated(since = "39.0.0", note = "use with_exprs_and_inputs instead")]
286-
#[allow(clippy::wrong_self_convention)]
287-
fn from_template(&self, exprs: &[Expr], inputs: &[LogicalPlan]) -> Self {
288-
self.with_exprs_and_inputs(exprs.to_vec(), inputs.to_vec())
289-
.unwrap()
290-
}
291-
292274
/// Create a new `UserDefinedLogicalNode` with the specified children
293275
/// and expressions. This function is used during optimization
294276
/// when the plan is being rewritten and a new instance of the

datafusion/expr/src/utils.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -48,16 +48,6 @@ pub use datafusion_functions_aggregate_common::order::AggregateOrderSensitivity;
4848
/// `COUNT(<constant>)` expressions
4949
pub use datafusion_common::utils::expr::COUNT_STAR_EXPANSION;
5050

51-
/// Recursively walk a list of expression trees, collecting the unique set of columns
52-
/// referenced in the expression
53-
#[deprecated(since = "40.0.0", note = "Expr::add_column_refs instead")]
54-
pub fn exprlist_to_columns(expr: &[Expr], accum: &mut HashSet<Column>) -> Result<()> {
55-
for e in expr {
56-
expr_to_columns(e, accum)?;
57-
}
58-
Ok(())
59-
}
60-
6151
/// Count the number of distinct exprs in a list of group by expressions. If the
6252
/// first element is a `GroupingSet` expression then it must be the only expr.
6353
pub fn grouping_set_expr_count(group_expr: &[Expr]) -> Result<usize> {

datafusion/optimizer/src/lib.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,6 @@ pub use analyzer::{Analyzer, AnalyzerRule};
7070
pub use optimizer::{
7171
ApplyOrder, Optimizer, OptimizerConfig, OptimizerContext, OptimizerRule,
7272
};
73-
#[allow(deprecated)]
74-
pub use utils::optimize_children;
7573

7674
pub(crate) mod join_key_set;
7775
mod plan_signature;

datafusion/optimizer/src/optimizer.rs

Lines changed: 4 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -70,24 +70,6 @@ use crate::utils::log_plan;
7070
/// [`AnalyzerRule`]: crate::analyzer::AnalyzerRule
7171
/// [`SessionState::add_optimizer_rule`]: https://docs.rs/datafusion/latest/datafusion/execution/session_state/struct.SessionState.html#method.add_optimizer_rule
7272
pub trait OptimizerRule: Debug {
73-
/// Try and rewrite `plan` to an optimized form, returning None if the plan
74-
/// cannot be optimized by this rule.
75-
///
76-
/// Note this API will be deprecated in the future as it requires `clone`ing
77-
/// the input plan, which can be expensive. OptimizerRules should implement
78-
/// [`Self::rewrite`] instead.
79-
#[deprecated(
80-
since = "40.0.0",
81-
note = "please implement supports_rewrite and rewrite instead"
82-
)]
83-
fn try_optimize(
84-
&self,
85-
_plan: &LogicalPlan,
86-
_config: &dyn OptimizerConfig,
87-
) -> Result<Option<LogicalPlan>> {
88-
internal_err!("Should have called rewrite")
89-
}
90-
9173
/// A human readable name for this optimizer rule
9274
fn name(&self) -> &str;
9375

@@ -108,7 +90,7 @@ pub trait OptimizerRule: Debug {
10890
/// if the plan was rewritten and `Transformed::no` if it was not.
10991
///
11092
/// Note: this function is only called if [`Self::supports_rewrite`] returns
111-
/// true. Otherwise the Optimizer calls [`Self::try_optimize`]
93+
/// true.
11294
fn rewrite(
11395
&self,
11496
_plan: LogicalPlan,
@@ -329,19 +311,10 @@ fn optimize_plan_node(
329311
config: &dyn OptimizerConfig,
330312
) -> Result<Transformed<LogicalPlan>> {
331313
if rule.supports_rewrite() {
332-
return rule.rewrite(plan, config);
314+
rule.rewrite(plan, config)
315+
} else {
316+
Ok(Transformed::no(plan))
333317
}
334-
335-
#[allow(deprecated)]
336-
rule.try_optimize(&plan, config).map(|maybe_plan| {
337-
match maybe_plan {
338-
Some(new_plan) => {
339-
// if the node was rewritten by the optimizer, replace the node
340-
Transformed::yes(new_plan)
341-
}
342-
None => Transformed::no(plan),
343-
}
344-
})
345318
}
346319

347320
impl Optimizer {

datafusion/optimizer/src/simplify_expressions/simplify_exprs.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,7 @@ impl OptimizerRule for SimplifyExpressions {
6262
true
6363
}
6464

65-
/// if supports_owned returns true, the Optimizer calls
66-
/// [`Self::rewrite`] instead of [`Self::try_optimize`]
65+
/// if supports_owned returns true, the Optimizer calls [`Self::rewrite`]
6766
fn rewrite(
6867
&self,
6968
plan: LogicalPlan,

0 commit comments

Comments
 (0)