()
| 10490 | |
| 10491 | #[test] |
| 10492 | fn test_eq_array_run_end_encoded() { |
| 10493 | let run_ends = Int16Array::from(vec![1, 3]); |
| 10494 | let values = Float32Array::from(vec![None, Some(1.0)]); |
| 10495 | let run_array = |
| 10496 | Arc::new(RunArray::try_new(&run_ends, &values).unwrap()) as ArrayRef; |
| 10497 | |
| 10498 | let scalar = ScalarValue::RunEndEncoded( |
| 10499 | Field::new("run_ends", DataType::Int16, false).into(), |
| 10500 | Field::new("values", DataType::Float32, true).into(), |
| 10501 | Box::new(ScalarValue::Float32(None)), |
| 10502 | ); |
| 10503 | assert!(scalar.eq_array(&run_array, 0).unwrap()); |
| 10504 | |
| 10505 | let scalar = ScalarValue::RunEndEncoded( |
| 10506 | Field::new("run_ends", DataType::Int16, false).into(), |
| 10507 | Field::new("values", DataType::Float32, true).into(), |
| 10508 | Box::new(ScalarValue::Float32(Some(1.0))), |
| 10509 | ); |
| 10510 | assert!(scalar.eq_array(&run_array, 1).unwrap()); |
| 10511 | assert!(scalar.eq_array(&run_array, 2).unwrap()); |
| 10512 | |
| 10513 | // value types must match |
| 10514 | let scalar = ScalarValue::RunEndEncoded( |
| 10515 | Field::new("run_ends", DataType::Int16, false).into(), |
| 10516 | Field::new("values", DataType::Float64, true).into(), |
| 10517 | Box::new(ScalarValue::Float64(Some(1.0))), |
| 10518 | ); |
| 10519 | let err = scalar.eq_array(&run_array, 1).unwrap_err(); |
| 10520 | let expected = "Internal error: could not cast array of type Float32 to arrow_array::array::primitive_array::PrimitiveArray<arrow_array::types::Float64Type>"; |
| 10521 | assert!(err.to_string().starts_with(expected)); |
| 10522 | |
| 10523 | // run ends type must match |
| 10524 | let scalar = ScalarValue::RunEndEncoded( |
| 10525 | Field::new("run_ends", DataType::Int32, false).into(), |
| 10526 | Field::new("values", DataType::Float32, true).into(), |
| 10527 | Box::new(ScalarValue::Float32(None)), |
| 10528 | ); |
| 10529 | let err = scalar.eq_array(&run_array, 0).unwrap_err(); |
| 10530 | let expected = "Internal error: could not cast array of type RunEndEncoded(\"run_ends\": non-null Int16, \"values\": Float32) to arrow_array::array::run_array::RunArray<arrow_array::types::Int32Type>"; |
| 10531 | assert!(err.to_string().starts_with(expected)); |
| 10532 | } |
| 10533 | |
| 10534 | #[test] |
| 10535 | fn test_iter_to_array_run_end_encoded() { |
nothing calls this directly
no test coverage detected
searching dependent graphs…