1 # Licensed to the Apache Software Foundation (ASF) under one
2 # or more contributor license agreements. See the NOTICE file
3 # distributed with this work for additional information
4 # regarding copyright ownership. The ASF licenses this file
5 # to you under the Apache License, Version 2.0 (the
6 # "License"); you may not use this file except in compliance
7 # with the License. You may obtain a copy of the License at
9 # http://www.apache.org/licenses/LICENSE-2.0
11 # Unless required by applicable law or agreed to in writing,
12 # software distributed under the License is distributed on an
13 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 # KIND, either express or implied. See the License for the
15 # specific language governing permissions and limitations
18 class TestParquetArrowFileReader
< Test
::Unit::TestCase
19 include Helper
::Buildable
22 omit("Parquet is required") unless defined?(::Parquet)
23 @file = Tempfile
.open(["data", ".parquet"])
24 @a_array = build_string_array(["foo", "bar"])
25 @b_array = build_int32_array([123, 456])
26 @table = build_table("a" => @a_array,
28 writer
= Parquet
::ArrowFileWriter.new(@table.schema
, @file.path
)
30 writer
.write_table(@table, chunk_size
)
32 @reader = Parquet
::ArrowFileReader.new(@file.path
)
36 assert_equal(<<-SCHEMA.chomp, @reader.schema.to_s)
42 sub_test_case("#read_row_group") do
43 test("with column indices") do
44 assert_equal(build_table("b" => @b_array.slice(0, 1)),
45 @reader.read_row_group(0, [-1]))
48 test("without column indices") do
49 assert_equal(build_table("a" => @a_array.slice(1, 1),
50 "b" => @b_array.slice(1, 1)),
51 @reader.read_row_group(1))
57 Arrow
::ChunkedArray.new([@a_array]),
58 Arrow
::ChunkedArray.new([@b_array]),
61 @reader.read_column_data(0),
62 @reader.read_column_data(-1),
67 assert_equal(2, @reader.n_rows
)