Apache DataFusion SQL Query Engine
Minor: Use impl Into<Arc<str>> to construct TableReference (#9916)
Andrew Lambd2ba90109bc5
diff --git a/datafusion/common/src/table_reference.rs b/datafusion/common/src/table_reference.rsindex 1ffcbb8f34..63dbb95177 100644--- a/datafusion/common/src/table_reference.rs+++ b/datafusion/common/src/table_reference.rs@@ -131,7 +131,7 @@ impl TableReference {/// As described on [`TableReference`] this does *NO* parsing at/// all, so "Foo.Bar" stays as a reference to the table named/// "Foo.Bar" (rather than "foo"."bar")- pub fn bare(table: &str) -> TableReference {+ pub fn bare(table: impl Into<Arc<str>>) -> TableReference {TableReference::Bare {table: table.into(),}@@ -140,7 +140,10 @@ impl TableReference {/// Convenience method for creating a [`TableReference::Partial`].////// As described on [`TableReference`] this does *NO* parsing at all.- pub fn partial(schema: &str, table: &str) -> TableReference {+ pub fn partial(+ schema: impl Into<Arc<str>>,+ table: impl Into<Arc<str>>,+ ) -> TableReference {TableReference::Partial {schema: schema.into(),table: table.into(),@@ -150,7 +153,11 @@ impl TableReference {/// Convenience method for creating a [`TableReference::Full`]////// As described on [`TableReference`] this does *NO* parsing at all.- pub fn full(catalog: &str, schema: &str, table: &str) -> TableReference {+ pub fn full(+ catalog: impl Into<Arc<str>>,+ schema: impl Into<Arc<str>>,+ table: impl Into<Arc<str>>,+ ) -> TableReference {TableReference::Full {catalog: catalog.into(),schema: schema.into(),diff --git a/datafusion/proto/src/logical_plan/from_proto.rs b/datafusion/proto/src/logical_plan/from_proto.rsindex 02f73b296a..3694418412 100644--- a/datafusion/proto/src/logical_plan/from_proto.rs+++ b/datafusion/proto/src/logical_plan/from_proto.rs@@ -223,17 +223,17 @@ impl TryFrom<protobuf::OwnedTableReference> for OwnedTableReference {match table_reference_enum {TableReferenceEnum::Bare(protobuf::BareTableReference { table }) => {- Ok(OwnedTableReference::bare(&table))+ Ok(OwnedTableReference::bare(table))}TableReferenceEnum::Partial(protobuf::PartialTableReference {schema,table,- }) => Ok(OwnedTableReference::partial(&schema, &table)),+ }) => Ok(OwnedTableReference::partial(schema, table)),TableReferenceEnum::Full(protobuf::FullTableReference {catalog,schema,table,- }) => Ok(OwnedTableReference::full(&catalog, &schema, &table)),+ }) => Ok(OwnedTableReference::full(catalog, schema, table)),}}}diff --git a/datafusion/sql/src/planner.rs b/datafusion/sql/src/planner.rsindex 0ee7860573..d2182962b9 100644--- a/datafusion/sql/src/planner.rs+++ b/datafusion/sql/src/planner.rs@@ -307,7 +307,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {let plan = self.apply_expr_alias(plan, alias.columns)?;LogicalPlanBuilder::from(plan)- .alias(TableReference::bare(&self.normalizer.normalize(alias.name)))?+ .alias(TableReference::bare(self.normalizer.normalize(alias.name)))?.build()}@@ -530,18 +530,18 @@ pub(crate) fn idents_to_table_reference(match taker.0.len() {1 => {let table = taker.take(enable_normalization);- Ok(OwnedTableReference::bare(&table))+ Ok(OwnedTableReference::bare(table))}2 => {let table = taker.take(enable_normalization);let schema = taker.take(enable_normalization);- Ok(OwnedTableReference::partial(&schema, &table))+ Ok(OwnedTableReference::partial(schema, table))}3 => {let table = taker.take(enable_normalization);let schema = taker.take(enable_normalization);let catalog = taker.take(enable_normalization);- Ok(OwnedTableReference::full(&catalog, &schema, &table))+ Ok(OwnedTableReference::full(catalog, schema, table))}_ => plan_err!("Unsupported compound identifier '{:?}'", taker.0),}diff --git a/datafusion/sql/src/statement.rs b/datafusion/sql/src/statement.rsindex 84dab90678..69d1b71e4f 100644--- a/datafusion/sql/src/statement.rs+++ b/datafusion/sql/src/statement.rs@@ -994,7 +994,7 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {self.build_order_by(order_exprs, &df_schema, &mut planner_context)?;// External tables do not support schemas at the moment, so the name is just a table name- let name = OwnedTableReference::bare(&name);+ let name = OwnedTableReference::bare(name);let constraints =Constraints::new_from_table_constraints(&all_constraints, &df_schema)?;Ok(LogicalPlan::Ddl(DdlStatement::CreateExternalTable(