()
| 372 | |
| 373 | #[test] |
| 374 | fn test_avro_with_projection() { |
| 375 | // Test projection to filter and reorder columns |
| 376 | let projection = vec![9, 7, 1]; // string_col, double_col, bool_col |
| 377 | |
| 378 | let mut reader = build_reader("alltypes_dictionary.avro", Some(projection)); |
| 379 | let batch = reader.next().unwrap().unwrap(); |
| 380 | |
| 381 | // Only 3 columns should be present (not all 11) |
| 382 | assert_eq!(3, batch.num_columns()); |
| 383 | assert_eq!(2, batch.num_rows()); |
| 384 | |
| 385 | let schema = reader.schema(); |
| 386 | let batch_schema = batch.schema(); |
| 387 | assert_eq!(schema, batch_schema); |
| 388 | |
| 389 | // Verify columns are in the order specified in projection |
| 390 | // First column should be string_col (was at index 9 in original) |
| 391 | assert_eq!("string_col", schema.field(0).name()); |
| 392 | assert_eq!(&DataType::Binary, schema.field(0).data_type()); |
| 393 | let col = batch |
| 394 | .column(0) |
| 395 | .as_any() |
| 396 | .downcast_ref::<BinaryArray>() |
| 397 | .unwrap(); |
| 398 | assert_eq!("0".as_bytes(), col.value(0)); |
| 399 | assert_eq!("1".as_bytes(), col.value(1)); |
| 400 | |
| 401 | // Second column should be double_col (was at index 7 in original) |
| 402 | assert_eq!("double_col", schema.field(1).name()); |
| 403 | assert_eq!(&DataType::Float64, schema.field(1).data_type()); |
| 404 | let col = batch |
| 405 | .column(1) |
| 406 | .as_any() |
| 407 | .downcast_ref::<Float64Array>() |
| 408 | .unwrap(); |
| 409 | assert_eq!(0.0, col.value(0)); |
| 410 | assert_eq!(10.1, col.value(1)); |
| 411 | |
| 412 | // Third column should be bool_col (was at index 1 in original) |
| 413 | assert_eq!("bool_col", schema.field(2).name()); |
| 414 | assert_eq!(&DataType::Boolean, schema.field(2).data_type()); |
| 415 | let col = batch |
| 416 | .column(2) |
| 417 | .as_any() |
| 418 | .downcast_ref::<BooleanArray>() |
| 419 | .unwrap(); |
| 420 | assert!(col.value(0)); |
| 421 | assert!(!col.value(1)); |
| 422 | } |
| 423 | |
| 424 | #[test] |
| 425 | fn test_avro_timestamp_logical_types() { |
nothing calls this directly
no test coverage detected
searching dependent graphs…