Skip to content
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

List files #904

Closed
wants to merge 10 commits into from
20 changes: 20 additions & 0 deletions crates/iceberg/src/io/file_io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ impl FileIO {
Ok(op.exists(relative_path).await?)
}

/// List the path and all nested dirs and files recursively.
///
/// # Arguments
///
/// * path: It should be *absolute* path starting with scheme string used to construct [`FileIO`].
pub async fn list(&self, path: impl AsRef<str>) -> Result<Vec<opendal::Entry>> {
let (op, relative_path) = self.inner.create_operator(&path)?;
Ok(op.list(relative_path).await?)
}

/// Creates input file.
///
/// # Arguments
Expand Down Expand Up @@ -355,6 +365,16 @@ impl OutputFile {
writer.close().await
}

/// Create a new output file with given bytes.
/// Error out if the file already exists
pub async fn write_exclusive(&self, bs: Bytes) -> crate::Result<()> {
self.op
.write_with(&self.path[self.relative_path_pos..], bs)
.if_not_exists(true)
.await?;
Ok(())
}

/// Creates output file for continues writing.
///
/// # Notes
Expand Down
4 changes: 4 additions & 0 deletions crates/integrations/datafusion/src/table/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ impl IcebergTableProvider {
schema,
})
}

pub fn table(&self) -> Table {
self.table.clone()
}
}

#[async_trait]
Expand Down
Loading