From c80da91e0fc6f0817b65cdf99fe2a50be9680fab Mon Sep 17 00:00:00 2001 From: Ruihang Xia Date: Sat, 29 Jun 2024 11:07:46 +0800 Subject: [PATCH] fix(typo): unqualifed to unqualified (#11159) * fix(typo): unqualifed to unqualified Signed-off-by: Ruihang Xia * keep the old API Signed-off-by: Ruihang Xia * Update datafusion/common/src/dfschema.rs Co-authored-by: Oleks V --------- Signed-off-by: Ruihang Xia Co-authored-by: Oleks V --- datafusion-examples/examples/expr_api.rs | 6 +++--- datafusion/common/src/dfschema.rs | 15 ++++++++++++++- datafusion/core/src/datasource/listing/helpers.rs | 2 +- datafusion/core/src/physical_planner.rs | 2 +- datafusion/expr/src/expr_schema.rs | 4 ++-- datafusion/expr/src/logical_plan/builder.rs | 2 +- datafusion/expr/src/logical_plan/plan.rs | 2 +- .../optimizer/src/analyzer/type_coercion.rs | 12 ++++++------ .../optimizer/src/common_subexpr_eliminate.rs | 6 +++--- .../optimizer/src/propagate_empty_relation.rs | 2 +- .../src/simplify_expressions/expr_simplifier.rs | 2 +- .../optimizer/src/unwrap_cast_in_comparison.rs | 2 +- 12 files changed, 35 insertions(+), 22 deletions(-) diff --git a/datafusion-examples/examples/expr_api.rs b/datafusion-examples/examples/expr_api.rs index 591f6ac3de95..36ce3badcb5e 100644 --- a/datafusion-examples/examples/expr_api.rs +++ b/datafusion-examples/examples/expr_api.rs @@ -292,14 +292,14 @@ fn expression_type_demo() -> Result<()> { // types of the input expressions. You can provide this information using // a schema. In this case we create a schema where the column `c` is of // type Utf8 (a String / VARCHAR) - let schema = DFSchema::from_unqualifed_fields( + let schema = DFSchema::from_unqualified_fields( vec![Field::new("c", DataType::Utf8, true)].into(), HashMap::new(), )?; assert_eq!("Utf8", format!("{}", expr.get_type(&schema).unwrap())); // Using a schema where the column `foo` is of type Int32 - let schema = DFSchema::from_unqualifed_fields( + let schema = DFSchema::from_unqualified_fields( vec![Field::new("c", DataType::Int32, true)].into(), HashMap::new(), )?; @@ -308,7 +308,7 @@ fn expression_type_demo() -> Result<()> { // Get the type of an expression that adds 2 columns. Adding an Int32 // and Float32 results in Float32 type let expr = col("c1") + col("c2"); - let schema = DFSchema::from_unqualifed_fields( + let schema = DFSchema::from_unqualified_fields( vec![ Field::new("c1", DataType::Int32, true), Field::new("c2", DataType::Float32, true), diff --git a/datafusion/common/src/dfschema.rs b/datafusion/common/src/dfschema.rs index 0dab13d08731..3c2cc89fc014 100644 --- a/datafusion/common/src/dfschema.rs +++ b/datafusion/common/src/dfschema.rs @@ -98,7 +98,7 @@ pub type DFSchemaRef = Arc; /// use arrow::datatypes::Field; /// use std::collections::HashMap; /// -/// let df_schema = DFSchema::from_unqualifed_fields(vec![ +/// let df_schema = DFSchema::from_unqualified_fields(vec![ /// Field::new("c1", arrow::datatypes::DataType::Int32, false), /// ].into(),HashMap::new()).unwrap(); /// let schema = Schema::from(df_schema); @@ -159,6 +159,19 @@ impl DFSchema { } /// Create a new `DFSchema` from a list of Arrow [Field]s + #[allow(deprecated)] + pub fn from_unqualified_fields( + fields: Fields, + metadata: HashMap, + ) -> Result { + Self::from_unqualifed_fields(fields, metadata) + } + + /// Create a new `DFSchema` from a list of Arrow [Field]s + #[deprecated( + since = "40.0.0", + note = "Please use `from_unqualified_fields` instead (this one's name is a typo). This method is subject to be removed soon" + )] pub fn from_unqualifed_fields( fields: Fields, metadata: HashMap, diff --git a/datafusion/core/src/datasource/listing/helpers.rs b/datafusion/core/src/datasource/listing/helpers.rs index 822a66783819..c1ce4cc5b6c5 100644 --- a/datafusion/core/src/datasource/listing/helpers.rs +++ b/datafusion/core/src/datasource/listing/helpers.rs @@ -261,7 +261,7 @@ async fn prune_partitions( .collect(); let schema = Arc::new(Schema::new(fields)); - let df_schema = DFSchema::from_unqualifed_fields( + let df_schema = DFSchema::from_unqualified_fields( partition_cols .iter() .map(|(n, d)| Field::new(n, d.clone(), true)) diff --git a/datafusion/core/src/physical_planner.rs b/datafusion/core/src/physical_planner.rs index 9dfc62f3a741..a0390cf16c17 100644 --- a/datafusion/core/src/physical_planner.rs +++ b/datafusion/core/src/physical_planner.rs @@ -2763,7 +2763,7 @@ mod tests { fn default() -> Self { Self { schema: DFSchemaRef::new( - DFSchema::from_unqualifed_fields( + DFSchema::from_unqualified_fields( vec![Field::new("a", DataType::Int32, false)].into(), HashMap::new(), ) diff --git a/datafusion/expr/src/expr_schema.rs b/datafusion/expr/src/expr_schema.rs index d5a04ad4ae1f..8bb655eda575 100644 --- a/datafusion/expr/src/expr_schema.rs +++ b/datafusion/expr/src/expr_schema.rs @@ -80,7 +80,7 @@ impl ExprSchemable for Expr { /// /// fn main() { /// let expr = col("c1") + col("c2"); - /// let schema = DFSchema::from_unqualifed_fields( + /// let schema = DFSchema::from_unqualified_fields( /// vec![ /// Field::new("c1", DataType::Int32, true), /// Field::new("c2", DataType::Float32, true), @@ -668,7 +668,7 @@ mod tests { .unwrap() ); - let schema = DFSchema::from_unqualifed_fields( + let schema = DFSchema::from_unqualified_fields( vec![Field::new("foo", DataType::Int32, true).with_metadata(meta.clone())] .into(), HashMap::new(), diff --git a/datafusion/expr/src/logical_plan/builder.rs b/datafusion/expr/src/logical_plan/builder.rs index 11a8112650d1..1f1175088227 100644 --- a/datafusion/expr/src/logical_plan/builder.rs +++ b/datafusion/expr/src/logical_plan/builder.rs @@ -223,7 +223,7 @@ impl LogicalPlanBuilder { Field::new(name, data_type.clone(), true) }) .collect::>(); - let dfschema = DFSchema::from_unqualifed_fields(fields.into(), HashMap::new())?; + let dfschema = DFSchema::from_unqualified_fields(fields.into(), HashMap::new())?; let schema = DFSchemaRef::new(dfschema); Ok(Self::from(LogicalPlan::Values(Values { schema, values }))) } diff --git a/datafusion/expr/src/logical_plan/plan.rs b/datafusion/expr/src/logical_plan/plan.rs index 31f830a6a13d..aef11853c81c 100644 --- a/datafusion/expr/src/logical_plan/plan.rs +++ b/datafusion/expr/src/logical_plan/plan.rs @@ -2080,7 +2080,7 @@ impl SubqueryAlias { let fields = change_redundant_column(plan.schema().fields()); let meta_data = plan.schema().as_ref().metadata().clone(); let schema: Schema = - DFSchema::from_unqualifed_fields(fields.into(), meta_data)?.into(); + DFSchema::from_unqualified_fields(fields.into(), meta_data)?.into(); // Since schema is the same, other than qualifier, we can use existing // functional dependencies: let func_dependencies = plan.schema().functional_dependencies().clone(); diff --git a/datafusion/optimizer/src/analyzer/type_coercion.rs b/datafusion/optimizer/src/analyzer/type_coercion.rs index 51ec8d8af1d3..64d9c508f3f6 100644 --- a/datafusion/optimizer/src/analyzer/type_coercion.rs +++ b/datafusion/optimizer/src/analyzer/type_coercion.rs @@ -843,7 +843,7 @@ mod test { Arc::new(LogicalPlan::EmptyRelation(EmptyRelation { produce_one_row: false, schema: Arc::new( - DFSchema::from_unqualifed_fields( + DFSchema::from_unqualified_fields( vec![Field::new("a", data_type, true)].into(), std::collections::HashMap::new(), ) @@ -1081,7 +1081,7 @@ mod test { let expr = col("a").in_list(vec![lit(1_i32), lit(4_i8), lit(8_i64)], false); let empty = Arc::new(LogicalPlan::EmptyRelation(EmptyRelation { produce_one_row: false, - schema: Arc::new(DFSchema::from_unqualifed_fields( + schema: Arc::new(DFSchema::from_unqualified_fields( vec![Field::new("a", DataType::Decimal128(12, 4), true)].into(), std::collections::HashMap::new(), )?), @@ -1278,7 +1278,7 @@ mod test { #[test] fn test_type_coercion_rewrite() -> Result<()> { // gt - let schema = Arc::new(DFSchema::from_unqualifed_fields( + let schema = Arc::new(DFSchema::from_unqualified_fields( vec![Field::new("a", DataType::Int64, true)].into(), std::collections::HashMap::new(), )?); @@ -1289,7 +1289,7 @@ mod test { assert_eq!(expected, result); // eq - let schema = Arc::new(DFSchema::from_unqualifed_fields( + let schema = Arc::new(DFSchema::from_unqualified_fields( vec![Field::new("a", DataType::Int64, true)].into(), std::collections::HashMap::new(), )?); @@ -1300,7 +1300,7 @@ mod test { assert_eq!(expected, result); // lt - let schema = Arc::new(DFSchema::from_unqualifed_fields( + let schema = Arc::new(DFSchema::from_unqualified_fields( vec![Field::new("a", DataType::Int64, true)].into(), std::collections::HashMap::new(), )?); @@ -1373,7 +1373,7 @@ mod test { #[test] fn test_case_expression_coercion() -> Result<()> { - let schema = Arc::new(DFSchema::from_unqualifed_fields( + let schema = Arc::new(DFSchema::from_unqualified_fields( vec![ Field::new("boolean", DataType::Boolean, true), Field::new("integer", DataType::Int32, true), diff --git a/datafusion/optimizer/src/common_subexpr_eliminate.rs b/datafusion/optimizer/src/common_subexpr_eliminate.rs index e760845e043a..81b987b0d4fc 100644 --- a/datafusion/optimizer/src/common_subexpr_eliminate.rs +++ b/datafusion/optimizer/src/common_subexpr_eliminate.rs @@ -1702,7 +1702,7 @@ mod test { fn test_extract_expressions_from_grouping_set() -> Result<()> { let mut result = Vec::with_capacity(3); let grouping = grouping_set(vec![vec![col("a"), col("b")], vec![col("c")]]); - let schema = DFSchema::from_unqualifed_fields( + let schema = DFSchema::from_unqualified_fields( vec![ Field::new("a", DataType::Int32, false), Field::new("b", DataType::Int32, false), @@ -1721,7 +1721,7 @@ mod test { fn test_extract_expressions_from_grouping_set_with_identical_expr() -> Result<()> { let mut result = Vec::with_capacity(2); let grouping = grouping_set(vec![vec![col("a"), col("b")], vec![col("a")]]); - let schema = DFSchema::from_unqualifed_fields( + let schema = DFSchema::from_unqualified_fields( vec![ Field::new("a", DataType::Int32, false), Field::new("b", DataType::Int32, false), @@ -1790,7 +1790,7 @@ mod test { #[test] fn test_extract_expressions_from_col() -> Result<()> { let mut result = Vec::with_capacity(1); - let schema = DFSchema::from_unqualifed_fields( + let schema = DFSchema::from_unqualified_fields( vec![Field::new("a", DataType::Int32, false)].into(), HashMap::default(), )?; diff --git a/datafusion/optimizer/src/propagate_empty_relation.rs b/datafusion/optimizer/src/propagate_empty_relation.rs index 63b357510f2f..576dabe305e6 100644 --- a/datafusion/optimizer/src/propagate_empty_relation.rs +++ b/datafusion/optimizer/src/propagate_empty_relation.rs @@ -578,7 +578,7 @@ mod tests { let empty = LogicalPlan::EmptyRelation(EmptyRelation { produce_one_row: false, - schema: Arc::new(DFSchema::from_unqualifed_fields( + schema: Arc::new(DFSchema::from_unqualified_fields( fields.into(), Default::default(), )?), diff --git a/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs b/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs index f2c80e4a7207..36dd85ac96e1 100644 --- a/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs +++ b/datafusion/optimizer/src/simplify_expressions/expr_simplifier.rs @@ -3005,7 +3005,7 @@ mod tests { fn expr_test_schema() -> DFSchemaRef { Arc::new( - DFSchema::from_unqualifed_fields( + DFSchema::from_unqualified_fields( vec![ Field::new("c1", DataType::Utf8, true), Field::new("c2", DataType::Boolean, true), diff --git a/datafusion/optimizer/src/unwrap_cast_in_comparison.rs b/datafusion/optimizer/src/unwrap_cast_in_comparison.rs index fb18518fd226..de471d59c466 100644 --- a/datafusion/optimizer/src/unwrap_cast_in_comparison.rs +++ b/datafusion/optimizer/src/unwrap_cast_in_comparison.rs @@ -839,7 +839,7 @@ mod tests { fn expr_test_schema() -> DFSchemaRef { Arc::new( - DFSchema::from_unqualifed_fields( + DFSchema::from_unqualified_fields( vec![ Field::new("c1", DataType::Int32, false), Field::new("c2", DataType::Int64, false),