feat: add a way to retrieve storage path from parquet chunks
@@ -133,20 +133,19 @@ impl Chunk {
/// Return Schema for the specified table / columns
pub fn table_schema(&self, table_name: &str, selection: Selection<'_>) -> Result<Schema> {
- let table = self
- .tables
- .iter()
- .find(|t| t.has_table(table_name))
- .context(NamedTableNotFoundInChunk {
- table_name,
- chunk_id: self.id(),
- })?;
+ let table = self.find_table(table_name)?;
table
.schema(selection)
.context(NamedTableError { table_name })
}
+ /// Return object store path for specified table
+ pub fn table_path(&self, table_name: &str) -> Result<Path> {
+ let table = self.find_table(table_name)?;
+ Ok(table.path())
+ }
+
// Return all tables of this chunk whose timestamp overlaps with the give one
pub fn table_names(
&self,
@@ -168,14 +167,7 @@ impl Chunk {
table_name: &str,
selection: Selection<'_>,
) -> Option<BTreeSet<String>> {
- let table = self
- .tables
- .iter()
- .find(|t| t.has_table(table_name))
- .context(NamedTableNotFoundInChunk {
- table_name,
- chunk_id: self.id(),
- });
+ let table = self.find_table(table_name);
match table {
Ok(table) => table.column_names(selection),
@@ -190,14 +182,7 @@ impl Chunk {
predicate: &Predicate,
selection: Selection<'_>,
) -> Result<SendableRecordBatchStream> {
- let table = self
- .tables
- .iter()
- .find(|t| t.has_table(table_name))
- .context(NamedTableNotFoundInChunk {
- table_name,
- chunk_id: self.id(),
- })?;
+ let table = self.find_table(table_name)?;
table
.read_filter(predicate, selection)
@@ -211,4 +196,14 @@ impl Chunk {
pub fn rows(&self) -> usize {
self.tables.iter().map(|t| t.rows()).sum()
}
+
+ fn find_table(&self, table_name: &str) -> Result<&Table> {
+ self.tables
+ .iter()
+ .find(|t| t.has_table(table_name))
+ .context(NamedTableNotFoundInChunk {
+ table_name,
+ chunk_id: self.id(),
+ })
+ }
}
