Skip to content

Commit 0c2abea

Browse files
committed
test(parquet): add failing tests for ParquetReadOptions
1 parent 5292e05 commit 0c2abea

1 file changed

Lines changed: 76 additions & 0 deletions

File tree

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
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.assertNull;
24+
import static org.junit.jupiter.api.Assertions.assertSame;
25+
import static org.junit.jupiter.api.Assertions.assertTrue;
26+
27+
import java.util.List;
28+
29+
import org.apache.arrow.vector.types.pojo.ArrowType;
30+
import org.apache.arrow.vector.types.pojo.Field;
31+
import org.apache.arrow.vector.types.pojo.FieldType;
32+
import org.apache.arrow.vector.types.pojo.Schema;
33+
import org.junit.jupiter.api.Test;
34+
35+
class ParquetReadOptionsTest {
36+
37+
@Test
38+
void defaultsMatchDataFusion() {
39+
ParquetReadOptions opts = new ParquetReadOptions();
40+
assertEquals(".parquet", opts.fileExtension());
41+
assertNull(opts.parquetPruning());
42+
assertNull(opts.skipMetadata());
43+
assertNull(opts.metadataSizeHint());
44+
assertNull(opts.schema());
45+
}
46+
47+
@Test
48+
void fluentSettersChainAndMutate() {
49+
Schema schema =
50+
new Schema(
51+
List.of(
52+
new Field(
53+
"x", FieldType.nullable(new ArrowType.Int(32, true)), null)));
54+
55+
ParquetReadOptions opts =
56+
new ParquetReadOptions()
57+
.fileExtension(".parq")
58+
.parquetPruning(true)
59+
.skipMetadata(false)
60+
.metadataSizeHint(1_048_576L)
61+
.schema(schema);
62+
63+
assertEquals(".parq", opts.fileExtension());
64+
assertEquals(Boolean.TRUE, opts.parquetPruning());
65+
assertEquals(Boolean.FALSE, opts.skipMetadata());
66+
assertEquals(Long.valueOf(1_048_576L), opts.metadataSizeHint());
67+
assertTrue(opts.schema() == schema);
68+
}
69+
70+
@Test
71+
void schemaSetterRetainsReferenceIdentity() {
72+
Schema schema = new Schema(List.of());
73+
ParquetReadOptions opts = new ParquetReadOptions().schema(schema);
74+
assertSame(schema, opts.schema());
75+
}
76+
}

0 commit comments

Comments
 (0)