Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 2.3k
use Into<String> as argument type wherever applicable#615
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -115,39 +115,41 @@ impl LogicalPlanBuilder { | ||
| /// Scan a CSV data source | ||
| pub fn scan_csv( | ||
| path: &str, | ||
| path: impl Into<String>, | ||
| options: CsvReadOptions, | ||
| projection: Option<Vec<usize>>, | ||
| ) -> Result<Self> { | ||
| Self::scan_csv_with_name(path, options, projection, path) | ||
| let path = path.into(); | ||
| Self::scan_csv_with_name(path.clone(), options, projection, path) | ||
| } | ||
| /// Scan a CSV data source and register it with a given table name | ||
| pub fn scan_csv_with_name( | ||
| path: &str, | ||
| path: impl Into<String>, | ||
| options: CsvReadOptions, | ||
| projection: Option<Vec<usize>>, | ||
| table_name: &str, | ||
| table_name: impl Into<String>, | ||
| ) -> Result<Self> { | ||
| let provider = Arc::new(CsvFile::try_new(path, options)?); | ||
| Self::scan(table_name, provider, projection) | ||
| } | ||
| /// Scan a Parquet data source | ||
| pub fn scan_parquet( | ||
| path: &str, | ||
| path: impl Into<String>, | ||
| projection: Option<Vec<usize>>, | ||
| max_concurrency: usize, | ||
| ) -> Result<Self> { | ||
| Self::scan_parquet_with_name(path, projection, max_concurrency, path) | ||
| let path = path.into(); | ||
| Self::scan_parquet_with_name(path.clone(), projection, max_concurrency, path) | ||
| } | ||
| /// Scan a Parquet data source and register it with a given table name | ||
| pub fn scan_parquet_with_name( | ||
| path: &str, | ||
| path: impl Into<String>, | ||
| projection: Option<Vec<usize>>, | ||
| max_concurrency: usize, | ||
| table_name: &str, | ||
| table_name: impl Into<String>, | ||
| ) -> Result<Self> { | ||
| let provider = Arc::new(ParquetTable::try_new(path, max_concurrency)?); | ||
| Self::scan(table_name, provider, projection) | ||
| @@ -166,10 +168,12 @@ impl LogicalPlanBuilder { | ||
| /// Convert a table provider into a builder with a TableScan | ||
| pub fn scan( | ||
| table_name: &str, | ||
| table_name: impl Into<String>, | ||
| provider: Arc<dyn TableProvider>, | ||
| projection: Option<Vec<usize>>, | ||
| ) -> Result<Self> { | ||
| let table_name = table_name.into(); | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This change makes sense to me as this function previously was making an explicit copy and no can reuse the copy the caller passed in, if any 👍 | ||
| if table_name.is_empty() { | ||
| return Err(DataFusionError::Plan( | ||
| "table_name cannot be empty".to_string(), | ||
| @@ -184,17 +188,17 @@ impl LogicalPlanBuilder { | ||
| DFSchema::new( | ||
| p.iter() | ||
| .map(|i| { | ||
| DFField::from_qualified(table_name, schema.field(*i).clone()) | ||
| DFField::from_qualified(&table_name, schema.field(*i).clone()) | ||
| }) | ||
| .collect(), | ||
| ) | ||
| }) | ||
| .unwrap_or_else(|| { | ||
| DFSchema::try_from_qualified_schema(table_name, &schema) | ||
| DFSchema::try_from_qualified_schema(&table_name, &schema) | ||
| })?; | ||
| let table_scan = LogicalPlan::TableScan { | ||
| table_name: table_name.to_string(), | ||
| table_name, | ||
| source: provider, | ||
| projected_schema: Arc::new(projected_schema), | ||
| projection, | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -44,10 +44,10 @@ pub struct Column { | ||
| impl Column { | ||
| /// Create Column from unqualified name. | ||
| pub fn from_name(name: String) -> Self { | ||
| pub fn from_name(name: impl Into<String>) -> Self { | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 | ||
| Self { | ||
| relation: None, | ||
| name, | ||
| name: name.into(), | ||
| } | ||
| } | ||
| @@ -131,7 +131,7 @@ impl fmt::Display for Column { | ||
| /// ``` | ||
| /// # use datafusion::logical_plan::*; | ||
| /// let expr = col("c1"); | ||
| /// assert_eq!(expr, Expr::Column(Column::from_name("c1".to_string()))); | ||
| /// assert_eq!(expr, Expr::Column(Column::from_name("c1"))); | ||
| /// ``` | ||
| /// | ||
| /// ## Create the expression `c1 + c2` to add columns "c1" and "c2" together | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As above, this pattern just doesn't make a lot of sense to me -- if someone passed in a
&strthen this code will now create a copy (aString) and then simply use a reference to that copy (rather than the path itself)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the owned value is passed along to
Self::scanat the end of the function.