MCPcopy Create free account
hub / github.com/apache/datafusion / file_extension

Method file_extension

datafusion/datasource/src/url.rs:220–230  ·  view source on GitHub ↗

Returns the file extension of the last path segment if it exists Examples: ```rust use datafusion_datasource::ListingTableUrl; let url = ListingTableUrl::parse("file:///foo/bar.csv").unwrap(); assert_eq!(url.file_extension(), Some("csv")); let url = ListingTableUrl::parse("file:///foo/bar").unwrap(); assert_eq!(url.file_extension(), None); let url = ListingTableUrl::parse("file:///foo/bar.").unwr

(&self)

Source from the content-addressed store, hash-verified

218 /// assert_eq!(url.file_extension(), None);
219 /// ```
220 pub fn file_extension(&self) -> Option<&str> {
221 if let Some(mut segments) = self.url.path_segments()
222 && let Some(last_segment) = segments.next_back()
223 && last_segment.contains(".")
224 && !last_segment.ends_with(".")
225 {
226 return last_segment.split('.').next_back();
227 }
228
229 None
230 }
231
232 /// Strips the prefix of this [`ListingTableUrl`] from the provided path, returning
233 /// an iterator of the remaining path segments

Callers 3

single_file_outputMethod · 0.45
runMethod · 0.45

Calls 2

containsMethod · 0.45
splitMethod · 0.45

Tested by 1