Skip to content

Commit 86154f0

Browse files
elahrvivazwesm
authored andcommitted
ARROW-1340: [Java] Fix NullableMapVector field metadata
Author: Emilio Lahr-Vivaz <elahrvivaz@ccri.com> Closes #953 from elahrvivaz/ARROW-1340 and squashes the following commits: a307779 [Emilio Lahr-Vivaz] ARROW-1340: [Java] Fix NullableMapVector field metadata
1 parent 7fdbcc6 commit 86154f0

File tree

2 files changed

+59
-1
lines changed

2 files changed

+59
-1
lines changed

java/vector/src/main/java/org/apache/arrow/vector/complex/NullableMapVector.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ public NullableMapVector(String name, BufferAllocator allocator, FieldType field
8686
@Override
8787
public Field getField() {
8888
Field f = super.getField();
89-
return new Field(f.getName(), true, f.getType(), f.getChildren());
89+
FieldType type = new FieldType(true, f.getType(), f.getFieldType().getDictionary(), f.getFieldType().getMetadata());
90+
return new Field(f.getName(), type, f.getChildren());
9091
}
9192

9293
@Override
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
package org.apache.arrow.vector;
20+
21+
import java.util.HashMap;
22+
import java.util.Map;
23+
24+
import org.apache.arrow.memory.BufferAllocator;
25+
import org.apache.arrow.vector.complex.NullableMapVector;
26+
import org.apache.arrow.vector.types.pojo.ArrowType.Struct;
27+
import org.apache.arrow.vector.types.pojo.FieldType;
28+
import org.junit.After;
29+
import org.junit.Assert;
30+
import org.junit.Before;
31+
import org.junit.Test;
32+
33+
34+
public class TestMapVector {
35+
36+
private BufferAllocator allocator;
37+
38+
@Before
39+
public void init() {
40+
allocator = new DirtyRootAllocator(Long.MAX_VALUE, (byte) 100);
41+
}
42+
43+
@After
44+
public void terminate() throws Exception {
45+
allocator.close();
46+
}
47+
48+
@Test
49+
public void testFieldMetadata() throws Exception {
50+
Map<String, String> metadata = new HashMap<>();
51+
metadata.put("k1", "v1");
52+
FieldType type = new FieldType(true, Struct.INSTANCE, null, metadata);
53+
try (NullableMapVector vector = new NullableMapVector("map", allocator, type, null)) {
54+
Assert.assertEquals(vector.getField().getMetadata(), type.getMetadata());
55+
}
56+
}
57+
}

0 commit comments

Comments
 (0)