-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
use Into<String> as argument type wherever applicable #615
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
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, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { | ||
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
&str
then 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::scan
at the end of the function.