| 1220 | |
| 1221 | #[test] |
| 1222 | fn test_dense_mixed_with_nulls() { |
| 1223 | let mut builder = UnionBuilder::new_dense(); |
| 1224 | builder.append::<Int32Type>("a", 1).unwrap(); |
| 1225 | builder.append::<Int64Type>("c", 3).unwrap(); |
| 1226 | builder.append::<Int32Type>("a", 10).unwrap(); |
| 1227 | builder.append_null::<Int32Type>("a").unwrap(); |
| 1228 | builder.append::<Int32Type>("a", 6).unwrap(); |
| 1229 | let union = builder.build().unwrap(); |
| 1230 | |
| 1231 | assert_eq!(5, union.len()); |
| 1232 | for i in 0..union.len() { |
| 1233 | let slot = union.value(i); |
| 1234 | match i { |
| 1235 | 0 => { |
| 1236 | let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap(); |
| 1237 | assert!(!slot.is_null(0)); |
| 1238 | assert_eq!(slot.len(), 1); |
| 1239 | let value = slot.value(0); |
| 1240 | assert_eq!(1_i32, value); |
| 1241 | } |
| 1242 | 1 => { |
| 1243 | let slot = slot.as_any().downcast_ref::<Int64Array>().unwrap(); |
| 1244 | assert!(!slot.is_null(0)); |
| 1245 | assert_eq!(slot.len(), 1); |
| 1246 | let value = slot.value(0); |
| 1247 | assert_eq!(3_i64, value); |
| 1248 | } |
| 1249 | 2 => { |
| 1250 | let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap(); |
| 1251 | assert!(!slot.is_null(0)); |
| 1252 | assert_eq!(slot.len(), 1); |
| 1253 | let value = slot.value(0); |
| 1254 | assert_eq!(10_i32, value); |
| 1255 | } |
| 1256 | 3 => assert!(slot.is_null(0)), |
| 1257 | 4 => { |
| 1258 | let slot = slot.as_any().downcast_ref::<Int32Array>().unwrap(); |
| 1259 | assert!(!slot.is_null(0)); |
| 1260 | assert_eq!(slot.len(), 1); |
| 1261 | let value = slot.value(0); |
| 1262 | assert_eq!(6_i32, value); |
| 1263 | } |
| 1264 | _ => unreachable!(), |
| 1265 | } |
| 1266 | } |
| 1267 | } |
| 1268 | |
| 1269 | #[test] |
| 1270 | fn test_dense_mixed_with_nulls_and_offset() { |