alamb commented on code in PR #7058:
URL: https://github.com/apache/arrow-datafusion/pull/7058#discussion_r1275356651
##########
datafusion/core/src/datasource/listing/url.rs:
##########
@@ -87,6 +89,41 @@ impl ListingTableUrl {
}
}
+ /// Perform shell-like path expansions
+ /// * Home directory expansion: "~/test.csv" expands to
"/Users/user1/test.csv"
+ /// * Environment variable expansion: "$HOME/$DATA/test.csv" expands to
+ /// "/Users/user1/data/test.csv"
+ fn expand_path_prefix(path: &str) -> Result<String, DataFusionError> {
+ let home_dir = home::home_dir()
+ .unwrap()
Review Comment:
I don't think we should use either `unwrap` as it will cause a panic of the
user doesn't have a $HOME set, I think. Instead I think the code should simply
not attempt `~` substitution if it can't find the home directory expansion
##########
datafusion/core/src/datasource/listing/url.rs:
##########
@@ -87,6 +89,41 @@ impl ListingTableUrl {
}
}
+ /// Perform shell-like path expansions
+ /// * Home directory expansion: "~/test.csv" expands to
"/Users/user1/test.csv"
+ /// * Environment variable expansion: "$HOME/$DATA/test.csv" expands to
+ /// "/Users/user1/data/test.csv"
+ fn expand_path_prefix(path: &str) -> Result<String, DataFusionError> {
+ let home_dir = home::home_dir()
+ .unwrap()
+ .into_os_string()
+ .into_string()
+ .unwrap();
+
+ let path = path.replace('~', &home_dir);
+
+ let parts = path.split('/').collect::<Vec<_>>();
+ let mut expanded_parts = Vec::new();
+
+ for part in parts {
+ if let Some(envvar_name) = part.strip_prefix('$') {
Review Comment:
this only works for paths like `/$foo/` right, not `/foo$bar/`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]