|
| 1 | +/* |
| 2 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + * or more contributor license agreements. See the NOTICE file |
| 4 | + * distributed with this work for additional information |
| 5 | + * regarding copyright ownership. The ASF licenses this file |
| 6 | + * to you under the Apache License, Version 2.0 (the |
| 7 | + * "License"); you may not use this file except in compliance |
| 8 | + * with the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, |
| 13 | + * software distributed under the License is distributed on an |
| 14 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + * KIND, either express or implied. See the License for the |
| 16 | + * specific language governing permissions and limitations |
| 17 | + * under the License. |
| 18 | + */ |
| 19 | + |
| 20 | +package org.apache.datafusion; |
| 21 | + |
| 22 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 23 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
| 24 | + |
| 25 | +import java.nio.file.Files; |
| 26 | +import java.nio.file.Path; |
| 27 | + |
| 28 | +import org.apache.arrow.memory.BufferAllocator; |
| 29 | +import org.apache.arrow.memory.RootAllocator; |
| 30 | +import org.apache.arrow.vector.VectorSchemaRoot; |
| 31 | +import org.apache.arrow.vector.ipc.ArrowReader; |
| 32 | +import org.junit.jupiter.api.Assumptions; |
| 33 | +import org.junit.jupiter.api.Test; |
| 34 | + |
| 35 | +class SessionContextParquetOptionsTest { |
| 36 | + |
| 37 | + @Test |
| 38 | + void readParquetWithDefaultOptionsCountsAllRows() throws Exception { |
| 39 | + Path lineitem = Path.of("tpch-data/sf1/lineitem.parquet"); |
| 40 | + Assumptions.assumeTrue( |
| 41 | + Files.exists(lineitem), "TPC-H SF1 data not found; run `make tpch-data` first"); |
| 42 | + |
| 43 | + try (BufferAllocator allocator = new RootAllocator(); |
| 44 | + SessionContext ctx = new SessionContext(); |
| 45 | + DataFrame df = ctx.readParquet(lineitem.toAbsolutePath().toString()); |
| 46 | + ArrowReader reader = df.collect(allocator)) { |
| 47 | + long total = 0; |
| 48 | + while (reader.loadNextBatch()) { |
| 49 | + VectorSchemaRoot root = reader.getVectorSchemaRoot(); |
| 50 | + total += root.getRowCount(); |
| 51 | + } |
| 52 | + assertEquals(6_001_215L, total); |
| 53 | + assertTrue(total > 0); |
| 54 | + } |
| 55 | + } |
| 56 | +} |
0 commit comments