Skip to content

Commit

Permalink
Add deprecation warnings for everything related to dict_id
Browse files Browse the repository at this point in the history
  • Loading branch information
brancz committed Dec 12, 2024
1 parent 4acf4d3 commit d542433
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
24 changes: 24 additions & 0 deletions arrow-ipc/src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ pub struct IpcWriteOptions {
/// schema or generate unique dictionary IDs internally during encoding.
///
/// Defaults to `false`
#[deprecated(
since = "54.0.0",
note = "The ability to preserve dictionary IDs will be removed. With it, all fields related to it."
)]
preserve_dict_id: bool,
}

Expand Down Expand Up @@ -138,6 +142,10 @@ impl IpcWriteOptions {

/// Return whether the writer is configured to preserve the dictionary IDs
/// defined in the schema
#[deprecated(
since = "54.0.0",
note = "The ability to preserve dictionary IDs will be removed. With it, all functions related to it."
)]
pub fn preserve_dict_id(&self) -> bool {
self.preserve_dict_id
}
Expand All @@ -149,6 +157,10 @@ impl IpcWriteOptions {
/// to the dictionary batches in order to encode them correctly
///
/// The default will change to `false` in future releases
#[deprecated(
since = "54.0.0",
note = "The ability to preserve dictionary IDs will be removed. With it, all functions related to it."
)]
pub fn with_preserve_dict_id(mut self, preserve_dict_id: bool) -> Self {
self.preserve_dict_id = preserve_dict_id;
self
Expand Down Expand Up @@ -767,6 +779,10 @@ pub struct DictionaryTracker {
written: HashMap<i64, ArrayData>,
dict_ids: Vec<i64>,
error_on_replacement: bool,
#[deprecated(
since = "54.0.0",
note = "The ability to preserve dictionary IDs will be removed. With it, all fields related to it."
)]
preserve_dict_id: bool,
}

Expand Down Expand Up @@ -795,6 +811,10 @@ impl DictionaryTracker {
/// If `error_on_replacement`
/// is true, an error will be generated if an update to an
/// existing dictionary is attempted.
#[deprecated(
since = "54.0.0",
note = "The ability to preserve dictionary IDs will be removed. With it, all functions related to it."
)]
pub fn new_with_preserve_dict_id(error_on_replacement: bool, preserve_dict_id: bool) -> Self {
Self {
written: HashMap::new(),
Expand All @@ -811,6 +831,10 @@ impl DictionaryTracker {
///
/// If `preserve_dict_id` is false, this will return the value of the last `dict_id` assigned incremented by 1
/// or 0 in the case where no dictionary IDs have yet been assigned
#[deprecated(
since = "54.0.0",
note = "The ability to preserve dictionary IDs will be removed. With it, all functions related to it."
)]
pub fn set_dict_id(&mut self, field: &Field) -> i64 {
let next = if self.preserve_dict_id {
field.dict_id().expect("no dict_id in field")
Expand Down
16 changes: 16 additions & 0 deletions arrow-schema/src/field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ pub struct Field {
name: String,
data_type: DataType,
nullable: bool,
#[deprecated(
since = "54.0.0",
note = "The ability to preserve dictionary IDs will be removed. With it, all fields related to it."
)]
dict_id: i64,
dict_is_ordered: bool,
/// A map of key-value pairs containing additional custom meta data.
Expand Down Expand Up @@ -151,6 +155,10 @@ impl Field {
}

/// Creates a new field that has additional dictionary information
#[deprecated(
since = "54.0.0",
note = "The ability to preserve dictionary IDs will be removed. With the dict_id field disappearing this function signature will change by removing the dict_id parameter."
)]
pub fn new_dict(
name: impl Into<String>,
data_type: DataType,
Expand Down Expand Up @@ -386,6 +394,10 @@ impl Field {
/// Returns a vector containing all (potentially nested) `Field` instances selected by the
/// dictionary ID they use
#[inline]
#[deprecated(
since = "54.0.0",
note = "The ability to preserve dictionary IDs will be removed. With it, all fields related to it."
)]
pub(crate) fn fields_with_dict_id(&self, id: i64) -> Vec<&Field> {
self.fields()
.into_iter()
Expand All @@ -397,6 +409,10 @@ impl Field {

/// Returns the dictionary ID, if this is a dictionary type.
#[inline]
#[deprecated(
since = "54.0.0",
note = "The ability to preserve dictionary IDs will be removed. With it, all fields related to it."
)]
pub const fn dict_id(&self) -> Option<i64> {
match self.data_type {
DataType::Dictionary(_, _) => Some(self.dict_id),
Expand Down

0 comments on commit d542433

Please sign in to comment.