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