Skip to content

Commit 008c4ec

Browse files
davidhewittfriendlymatthew
authored andcommitted
test unsupported case
1 parent 6e1ceb8 commit 008c4ec

File tree

2 files changed

+58
-2
lines changed

2 files changed

+58
-2
lines changed

arrow-select/src/concat.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ fn concat_dictionaries<K: ArrowDictionaryKeyType>(
122122
// to concatenating values
123123
_ if !is_overflow => concat_fallback(arrays, Capacities::Array(output_len)),
124124
other => Err(ArrowError::NotYetImplemented(format!(
125-
"concat of dictionaries would overflow key type {key_type:?} with value type {other:?}",
125+
"concat of dictionaries would overflow key type {key_type:?} and \
126+
value type {other:?} not yet supported for merging",
126127
key_type = K::DATA_TYPE,
127128
)))
128129
}
@@ -1093,6 +1094,33 @@ mod tests {
10931094
);
10941095
}
10951096

1097+
#[test]
1098+
fn test_unsupported_concat_dictionary_overflow() {
1099+
// each array has length equal to the full dictionary key space
1100+
let len: usize = usize::try_from(i8::MAX).unwrap();
1101+
1102+
let a = DictionaryArray::<Int8Type>::new(
1103+
Int8Array::from_value(0, len),
1104+
Arc::new(NullArray::new(len)),
1105+
);
1106+
let b = DictionaryArray::<Int8Type>::new(
1107+
Int8Array::from_value(0, len),
1108+
Arc::new(NullArray::new(len)),
1109+
);
1110+
1111+
// Case 1: with a single input array, should _never_ overflow
1112+
concat(&[&a]).unwrap();
1113+
1114+
// Case 2: two arrays
1115+
// Will fail to merge values on unsupported datatype
1116+
let values = concat(&[&a, &b]).unwrap_err();
1117+
assert_eq!(
1118+
values.to_string(),
1119+
"Not yet implemented: concat of dictionaries would overflow key type Int8 and \
1120+
value type Null not yet supported for merging"
1121+
);
1122+
}
1123+
10961124
#[test]
10971125
fn test_concat_string_sizes() {
10981126
let a: LargeStringArray = ((0..150).map(|_| Some("foo"))).collect();

arrow-select/src/interleave.rs

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,8 @@ fn interleave_dictionaries<K: ArrowDictionaryKeyType>(
223223
// to concatenating values
224224
_ if !is_overflow => interleave_fallback(arrays, indices),
225225
other => Err(ArrowError::NotYetImplemented(format!(
226-
"interleave of dictionaries would overflow key type {key_type:?} with value type {other:?}",
226+
"interleave of dictionaries would overflow key type {key_type:?} and \
227+
value type {other:?} not yet supported for merging",
227228
key_type = K::DATA_TYPE,
228229
)))
229230
}
@@ -547,6 +548,33 @@ mod tests {
547548
assert_eq!(&collected, &[0, 0, 1]);
548549
}
549550

551+
#[test]
552+
fn test_unsupported_interleave_dictionary_overflow() {
553+
// each array has length equal to the full dictionary key space
554+
let len: usize = usize::try_from(i8::MAX).unwrap();
555+
556+
let a = DictionaryArray::<Int8Type>::new(
557+
Int8Array::from_value(0, len),
558+
Arc::new(NullArray::new(len)),
559+
);
560+
let b = DictionaryArray::<Int8Type>::new(
561+
Int8Array::from_value(0, len),
562+
Arc::new(NullArray::new(len)),
563+
);
564+
565+
// Case 1: with a single input array, should _never_ overflow
566+
interleave(&[&a], &[(0, 2), (0, 2)]).unwrap();
567+
568+
// Case 2: two arrays
569+
// Will fail to merge values on unsupported datatype
570+
let values = interleave(&[&a, &b], &[(0, 2), (0, 2), (1, 1)]).unwrap_err();
571+
assert_eq!(
572+
values.to_string(),
573+
"Not yet implemented: qinterleave of dictionaries would overflow key type Int8 and \
574+
value type Null not yet supported for merging"
575+
);
576+
}
577+
550578
#[test]
551579
fn test_lists() {
552580
// [[1, 2], null, [3]]

0 commit comments

Comments
 (0)