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

Adding predicate to protocol and metadata log replay query #336

Merged
Merged
13 changes: 11 additions & 2 deletions kernel/src/snapshot.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
//!

use std::cmp::Ordering;
use std::ops::Not;
use std::sync::Arc;

use itertools::Itertools;
Expand Down Expand Up @@ -71,9 +72,17 @@ impl LogSegment {

fn read_metadata(&self, engine: &dyn Engine) -> DeltaResult<Option<(Metadata, Protocol)>> {
let schema = get_log_schema().project(&[PROTOCOL_NAME, METADATA_NAME])?;
// filter out log files that do not contain metadata or protocol information
let filter = Some(Expression::or(
Expression::not(Expression::is_null(Expression::Column(
"metaData.id".into(),
))),
Expression::not(Expression::is_null(Expression::Column(
"protocol.min_reader_version".into(),
))),
));
// read the same protocol and metadata schema for both commits and checkpoints
// TODO add metadata.table_id is not null and protocol.something_required is not null
let data_batches = self.replay(engine, schema.clone(), schema, None)?;
let data_batches = self.replay(engine, schema.clone(), schema, filter)?;
let mut metadata_opt: Option<Metadata> = None;
let mut protocol_opt: Option<Protocol> = None;
for batch in data_batches {
Expand Down
Loading