Skip to content

Commit f0fe064

Browse files
committed
address comments
1 parent a68b9b6 commit f0fe064

4 files changed

Lines changed: 34 additions & 22 deletions

File tree

kernel/src/engine/plans/parquet.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,10 @@ impl ParquetHandler for PlanBasedParquetHandler {
4949
}
5050

5151
fn read_parquet_footer(&self, file: &FileMeta) -> DeltaResult<ParquetFooter> {
52-
let op = IoOperation::parquet_schema(file.clone());
53-
let schema = self
54-
.executor
52+
let op = IoOperation::parquet_footer(file.clone());
53+
self.executor
5554
.execute_op(Operation::IoOperation(op))?
56-
.into_schema()?;
57-
Ok(ParquetFooter { schema })
55+
.into_parquet_footer()
5856
}
5957
}
6058

kernel/src/engine/sync/plan.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ impl SyncPlanExecutor {
9393
self.storage.copy_atomic(&source, &destination)?;
9494
Ok(PlanResult::Unit)
9595
}
96-
IoOperation::ParquetSchema { file } => {
96+
IoOperation::ParquetFooter { file } => {
9797
let footer = self.parquet.read_parquet_footer(&file)?;
98-
Ok(PlanResult::Schema(footer.schema))
98+
Ok(PlanResult::ParquetFooter(footer))
9999
}
100100
}
101101
}

kernel/src/plans/ir.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,14 +62,14 @@ pub enum IoOperation {
6262
/// [`Error::FileAlreadyExists`](crate::Error::FileAlreadyExists) without modifying it.
6363
/// Returns [`PlanResult::Unit`](super::PlanResult::Unit) on success.
6464
AtomicCopy { source: Url, destination: Url },
65-
/// Read the schema from the footer of a Parquet file.
65+
/// Read the footer of a Parquet file.
6666
///
67-
/// Returns [`PlanResult::Schema`](super::PlanResult::Schema) containing the file's schema
68-
/// converted to Delta Kernel's format. See [`ParquetHandler::read_parquet_footer`] for the
69-
/// full contract.
67+
/// Returns [`PlanResult::ParquetFooter`](super::PlanResult::ParquetFooter) containing the
68+
/// file's footer metadata (schema and any future extensions). See
69+
/// [`ParquetHandler::read_parquet_footer`] for the full contract.
7070
///
7171
/// [`ParquetHandler::read_parquet_footer`]: crate::ParquetHandler::read_parquet_footer
72-
ParquetSchema { file: FileMeta },
72+
ParquetFooter { file: FileMeta },
7373
}
7474

7575
impl IoOperation {
@@ -100,8 +100,8 @@ impl IoOperation {
100100
}
101101
}
102102

103-
pub fn parquet_schema(file: FileMeta) -> Self {
104-
Self::ParquetSchema { file }
103+
pub fn parquet_footer(file: FileMeta) -> Self {
104+
Self::ParquetFooter { file }
105105
}
106106
}
107107

kernel/src/plans/mod.rs

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ use bytes::Bytes;
88
pub use ir::{IoOperation, Operation, QueryPlan, QueryPlanNode};
99
pub use query_builder::QueryPlanBuilder;
1010

11-
use crate::schema::SchemaRef;
12-
use crate::{AsAny, DeltaResult, DeltaResultIteratorStatic, EngineData, Error, FileMeta};
11+
use crate::{
12+
AsAny, DeltaResult, DeltaResultIteratorStatic, EngineData, Error, FileMeta, ParquetFooter,
13+
};
1314

1415
/// Provides the ability to execute declarative plans to the Delta Kernel.
1516
///
@@ -30,41 +31,54 @@ pub enum PlanResult {
3031
FileMeta(DeltaResultIteratorStatic<FileMeta>),
3132
/// A stream of raw byte buffers.
3233
Bytes(DeltaResultIteratorStatic<Bytes>),
33-
/// The schema of a file (e.g. a Parquet footer schema).
34-
Schema(SchemaRef),
34+
/// Metadata extracted from a Parquet file footer.
35+
ParquetFooter(ParquetFooter),
3536
/// Represents the successful completion of a plan, but with no return value.
3637
Unit,
3738
}
3839

3940
impl PlanResult {
41+
/// Consumes the PlanResult and extracts the inner iterator of EngineData (assuming that it is a
42+
/// PlanResult::Data variant). Returns an error if the PlanResult is not the expected variant.
4043
pub fn into_data(self) -> DeltaResult<DeltaResultIteratorStatic<Box<dyn EngineData>>> {
4144
match self {
4245
Self::Data(iter) => Ok(iter),
4346
other => Err(other.type_mismatch("Data")),
4447
}
4548
}
4649

50+
/// Consumes the PlanResult and extracts the inner iterator of FileMeta (assuming that it is a
51+
/// PlanResult::FileMeta variant). Returns an error if the PlanResult is not the expected
52+
/// variant.
4753
pub fn into_file_meta(self) -> DeltaResult<DeltaResultIteratorStatic<FileMeta>> {
4854
match self {
4955
Self::FileMeta(iter) => Ok(iter),
5056
other => Err(other.type_mismatch("FileMeta")),
5157
}
5258
}
5359

60+
/// Consumes the PlanResult and extracts the inner iterator of Bytes (assuming that it is a
61+
/// PlanResult::Bytes variant). Returns an error if the PlanResult is not a PlanResult::Bytes
62+
/// variant.
5463
pub fn into_bytes(self) -> DeltaResult<DeltaResultIteratorStatic<Bytes>> {
5564
match self {
5665
Self::Bytes(iter) => Ok(iter),
5766
other => Err(other.type_mismatch("Bytes")),
5867
}
5968
}
6069

61-
pub fn into_schema(self) -> DeltaResult<SchemaRef> {
70+
/// Consumes the PlanResult and extracts the inner [`ParquetFooter`] (assuming that it is a
71+
/// PlanResult::ParquetFooter variant). Returns an error if the PlanResult is not the expected
72+
/// variant.
73+
pub fn into_parquet_footer(self) -> DeltaResult<ParquetFooter> {
6274
match self {
63-
Self::Schema(schema) => Ok(schema),
64-
other => Err(other.type_mismatch("Schema")),
75+
Self::ParquetFooter(footer) => Ok(footer),
76+
other => Err(other.type_mismatch("ParquetFooter")),
6577
}
6678
}
6779

80+
/// Consumes the PlanResult, verifying that it is a PlanResult::Unit variant. Returns an error
81+
/// if the PlanResult is not the expected variant.
6882
pub fn into_unit(self) -> DeltaResult<()> {
6983
match self {
7084
Self::Unit => Ok(()),
@@ -77,7 +91,7 @@ impl PlanResult {
7791
Self::Data(_) => "Data",
7892
Self::FileMeta(_) => "FileMeta",
7993
Self::Bytes(_) => "Bytes",
80-
Self::Schema(_) => "Schema",
94+
Self::ParquetFooter(_) => "ParquetFooter",
8195
Self::Unit => "Unit",
8296
}
8397
}

0 commit comments

Comments
 (0)