Struct deltalake::datafusion::datasource::listing::ListingTableUrl
source · pub struct ListingTableUrl { /* private fields */ }
Expand description
A parsed URL identifying files for a listing table, see ListingTableUrl::parse
for more information on the supported expressions
Implementations§
source§impl ListingTableUrl
impl ListingTableUrl
sourcepub fn parse(s: impl AsRef<str>) -> Result<ListingTableUrl, DataFusionError>
pub fn parse(s: impl AsRef<str>) -> Result<ListingTableUrl, DataFusionError>
Parse a provided string as a ListingTableUrl
A URL can either refer to a single object, or a collection of objects with a
common prefix, with the presence of a trailing /
indicating a collection.
For example, file:///foo.txt
refers to the file at /foo.txt
, whereas
file:///foo/
refers to all the files under the directory /foo
and its
subdirectories.
Similarly s3://BUCKET/blob.csv
refers to blob.csv
in the S3 bucket BUCKET
,
wherease s3://BUCKET/foo/
refers to all objects with the prefix foo/
in the
S3 bucket BUCKET
§URL Encoding
URL paths are expected to be URL-encoded. That is, the URL for a file named bar%2Efoo
would be file:///bar%252Efoo
, as per the URL specification.
It should be noted that some tools, such as the AWS CLI, take a different approach and
instead interpret the URL path verbatim. For example the object bar%2Efoo
would be
addressed as s3://BUCKET/bar%252Efoo
using ListingTableUrl
but s3://BUCKET/bar%2Efoo
when using the aws-cli.
§Paths without a Scheme
If no scheme is provided, or the string is an absolute filesystem path
as determined by std::path::Path::is_absolute
, the string will be
interpreted as a path on the local filesystem using the operating
system’s standard path delimiter, i.e. \
on Windows, /
on Unix.
If the path contains any of '?', '*', '['
, it will be considered
a glob expression and resolved as described in the section below.
Otherwise, the path will be resolved to an absolute path based on the current working directory, and converted to a file URI.
If the path already exists in the local filesystem this will be used to determine if this
ListingTableUrl
refers to a collection or a single object, otherwise the presence
of a trailing path delimiter will be used to indicate a directory. For the avoidance
of ambiguity it is recommended users always include trailing /
when intending to
refer to a directory.
§Glob File Paths
If no scheme is provided, and the path contains a glob expression, it will be resolved as follows.
The string up to the first path segment containing a glob expression will be extracted, and resolved in the same manner as a normal scheme-less path above.
The remaining string will be interpreted as a glob::Pattern
and used as a
filter when listing files from object storage
sourcepub fn prefix(&self) -> &Path
pub fn prefix(&self) -> &Path
Return the URL path not excluding any glob expression
If Self::is_collection
, this is the listing prefix
Otherwise, this is the path to the object
sourcepub fn contains(&self, path: &Path, ignore_subdirectory: bool) -> bool
pub fn contains(&self, path: &Path, ignore_subdirectory: bool) -> bool
Returns true
if path
matches this ListingTableUrl
sourcepub fn is_collection(&self) -> bool
pub fn is_collection(&self) -> bool
Returns true
if path
refers to a collection of objects
sourcepub async fn list_all_files<'a>(
&'a self,
ctx: &'a SessionState,
store: &'a (dyn ObjectStore + 'static),
file_extension: &'a str
) -> Result<Pin<Box<dyn Stream<Item = Result<ObjectMeta, DataFusionError>> + Send + 'a>>, DataFusionError>
pub async fn list_all_files<'a>( &'a self, ctx: &'a SessionState, store: &'a (dyn ObjectStore + 'static), file_extension: &'a str ) -> Result<Pin<Box<dyn Stream<Item = Result<ObjectMeta, DataFusionError>> + Send + 'a>>, DataFusionError>
List all files identified by this ListingTableUrl
for the provided file_extension
sourcepub fn as_str(&self) -> &str
pub fn as_str(&self) -> &str
Returns this ListingTableUrl
as a string
sourcepub fn object_store(&self) -> ObjectStoreUrl
pub fn object_store(&self) -> ObjectStoreUrl
Return the ObjectStoreUrl
for this ListingTableUrl
Trait Implementations§
source§impl AsRef<Url> for ListingTableUrl
impl AsRef<Url> for ListingTableUrl
source§impl AsRef<str> for ListingTableUrl
impl AsRef<str> for ListingTableUrl
source§impl Clone for ListingTableUrl
impl Clone for ListingTableUrl
source§fn clone(&self) -> ListingTableUrl
fn clone(&self) -> ListingTableUrl
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ListingTableUrl
impl Debug for ListingTableUrl
source§impl Display for ListingTableUrl
impl Display for ListingTableUrl
source§impl Hash for ListingTableUrl
impl Hash for ListingTableUrl
source§impl PartialEq for ListingTableUrl
impl PartialEq for ListingTableUrl
source§fn eq(&self, other: &ListingTableUrl) -> bool
fn eq(&self, other: &ListingTableUrl) -> bool
self
and other
values to be equal, and is used
by ==
.impl Eq for ListingTableUrl
impl StructuralPartialEq for ListingTableUrl
Auto Trait Implementations§
impl Freeze for ListingTableUrl
impl RefUnwindSafe for ListingTableUrl
impl Send for ListingTableUrl
impl Sync for ListingTableUrl
impl Unpin for ListingTableUrl
impl UnwindSafe for ListingTableUrl
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more