Skip to content

Commit ce4edd5

Browse files
authored
Some panic!s could more semantically be unimplemented! (#8933)
# Which issue does this PR close? We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. - Closes #8932 . # Rationale for this change Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. Some `panic!` conversions There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. # Are these changes tested? We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code Not sure these panic test cases are covered # Are there any user-facing changes? N/A
1 parent cd60536 commit ce4edd5

File tree

2 files changed

+8
-6
lines changed

2 files changed

+8
-6
lines changed

arrow-array/src/array/mod.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -824,20 +824,20 @@ pub fn make_array(data: ArrayData) -> ArrayRef {
824824
DataType::UInt16 => Arc::new(DictionaryArray::<UInt16Type>::from(data)) as ArrayRef,
825825
DataType::UInt32 => Arc::new(DictionaryArray::<UInt32Type>::from(data)) as ArrayRef,
826826
DataType::UInt64 => Arc::new(DictionaryArray::<UInt64Type>::from(data)) as ArrayRef,
827-
dt => panic!("Unexpected dictionary key type {dt}"),
827+
dt => unimplemented!("Unexpected dictionary key type {dt}"),
828828
},
829829
DataType::RunEndEncoded(run_ends_type, _) => match run_ends_type.data_type() {
830830
DataType::Int16 => Arc::new(RunArray::<Int16Type>::from(data)) as ArrayRef,
831831
DataType::Int32 => Arc::new(RunArray::<Int32Type>::from(data)) as ArrayRef,
832832
DataType::Int64 => Arc::new(RunArray::<Int64Type>::from(data)) as ArrayRef,
833-
dt => panic!("Unexpected data type for run_ends array {dt}"),
833+
dt => unimplemented!("Unexpected data type for run_ends array {dt}"),
834834
},
835835
DataType::Null => Arc::new(NullArray::from(data)) as ArrayRef,
836836
DataType::Decimal32(_, _) => Arc::new(Decimal32Array::from(data)) as ArrayRef,
837837
DataType::Decimal64(_, _) => Arc::new(Decimal64Array::from(data)) as ArrayRef,
838838
DataType::Decimal128(_, _) => Arc::new(Decimal128Array::from(data)) as ArrayRef,
839839
DataType::Decimal256(_, _) => Arc::new(Decimal256Array::from(data)) as ArrayRef,
840-
dt => panic!("Unexpected data type {dt}"),
840+
dt => unimplemented!("Unexpected data type {dt}"),
841841
}
842842
}
843843

arrow-array/src/builder/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ pub fn make_builder(datatype: &DataType, capacity: usize) -> Box<dyn ArrayBuilde
594594
LargeBinaryDictionaryBuilder::with_capacity(capacity, 256, 1024);
595595
Box::new(dict_builder)
596596
}
597-
t => panic!("Dictionary value type {t} is not currently supported"),
597+
t => unimplemented!("Dictionary value type {t} is not currently supported"),
598598
}
599599
};
600600
}
@@ -604,10 +604,12 @@ pub fn make_builder(datatype: &DataType, capacity: usize) -> Box<dyn ArrayBuilde
604604
DataType::Int32 => dict_builder!(Int32Type),
605605
DataType::Int64 => dict_builder!(Int64Type),
606606
_ => {
607-
panic!("Data type {t} with key type {key_type} is not currently supported")
607+
unimplemented!(
608+
"Data type {t} with key type {key_type} is not currently supported"
609+
)
608610
}
609611
}
610612
}
611-
t => panic!("Data type {t} is not currently supported"),
613+
t => unimplemented!("Data type {t} is not currently supported"),
612614
}
613615
}

0 commit comments

Comments
 (0)