Skip to content

Commit

Permalink
feat: Add check for whether appendOnly table feature is supported or …
Browse files Browse the repository at this point in the history
…enabled (#664)

## What changes are proposed in this pull request?
This PR adds two functions to TableConfiguration: 
1) check whether appendOnly table feature is supported
2) check whether appendOnly table feature is enabled

It also enabled writes on tables with `AppendOnly` writer feature.

## How was this change tested?
I check that write is supported on Protocol with
`WriterFeatures::AppendOnly`.

---------

Co-authored-by: Zach Schuermann <zachary.zvs@gmail.com>
  • Loading branch information
OussamaSaoudi and zachschuermann authored Mar 11, 2025
1 parent b663850 commit bdbb2f7
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 8 deletions.
13 changes: 7 additions & 6 deletions kernel/src/actions/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -888,12 +888,13 @@ mod tests {

#[test]
fn test_ensure_write_supported() {
let protocol = Protocol {
min_reader_version: 3,
min_writer_version: 7,
reader_features: Some(vec![]),
writer_features: Some(vec![]),
};
let protocol = Protocol::try_new(
3,
7,
Some::<Vec<String>>(vec![]),
Some(vec![WriterFeatures::AppendOnly]),
)
.unwrap();
assert!(protocol.ensure_write_supported().is_ok());

let protocol = Protocol::try_new(
Expand Down
17 changes: 17 additions & 0 deletions kernel/src/table_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,23 @@ impl TableConfiguration {
.enable_deletion_vectors
.unwrap_or(false)
}

/// Returns `true` if the table supports the appendOnly table feature. To support this feature:
/// - The table must have a writer version between 2 and 7 (inclusive)
/// - If the table is on writer version 7, it must have the [`WriterFeatures::AppendOnly`]
/// writer feature.
pub(crate) fn is_append_only_supported(&self) -> bool {
let protocol = &self.protocol;
match protocol.min_writer_version() {
7 if protocol.has_writer_feature(&WriterFeatures::AppendOnly) => true,
version => (2..=6).contains(&version),
}
}

#[allow(unused)]
pub(crate) fn is_append_only_enabled(&self) -> bool {
self.is_append_only_supported() && self.table_properties.append_only.unwrap_or(false)
}
}

#[cfg(test)]
Expand Down
4 changes: 2 additions & 2 deletions kernel/src/table_features/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,9 @@ pub(crate) static SUPPORTED_READER_FEATURES: LazyLock<HashSet<ReaderFeatures>> =
])
});

// write support wip: no table features are supported yet
// currently the only writer feature supported is `AppendOnly`
pub(crate) static SUPPORTED_WRITER_FEATURES: LazyLock<HashSet<WriterFeatures>> =
LazyLock::new(|| HashSet::from([]));
LazyLock::new(|| HashSet::from([WriterFeatures::AppendOnly]));

#[cfg(test)]
mod tests {
Expand Down

0 comments on commit bdbb2f7

Please sign in to comment.