@@ -8,8 +8,9 @@ use bytes::Bytes;
88pub use ir:: { IoOperation , Operation , QueryPlan , QueryPlanNode } ;
99pub 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
3940impl 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