2010YOUY01 commented on code in PR #7058:
URL: https://github.com/apache/arrow-datafusion/pull/7058#discussion_r1275386601
##########
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:
Good point, I will add support for patterns like `/foo$bar/` or `/$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]