Skip to content

Commit

Permalink
Allow deprecated methods for dict_id
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb committed Dec 16, 2024
1 parent d51ba47 commit 51fdc1e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
16 changes: 4 additions & 12 deletions datafusion/physical-plan/src/aggregates/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2436,25 +2436,21 @@ mod tests {
"labels".to_string(),
DataType::Struct(
vec![
Field::new_dict(
Field::new(
"a".to_string(),
DataType::Dictionary(
Box::new(DataType::Int32),
Box::new(DataType::Utf8),
),
true,
0,
false,
),
Field::new_dict(
Field::new(
"b".to_string(),
DataType::Dictionary(
Box::new(DataType::Int32),
Box::new(DataType::Utf8),
),
true,
0,
false,
),
]
.into(),
Expand All @@ -2466,15 +2462,13 @@ mod tests {
vec![
Arc::new(StructArray::from(vec![
(
Arc::new(Field::new_dict(
Arc::new(Field::new(
"a".to_string(),
DataType::Dictionary(
Box::new(DataType::Int32),
Box::new(DataType::Utf8),
),
true,
0,
false,
)),
Arc::new(
vec![Some("a"), None, Some("a")]
Expand All @@ -2483,15 +2477,13 @@ mod tests {
) as ArrayRef,
),
(
Arc::new(Field::new_dict(
Arc::new(Field::new(
"b".to_string(),
DataType::Dictionary(
Box::new(DataType::Int32),
Box::new(DataType::Utf8),
),
true,
0,
false,
)),
Arc::new(
vec![Some("b"), Some("c"), Some("b")]
Expand Down
4 changes: 4 additions & 0 deletions datafusion/proto-common/src/from_proto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,8 @@ impl TryFrom<&protobuf::Field> for Field {
fn try_from(field: &protobuf::Field) -> Result<Self, Self::Error> {
let datatype = field.arrow_type.as_deref().required("arrow_type")?;
let field = if field.dict_id != 0 {
// TODO file a ticket about handling deprecated dict_id attributes
#[allow(deprecated)]
Self::new_dict(
field.name.as_str(),
datatype,
Expand Down Expand Up @@ -365,6 +367,8 @@ impl TryFrom<&protobuf::ScalarValue> for ScalarValue {
.as_ref()
.ok_or_else(|| Error::required("value"))?;

// TODO file a ticket about handling deprecated dict_id attributes
#[allow(deprecated)]
Ok(match value {
Value::BoolValue(v) => Self::Boolean(Some(*v)),
Value::Utf8Value(v) => Self::Utf8(Some(v.to_owned())),
Expand Down
2 changes: 2 additions & 0 deletions datafusion/proto-common/src/to_proto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ impl TryFrom<&Field> for protobuf::Field {
nullable: field.is_nullable(),
children: Vec::new(),
metadata: field.metadata().clone(),
// TODO file a ticket about handling deprecated dict_id attributes
#[allow(deprecated)]
dict_id: field.dict_id().unwrap_or(0),
dict_ordered: field.dict_is_ordered().unwrap_or(false),
})
Expand Down
2 changes: 2 additions & 0 deletions datafusion/proto/tests/cases/roundtrip_logical_plan.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1777,6 +1777,8 @@ fn round_trip_datatype() {
}
}

// TODO file a ticket about handling deprecated dict_id attributes
#[allow(deprecated)]
#[test]
fn roundtrip_dict_id() -> Result<()> {
let dict_id = 42;
Expand Down

0 comments on commit 51fdc1e

Please sign in to comment.