diff --git a/tests/basic/data/nested_array_float.orc b/tests/basic/data/nested_array_float.orc new file mode 100644 index 00000000..341f00b1 Binary files /dev/null and b/tests/basic/data/nested_array_float.orc differ diff --git a/tests/basic/data/nested_array_struct.orc b/tests/basic/data/nested_array_struct.orc new file mode 100644 index 00000000..be822746 Binary files /dev/null and b/tests/basic/data/nested_array_struct.orc differ diff --git a/tests/basic/data/nested_map_struct.orc b/tests/basic/data/nested_map_struct.orc new file mode 100644 index 00000000..4c95e3c7 Binary files /dev/null and b/tests/basic/data/nested_map_struct.orc differ diff --git a/tests/basic/data/write.py b/tests/basic/data/write.py index 7c43c045..1606c99c 100644 --- a/tests/basic/data/write.py +++ b/tests/basic/data/write.py @@ -98,6 +98,7 @@ def _write( _write("struct>", nested_struct, "nested_struct.orc") + nested_array = { "value": [ [1, None, 3, 43, 5], @@ -110,6 +111,25 @@ def _write( _write("struct>", nested_array, "nested_array.orc") + +nested_array_float = { + "value": [ + [1.0, 3.0], + [None, 2.0], + ], +} + +_write("struct>", nested_array_float, "nested_array_float.orc") + +nested_array_struct = { + "value": [ + [(1.0, 1, "01"), (2.0, 2, "02")], + [None, (3.0, 3, "03")], + ], +} + +_write("struct>>", nested_array_struct, "nested_array_struct.orc") + nested_map = { "map": [ {"zero": 0, "one": 1}, @@ -121,6 +141,16 @@ def _write( _write("struct>", nested_map, "nested_map.orc") +nested_map_struct = { + "map": [ + {"01": (1.0, 1, "01"), "02": (2.0, 1, "02")}, + None, + {"03": (3.0, 3, "03"), "04": (4.0, 4, "04")}, + ], +} + +_write("struct>>", nested_map_struct, "nested_map_struct.orc") + _write( infer_schema(data), diff --git a/tests/basic/main.rs b/tests/basic/main.rs index 9a541f7b..e6537400 100644 --- a/tests/basic/main.rs +++ b/tests/basic/main.rs @@ -252,6 +252,58 @@ pub fn basic_test_nested_array() { assert_batches_eq(&batch, &expected); } +#[test] +pub fn basic_test_nested_array_float() { + let path = basic_path("nested_array_float.orc"); + let reader = new_arrow_reader_root(&path); + let batch = reader.collect::, _>>().unwrap(); + + let expected = [ + "+------------+", + "| value |", + "+------------+", + "| [1.0, 3.0] |", + "| [, 2.0] |", + "+------------+", + ]; + assert_batches_eq(&batch, &expected); +} + +#[test] +pub fn basic_test_nested_array_struct() { + let path = basic_path("nested_array_struct.orc"); + let reader = new_arrow_reader_root(&path); + let batch = reader.collect::, _>>().unwrap(); + + let expected = [ + "+------------------------------------------------+", + "| value |", + "+------------------------------------------------+", + "| [{a: 1.0, b: 1, c: 01}, {a: 2.0, b: 2, c: 02}] |", + "| [, {a: 3.0, b: 3, c: 03}] |", + "+------------------------------------------------+", + ]; + assert_batches_eq(&batch, &expected); +} + +#[test] +pub fn basic_test_nested_map_struct() { + let path = basic_path("nested_map_struct.orc"); + let reader = new_arrow_reader_root(&path); + let batch = reader.collect::, _>>().unwrap(); + + let expected = [ + "+--------------------------------------------------------+", + "| value |", + "+--------------------------------------------------------+", + "| {01: {a: 1.0, b: 1, c: 01}, 02: {a: 2.0, b: 1, c: 02}} |", + "| |", + "| {03: {a: 3.0, b: 3, c: 03}, 04: {a: 4.0, b: 4, c: 04}} |", + "+--------------------------------------------------------+", + ]; + assert_batches_eq(&batch, &expected); +} + #[test] pub fn basic_test_nested_map() { let path = basic_path("nested_map.orc"); @@ -342,6 +394,17 @@ pub async fn v0_file_test_async() { assert_eq!(1_920_800, total_rows); } +#[cfg(feature = "async")] +#[tokio::test] +pub async fn vx_file_test_async() { + let path = basic_path("0104.orc"); + let reader = new_arrow_stream_reader_root(&path).await; + let batches = reader.try_collect::>().await.unwrap(); + let total_rows: usize = batches.iter().map(|b| b.num_rows()).sum(); + assert_eq!(149235, total_rows); +} + + #[test] pub fn alltypes_test() { let compressions = ["none", "snappy", "zlib", "lzo", "zstd", "lz4"];