Skip to content

Commit cc86087

Browse files
committed
add tests for not printing all the data types
1 parent 95e4553 commit cc86087

File tree

1 file changed

+73
-0
lines changed

1 file changed

+73
-0
lines changed

arrow-select/src/concat.rs

+73
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,79 @@ mod tests {
376376
assert_eq!(re.unwrap_err().to_string(), "Invalid argument error: It is not possible to concatenate arrays of different data types (Int64, Utf8, Int32).");
377377
}
378378

379+
#[test]
380+
fn test_concat_10_incompatible_datatypes_should_include_all_of_them() {
381+
let re = concat(&[
382+
&PrimitiveArray::<Int64Type>::from(vec![Some(-1), Some(2), None]),
383+
// 2 string to make sure we only mention unique types
384+
&StringArray::from(vec![Some("hello"), Some("bar"), Some("world")]),
385+
&StringArray::from(vec![Some("hey"), Some(""), Some("you")]),
386+
// Another type to make sure we are showing all the incompatible types
387+
&PrimitiveArray::<Int32Type>::from(vec![Some(-1), Some(2), None]),
388+
&PrimitiveArray::<Int8Type>::from(vec![Some(-1), Some(2), None]),
389+
&PrimitiveArray::<Int16Type>::from(vec![Some(-1), Some(2), None]),
390+
&PrimitiveArray::<UInt8Type>::from(vec![Some(1), Some(2), None]),
391+
&PrimitiveArray::<UInt16Type>::from(vec![Some(1), Some(2), None]),
392+
&PrimitiveArray::<UInt32Type>::from(vec![Some(1), Some(2), None]),
393+
// Non unique
394+
&PrimitiveArray::<UInt16Type>::from(vec![Some(1), Some(2), None]),
395+
&PrimitiveArray::<UInt64Type>::from(vec![Some(1), Some(2), None]),
396+
&PrimitiveArray::<Float32Type>::from(vec![Some(1.0), Some(2.0), None]),
397+
]);
398+
399+
assert_eq!(re.unwrap_err().to_string(), "Invalid argument error: It is not possible to concatenate arrays of different data types (Int64, Utf8, Int32, Int8, Int16, UInt8, UInt16, UInt32, UInt64, Float32).");
400+
}
401+
402+
#[test]
403+
fn test_concat_11_incompatible_datatypes_should_only_include_10() {
404+
let re = concat(&[
405+
&PrimitiveArray::<Int64Type>::from(vec![Some(-1), Some(2), None]),
406+
// 2 string to make sure we only mention unique types
407+
&StringArray::from(vec![Some("hello"), Some("bar"), Some("world")]),
408+
&StringArray::from(vec![Some("hey"), Some(""), Some("you")]),
409+
// Another type to make sure we are showing all the incompatible types
410+
&PrimitiveArray::<Int32Type>::from(vec![Some(-1), Some(2), None]),
411+
&PrimitiveArray::<Int8Type>::from(vec![Some(-1), Some(2), None]),
412+
&PrimitiveArray::<Int16Type>::from(vec![Some(-1), Some(2), None]),
413+
&PrimitiveArray::<UInt8Type>::from(vec![Some(1), Some(2), None]),
414+
&PrimitiveArray::<UInt16Type>::from(vec![Some(1), Some(2), None]),
415+
&PrimitiveArray::<UInt32Type>::from(vec![Some(1), Some(2), None]),
416+
// Non unique
417+
&PrimitiveArray::<UInt16Type>::from(vec![Some(1), Some(2), None]),
418+
&PrimitiveArray::<UInt64Type>::from(vec![Some(1), Some(2), None]),
419+
&PrimitiveArray::<Float32Type>::from(vec![Some(1.0), Some(2.0), None]),
420+
&PrimitiveArray::<Float64Type>::from(vec![Some(1.0), Some(2.0), None]),
421+
]);
422+
423+
assert_eq!(re.unwrap_err().to_string(), "Invalid argument error: It is not possible to concatenate arrays of different data types (Int64, Utf8, Int32, Int8, Int16, UInt8, UInt16, UInt32, UInt64, Float32, ...).");
424+
}
425+
426+
#[test]
427+
fn test_concat_13_incompatible_datatypes_should_not_include_all_of_them() {
428+
let re = concat(&[
429+
&PrimitiveArray::<Int64Type>::from(vec![Some(-1), Some(2), None]),
430+
// 2 string to make sure we only mention unique types
431+
&StringArray::from(vec![Some("hello"), Some("bar"), Some("world")]),
432+
&StringArray::from(vec![Some("hey"), Some(""), Some("you")]),
433+
// Another type to make sure we are showing all the incompatible types
434+
&PrimitiveArray::<Int32Type>::from(vec![Some(-1), Some(2), None]),
435+
&PrimitiveArray::<Int8Type>::from(vec![Some(-1), Some(2), None]),
436+
&PrimitiveArray::<Int16Type>::from(vec![Some(-1), Some(2), None]),
437+
&PrimitiveArray::<UInt8Type>::from(vec![Some(1), Some(2), None]),
438+
&PrimitiveArray::<UInt16Type>::from(vec![Some(1), Some(2), None]),
439+
&PrimitiveArray::<UInt32Type>::from(vec![Some(1), Some(2), None]),
440+
// Non unique
441+
&PrimitiveArray::<UInt16Type>::from(vec![Some(1), Some(2), None]),
442+
&PrimitiveArray::<UInt64Type>::from(vec![Some(1), Some(2), None]),
443+
&PrimitiveArray::<Float32Type>::from(vec![Some(1.0), Some(2.0), None]),
444+
&PrimitiveArray::<Float64Type>::from(vec![Some(1.0), Some(2.0), None]),
445+
&PrimitiveArray::<Float16Type>::new_null(3),
446+
&BooleanArray::from(vec![Some(true), Some(false), None]),
447+
]);
448+
449+
assert_eq!(re.unwrap_err().to_string(), "Invalid argument error: It is not possible to concatenate arrays of different data types (Int64, Utf8, Int32, Int8, Int16, UInt8, UInt16, UInt32, UInt64, Float32, ...).");
450+
}
451+
379452
#[test]
380453
fn test_concat_string_arrays() {
381454
let arr = concat(&[

0 commit comments

Comments
 (0)