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

Introduce TableChangesScan::execute and ScanFileReader #555

Closed
wants to merge 36 commits into from

Conversation

OussamaSaoudi-db
Copy link
Collaborator

@OussamaSaoudi-db OussamaSaoudi-db commented Nov 30, 2024

What changes are proposed in this pull request?

This PR introduces TableChangesScan::execute, which reads the change data feed for a TableChangesScan. We do so by introducing a ScanFileReader which performs all the data file reading, batch iteration, and physical to logical transformation.

I introduce some helper methods for resolving the deletion vectors in ScanFile and the remove_dv.

Depends on #546

How was this change tested?

TODO: add tests

Copy link

codecov bot commented Nov 30, 2024

Codecov Report

Attention: Patch coverage is 72.00976% with 344 lines in your changes missing coverage. Please review.

Project coverage is 80.05%. Comparing base (953ceed) to head (13cb83c).
Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
kernel/src/table_changes/data_read.rs 0.00% 172 Missing ⚠️
kernel/src/table_changes/log_replay.rs 89.49% 40 Missing and 27 partials ⚠️
kernel/src/table_changes/scan.rs 4.83% 59 Missing ⚠️
kernel/src/table_changes/scan_file.rs 86.41% 26 Missing and 13 partials ⚠️
kernel/src/expressions/scalars.rs 0.00% 5 Missing ⚠️
ffi/src/error.rs 0.00% 1 Missing ⚠️
kernel/src/scan/state.rs 90.90% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #555      +/-   ##
==========================================
- Coverage   80.61%   80.05%   -0.57%     
==========================================
  Files          67       71       +4     
  Lines       14278    15499    +1221     
  Branches    14278    15499    +1221     
==========================================
+ Hits        11510    12407     +897     
- Misses       2188     2478     +290     
- Partials      580      614      +34     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@github-actions github-actions bot added the breaking-change Change that will require a version bump label Nov 30, 2024
Copy link
Collaborator

@nicklan nicklan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

few initial comments

struct Cli {
/// Path to the table to inspect
path: String,

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra spaces

use bytes::Bytes;
use roaring::RoaringTreemap;
use std::io::{Cursor, Read};
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you need these?

@@ -54,19 +55,26 @@ impl DvInfo {
self.deletion_vector.is_some()
}

pub fn get_selection_vector(
pub fn get_treemap(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pub(crate)?

}
}

pub(crate) fn get_generated_columns(&self) -> DeltaResult<HashMap<String, Expression>> {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doesn't need to be pub(crate)

}
}

pub fn scan_data(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't make this pub yet

Comment on lines +70 to +75
let generated_columns: HashMap<String, Expression> = cols
.iter()
.map(ToString::to_string)
.zip(expressions)
.collect();
Ok(generated_columns)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to make these Strings:

Suggested change
let generated_columns: HashMap<String, Expression> = cols
.iter()
.map(ToString::to_string)
.zip(expressions)
.collect();
Ok(generated_columns)
Ok(cols.into_iter().zip(expressions).collect())

Also requires:

  • Change the return of this to DeltaResult<HashMap<&str, Expression>>
  • do: .remove(field_name.as_str()) on 106 below

mut self,
engine: &dyn Engine,
) -> DeltaResult<impl Iterator<Item = DeltaResult<ScanResult>>> {
let table_root = Url::parse(&self.global_scan_state.table_root)?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this down to just above when you join to get location

}))
}
}
pub(crate) fn resolve_scan_file_dv(
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc comment please

@OussamaSaoudi-db
Copy link
Collaborator Author

Closing this to break it up into smaller pieces. I'll address the comments in the new PRs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change Change that will require a version bump
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants