-
Couldn't load subscription status.
- Fork 118
refactor: unify Reader/WriterFeature into a single TableFeature #1345
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
base: main
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1345 +/- ##
==========================================
+ Coverage 84.81% 84.84% +0.03%
==========================================
Files 113 113
Lines 28647 28721 +74
Branches 28647 28721 +74
==========================================
+ Hits 24297 24369 +72
Misses 3196 3196
- Partials 1154 1156 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a1ed296 to
f70b355
Compare
| matches!( | ||
| feature.feature_type(), | ||
| FeatureType::Writer | FeatureType::Unknown | ||
| ) || reader_features.contains(feature) |
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.
There's never a case where we allow a reader feature and not a writer featurer.
| ) || reader_features.contains(feature) | |
| ) |
kernel/src/actions/mod.rs
Outdated
| (Some(reader_features), None) => { | ||
| if *reader_features == vec![TableFeature::ColumnMapping] { | ||
| Ok(()) | ||
| } else { | ||
| Err(Error::invalid_protocol( | ||
| "Reader features should be present in writer features", | ||
| )) | ||
| } |
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.
We won't allow a case where there are reader features but no writer features. So we can keep this simple.
| (Some(reader_features), None) => { | |
| if *reader_features == vec![TableFeature::ColumnMapping] { | |
| Ok(()) | |
| } else { | |
| Err(Error::invalid_protocol( | |
| "Reader features should be present in writer features", | |
| )) | |
| } | |
| (Some(reader_features), None) => { | |
| Err(Error::invalid_protocol( | |
| "Reader features should be present in writer features", | |
| )) |
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.
There were existing test cases where we allowed reader feature (ColumnMapping) without writer feature because of #1124.
delta-kernel-rs/kernel/tests/write.rs
Lines 905 to 917 in 82fa82e
| // TODO: (#1124) we don't actually support column mapping writes yet, but have some | |
| // tests that do column mapping on writes. For now omit the writer feature to let tests | |
| // run, but after actual support this should be enabled. | |
| let table_url = create_table( | |
| store.clone(), | |
| table_location, | |
| table_schema.clone(), | |
| &[], | |
| true, | |
| vec!["variantType", "variantShredding-preview", "columnMapping"], | |
| vec!["variantType", "variantShredding-preview"], | |
| ) | |
| .await?; |
Also, previous feature check logic for ColumnMapping relied on reader feature instead of writer feature.
delta-kernel-rs/kernel/src/table_features/column_mapping.rs
Lines 37 to 42 in 82fa82e
| // NOTE: The table property is optional even when the feature is supported, and is allowed | |
| // (but should be ignored) even when the feature is not supported. For details see | |
| // https://github.com/delta-io/delta/blob/master/PROTOCOL.md#column-mapping | |
| (Some(mode), 2) => mode, | |
| (Some(mode), 3) if protocol.has_reader_feature(&ReaderFeature::ColumnMapping) => mode, | |
| _ => ColumnMappingMode::None, |
Should we update this logic and remove the exception for ColumnMapping as well?
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.
@zachschuermann what's the context of #1124? I don't know of any reason for there to be a reader feature present but not the equivalent writer feature.
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.
there isn't. it's an old bug that we temporarily benefitted from since it let us do column mapping read tests without actually having write support. the ideal path forward here IMO is we change to (1) "support" column mapping as a table feature (RW) but then (2) if users attempt writes to a column mapped table we block it in ensure_write_supported
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.
Thank you for clarification. I'll make the changes.
|
@ding-young Did you get a chance to look at this PR again? |
@DrakeLin I was waiting for answer to #1345 (comment) before proceeding. I would appreciate it if you could provide clarification, as it will determine how I should update the code logic and the existing unit tests. |
|
@ding-young Sounds great, I think zach answered your question. Otherwise, once we address Oussama's comments, I think the PR looks good to me :D |
| Some(vec![TableFeature::VariantType]), | ||
| Some(vec![ | ||
| TableFeature::VariantType, | ||
| TableFeature::DeletionVectors, | ||
| ]), | ||
| "Writer features must be Writer-only or also listed in reader features", |
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.
Answer to https://github.com/delta-io/delta-kernel-rs/pull/1345/files#r2400410008
I added that logic to catch cases where an RW feature is listed in the writer features but not in the reader features. Without this, the corresponding test case would fail. Do you mean we don't need to handle this case as well?
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.
Yeah, since we are consolidating features into TableFeatures, there can only be 3 case for RW features:
- Exists in Reader + Writer features
- Existing in Writer Features only
- Neither
For WriterOnly features:
- Exists in Writer Features only
- Neither
I think the idea in this test case is for TableFeatures that are WriterFeatures, they shouldn't exist in the ReaderFeatures?
| #[ignore] | ||
| #[tokio::test] | ||
| async fn test_append_variant() -> Result<(), Box<dyn std::error::Error>> { |
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.
Now, if we include column mapping write in the writer features, it triggers an unsupported writer feature error, so this test doesn’t pass. I considered a few ways to bypass it, but for now, I just ignored the test. I’d be glad to hear any other suggestions.
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.
Let's add to writer features then block it when we start a transaction
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.
or - do we even need column mapping here? can we just remove it?
What changes are proposed in this pull request?
closes #1340
As suggested in above issue, this pr
Protocol::try_newReaderFeatureWriterFeatureinto singleTableFeatureso that we can check only writer feature like
Note that there are three feature types, and the
Unknownvariant is for handlingTableFeature::Unknownwhich is eitherWriterorReaderWriterbased on its actual usage.How was this change tested?
Yes, added new test