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

feat: support merge by row_id, row_addr #3254

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

chenkovsky
Copy link
Contributor

No description provided.

@github-actions github-actions bot added the enhancement New feature or request label Dec 16, 2024
@chenkovsky chenkovsky changed the title feat: merge by row_id, row_addr feat: support merge by row_id, row_addr Dec 16, 2024
Copy link
Contributor

@wjones127 wjones127 left a comment

Choose a reason for hiding this comment

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

Thanks for working on this @chenkovsky. I would like to see a few improvements to the unit tests, and then this is ready to go.

Comment on lines 3138 to 3139
let test_dir = tempdir().unwrap();
let test_uri = test_dir.path().to_str().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

If we aren't testing anything about the files, let's use an in-memory dataset instead.

Suggested change
let test_dir = tempdir().unwrap();
let test_uri = test_dir.path().to_str().unwrap();

Comment on lines 3149 to 3153
Dataset::write(data, test_uri, Some(write_params.clone()))
.await
.unwrap();

let mut dataset = Dataset::open(test_uri).await.unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

If you re-use the dataset instance from write(), you can just use an in-memory dataset:

Suggested change
Dataset::write(data, test_uri, Some(write_params.clone()))
.await
.unwrap();
let mut dataset = Dataset::open(test_uri).await.unwrap();
let dataset = Dataset::write(data, "memory://", Some(write_params.clone()))
.await
.unwrap();

Comment on lines 3163 to 3168
let new_batch =
RecordBatch::try_new(new_schema.clone(), vec![row_ids.clone(), row_ids.clone()])
.unwrap();
let new_data = RecordBatchIterator::new(vec![Ok(new_batch)], new_schema.clone());
dataset.merge(new_data, ROW_ID, "rowid").await.unwrap();
dataset.validate().await.unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd like us to assert a few more things in this test:

  1. dataset has the expected final schema key, value, new_value.
  2. The values are what we expect. For this, you should avoid using the same values in each column. Otherwise, the test could pass even if there is a bug that uses the wrong column's values. Right now, you use row_ids.clone() for both rowid and new_value.
  3. This works even if you shuffle the data. I would recommend using take_record_batch() to reorder the new_batch so the row ids are out-of-order.

Comment on lines 3130 to 3131
// This test also tests "null filling" when merging (e.g. when keys do not match
// we need to insert nulls)
Copy link
Contributor

Choose a reason for hiding this comment

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

Where is the null filling? It seems like you are providing every row id, unless I am missing something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Where is the null filling? It seems like you are providing every row id, unless I am missing something.

sorry, I copy and modify another test

Comment on lines 3171 to 3176
#[rstest]
#[tokio::test]
async fn test_merge_on_row_addr(
#[values(LanceFileVersion::Legacy, LanceFileVersion::Stable)]
data_storage_version: LanceFileVersion,
#[values(false, true)] use_stable_row_id: bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comments from the row id test apply here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 78.42%. Comparing base (83b8efd) to head (0ce8ac1).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3254      +/-   ##
==========================================
- Coverage   78.47%   78.42%   -0.05%     
==========================================
  Files         245      245              
  Lines       85088    85096       +8     
  Branches    85088    85096       +8     
==========================================
- Hits        66772    66738      -34     
- Misses      15501    15546      +45     
+ Partials     2815     2812       -3     
Flag Coverage Δ
unittests 78.42% <100.00%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants