Skip to content

Commit b5671bb

Browse files
committed
test unsupported case
1 parent a9b5b67 commit b5671bb

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
@@ -121,7 +121,8 @@ fn concat_dictionaries<K: ArrowDictionaryKeyType>(
121121
// to concatenating values
122122
_ if !is_overflow => concat_fallback(arrays, Capacities::Array(output_len)),
123123
other => Err(ArrowError::NotYetImplemented(format!(
124-
"concat of dictionaries would overflow key type {key_type:?} with value type {other:?}",
124+
"concat of dictionaries would overflow key type {key_type:?} and \
125+
value type {other:?} not yet supported for merging",
125126
key_type = K::DATA_TYPE,
126127
)))
127128
}
@@ -1021,6 +1022,33 @@ mod tests {
10211022
);
10221023
}
10231024

1025+
#[test]
1026+
fn test_unsupported_concat_dictionary_overflow() {
1027+
// each array has length equal to the full dictionary key space
1028+
let len: usize = usize::try_from(i8::MAX).unwrap();
1029+
1030+
let a = DictionaryArray::<Int8Type>::new(
1031+
Int8Array::from_value(0, len),
1032+
Arc::new(NullArray::new(len)),
1033+
);
1034+
let b = DictionaryArray::<Int8Type>::new(
1035+
Int8Array::from_value(0, len),
1036+
Arc::new(NullArray::new(len)),
1037+
);
1038+
1039+
// Case 1: with a single input array, should _never_ overflow
1040+
concat(&[&a]).unwrap();
1041+
1042+
// Case 2: two arrays
1043+
// Will fail to merge values on unsupported datatype
1044+
let values = concat(&[&a, &b]).unwrap_err();
1045+
assert_eq!(
1046+
values.to_string(),
1047+
"Not yet implemented: concat of dictionaries would overflow key type Int8 and \
1048+
value type Null not yet supported for merging"
1049+
);
1050+
}
1051+
10241052
#[test]
10251053
fn test_concat_string_sizes() {
10261054
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)