| 929 | } |
| 930 | |
| 931 | fn _dictionary<K: ArrowDictionaryKeyType>() { |
| 932 | const TOTAL: i32 = 100; |
| 933 | |
| 934 | let v = ["aaa", "bbb", "ccc", "ddd", "eee"]; |
| 935 | let data: Vec<Option<&str>> = (0..TOTAL) |
| 936 | .map(|n| { |
| 937 | let i = n % 5; |
| 938 | if i == 3 { None } else { Some(v[i as usize]) } |
| 939 | }) |
| 940 | .collect(); |
| 941 | |
| 942 | let dict_array: DictionaryArray<K> = data.clone().into_iter().collect(); |
| 943 | |
| 944 | let expected: Vec<Option<&str>> = data.iter().map(|opt| opt.map(|s| &s[1..3])).collect(); |
| 945 | |
| 946 | let res = substring(&dict_array, 1, Some(2)).unwrap(); |
| 947 | let actual = res.as_any().downcast_ref::<DictionaryArray<K>>().unwrap(); |
| 948 | let actual: Vec<Option<&str>> = actual |
| 949 | .values() |
| 950 | .as_any() |
| 951 | .downcast_ref::<GenericStringArray<i32>>() |
| 952 | .unwrap() |
| 953 | .take_iter(actual.keys_iter()) |
| 954 | .collect(); |
| 955 | |
| 956 | for i in 0..TOTAL as usize { |
| 957 | assert_eq!(expected[i], actual[i],); |
| 958 | } |
| 959 | } |
| 960 | |
| 961 | #[test] |
| 962 | fn check_invalid_array_type() { |