()
| 283 | |
| 284 | #[test] |
| 285 | fn test_avro_basic() { |
| 286 | let mut reader = build_reader("alltypes_dictionary.avro", None); |
| 287 | let batch = reader.next().unwrap().unwrap(); |
| 288 | |
| 289 | assert_eq!(11, batch.num_columns()); |
| 290 | assert_eq!(2, batch.num_rows()); |
| 291 | |
| 292 | let schema = reader.schema(); |
| 293 | let batch_schema = batch.schema(); |
| 294 | assert_eq!(schema, batch_schema); |
| 295 | |
| 296 | let id = schema.column_with_name("id").unwrap(); |
| 297 | assert_eq!(0, id.0); |
| 298 | assert_eq!(&DataType::Int32, id.1.data_type()); |
| 299 | let col = get_col::<Int32Array>(&batch, id).unwrap(); |
| 300 | assert_eq!(0, col.value(0)); |
| 301 | assert_eq!(1, col.value(1)); |
| 302 | let bool_col = schema.column_with_name("bool_col").unwrap(); |
| 303 | assert_eq!(1, bool_col.0); |
| 304 | assert_eq!(&DataType::Boolean, bool_col.1.data_type()); |
| 305 | let col = get_col::<BooleanArray>(&batch, bool_col).unwrap(); |
| 306 | assert!(col.value(0)); |
| 307 | assert!(!col.value(1)); |
| 308 | let tinyint_col = schema.column_with_name("tinyint_col").unwrap(); |
| 309 | assert_eq!(2, tinyint_col.0); |
| 310 | assert_eq!(&DataType::Int32, tinyint_col.1.data_type()); |
| 311 | let col = get_col::<Int32Array>(&batch, tinyint_col).unwrap(); |
| 312 | assert_eq!(0, col.value(0)); |
| 313 | assert_eq!(1, col.value(1)); |
| 314 | let smallint_col = schema.column_with_name("smallint_col").unwrap(); |
| 315 | assert_eq!(3, smallint_col.0); |
| 316 | assert_eq!(&DataType::Int32, smallint_col.1.data_type()); |
| 317 | let col = get_col::<Int32Array>(&batch, smallint_col).unwrap(); |
| 318 | assert_eq!(0, col.value(0)); |
| 319 | assert_eq!(1, col.value(1)); |
| 320 | let int_col = schema.column_with_name("int_col").unwrap(); |
| 321 | assert_eq!(4, int_col.0); |
| 322 | let col = get_col::<Int32Array>(&batch, int_col).unwrap(); |
| 323 | assert_eq!(0, col.value(0)); |
| 324 | assert_eq!(1, col.value(1)); |
| 325 | assert_eq!(&DataType::Int32, int_col.1.data_type()); |
| 326 | let col = get_col::<Int32Array>(&batch, int_col).unwrap(); |
| 327 | assert_eq!(0, col.value(0)); |
| 328 | assert_eq!(1, col.value(1)); |
| 329 | let bigint_col = schema.column_with_name("bigint_col").unwrap(); |
| 330 | assert_eq!(5, bigint_col.0); |
| 331 | let col = get_col::<Int64Array>(&batch, bigint_col).unwrap(); |
| 332 | assert_eq!(0, col.value(0)); |
| 333 | assert_eq!(10, col.value(1)); |
| 334 | assert_eq!(&DataType::Int64, bigint_col.1.data_type()); |
| 335 | let float_col = schema.column_with_name("float_col").unwrap(); |
| 336 | assert_eq!(6, float_col.0); |
| 337 | let col = get_col::<Float32Array>(&batch, float_col).unwrap(); |
| 338 | assert_eq!(0.0, col.value(0)); |
| 339 | assert_eq!(1.1, col.value(1)); |
| 340 | assert_eq!(&DataType::Float32, float_col.1.data_type()); |
| 341 | let col = get_col::<Float32Array>(&batch, float_col).unwrap(); |
| 342 | assert_eq!(0.0, col.value(0)); |
nothing calls this directly
no test coverage detected
searching dependent graphs…