-
Couldn't load subscription status.
- Fork 118
refactor: Remove raw pointer indexing and add unit tests for RowIndexBuilder #1334
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
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d08e062
refactor: Remove raw pointer indexing and add unit tests for RowIndex…
lbhm 733952b
Refactor RowIndexBuilder::into_iter to RowIndexBuilder::build
lbhm c6a5460
Address nits
lbhm d1efad5
Merge branch 'main' into row-index-cleanup
zachschuermann File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,9 +3,10 @@ use std::path::PathBuf; | |
| use std::sync::Arc; | ||
|
|
||
| use delta_kernel::actions::deletion_vector::split_vector; | ||
| use delta_kernel::arrow::array::AsArray as _; | ||
| use delta_kernel::arrow::array::{AsArray as _, BooleanArray}; | ||
| use delta_kernel::arrow::compute::{concat_batches, filter_record_batch}; | ||
| use delta_kernel::arrow::datatypes::{Int64Type, Schema as ArrowSchema}; | ||
| use delta_kernel::arrow::record_batch::RecordBatch; | ||
| use delta_kernel::engine::arrow_conversion::TryFromKernel as _; | ||
| use delta_kernel::engine::default::executor::tokio::TokioBackgroundExecutor; | ||
| use delta_kernel::engine::default::DefaultEngine; | ||
|
|
@@ -14,7 +15,7 @@ use delta_kernel::expressions::{ | |
| }; | ||
| use delta_kernel::parquet::file::properties::{EnabledStatistics, WriterProperties}; | ||
| use delta_kernel::scan::state::{transform_to_logical, DvInfo, Stats}; | ||
| use delta_kernel::scan::Scan; | ||
| use delta_kernel::scan::{Scan, ScanResult}; | ||
| use delta_kernel::schema::{DataType, MetadataColumnSpec, Schema, StructField, StructType}; | ||
| use delta_kernel::{Engine, FileMeta, Snapshot}; | ||
|
|
||
|
|
@@ -33,6 +34,23 @@ const PARQUET_FILE1: &str = "part-00000-a72b1fb3-f2df-41fe-a8f0-e65b746382dd-c00 | |
| const PARQUET_FILE2: &str = "part-00001-c506e79a-0bf8-4e2b-a42b-9731b2e490ae-c000.snappy.parquet"; | ||
| const PARQUET_FILE3: &str = "part-00002-c506e79a-0bf8-4e2b-a42b-9731b2e490ff-c000.snappy.parquet"; | ||
|
|
||
| /// Helper function to extract filtered data from a scan result, respecting row masks | ||
| fn extract_record_batch( | ||
| scan_result: ScanResult, | ||
| ) -> Result<RecordBatch, Box<dyn std::error::Error>> { | ||
|
Comment on lines
+38
to
+40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| let mask = scan_result.full_mask(); | ||
| let record_batch = into_record_batch(scan_result.raw_data?); | ||
|
|
||
| if let Some(mask) = mask { | ||
| Ok(filter_record_batch( | ||
| &record_batch, | ||
| &BooleanArray::from(mask), | ||
| )?) | ||
| } else { | ||
| Ok(record_batch) | ||
| } | ||
| } | ||
|
|
||
| #[tokio::test] | ||
| async fn single_commit_two_add_files() -> Result<(), Box<dyn std::error::Error>> { | ||
| let batch = generate_simple_batch()?; | ||
|
|
@@ -1382,24 +1400,18 @@ async fn test_row_index_metadata_column() -> Result<(), Box<dyn std::error::Erro | |
| ) | ||
| .await?; | ||
|
|
||
| storage | ||
| .put( | ||
| &Path::from(PARQUET_FILE1), | ||
| record_batch_to_bytes(&batch1).into(), | ||
| ) | ||
| .await?; | ||
| storage | ||
| .put( | ||
| &Path::from(PARQUET_FILE2), | ||
| record_batch_to_bytes(&batch2).into(), | ||
| ) | ||
| .await?; | ||
| storage | ||
| .put( | ||
| &Path::from(PARQUET_FILE3), | ||
| record_batch_to_bytes(&batch3).into(), | ||
| ) | ||
| .await?; | ||
| for (parquet_file, batch) in [ | ||
| (PARQUET_FILE1, &batch1), | ||
| (PARQUET_FILE2, &batch2), | ||
| (PARQUET_FILE3, &batch3), | ||
| ] { | ||
| storage | ||
| .put( | ||
| &Path::from(parquet_file), | ||
| record_batch_to_bytes(batch).into(), | ||
| ) | ||
| .await?; | ||
| } | ||
|
|
||
| let location = Url::parse("memory:///")?; | ||
| let engine = Arc::new(DefaultEngine::new( | ||
|
|
@@ -1422,8 +1434,7 @@ async fn test_row_index_metadata_column() -> Result<(), Box<dyn std::error::Erro | |
| let stream = scan.execute(engine.clone())?; | ||
|
|
||
| for scan_result in stream { | ||
| let data = scan_result?.raw_data?; | ||
| let batch = into_record_batch(data); | ||
| let batch = extract_record_batch(scan_result?)?; | ||
| file_count += 1; | ||
|
|
||
| // Verify the schema structure | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #1272 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The various call sites like
fixup_parquet_readandreorder_struct_arrayshould start using this instead of<RowIndexBuilder as IntoIterator>::IntoIterThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also did this as part of this PR. I searched for all occurrences of
<RowIndexBuilder as IntoIterator>and replaced them.