aboutsummaryrefslogtreecommitdiff
path: root/exec/vector
diff options
context:
space:
mode:
authorSorabh Hamirwasia <shamirwasia@maprtech.com>2018-06-26 10:53:53 -0700
committerParth Chandra <parthc@apache.org>2018-07-02 13:58:50 -0700
commit208733b52ec40fd49e6bd424782f7c71aabef7e3 (patch)
tree7a694de35866a229b8ccbc7064038465a3998e15 /exec/vector
parent0bdebf27944396d69fa4926d1bf2da5899e03033 (diff)
DRILL-6530: JVM crash with a query involving multiple json files with one file having a schema change of one column from string to list
This closes #1343
Diffstat (limited to 'exec/vector')
-rw-r--r--exec/vector/src/main/codegen/templates/ListWriters.java18
1 files changed, 12 insertions, 6 deletions
diff --git a/exec/vector/src/main/codegen/templates/ListWriters.java b/exec/vector/src/main/codegen/templates/ListWriters.java
index cab8772a7..4300857b9 100644
--- a/exec/vector/src/main/codegen/templates/ListWriters.java
+++ b/exec/vector/src/main/codegen/templates/ListWriters.java
@@ -107,11 +107,13 @@ public class ${mode}ListWriter extends AbstractFieldWriter {
public MapWriter map() {
switch (mode) {
case INIT:
- int vectorCount = container.size();
+ final ValueVector oldVector = container.getChild(name);
final RepeatedMapVector vector = container.addOrGet(name, RepeatedMapVector.TYPE, RepeatedMapVector.class);
innerVector = vector;
writer = new RepeatedMapWriter(vector, this);
- if(vectorCount != container.size()) {
+ // oldVector will be null if it's first batch being created and it might not be same as newly added vector
+ // if new batch has schema change
+ if (oldVector == null || oldVector != vector) {
writer.allocate();
}
writer.setPosition(${index});
@@ -131,11 +133,13 @@ public class ${mode}ListWriter extends AbstractFieldWriter {
public ListWriter list() {
switch (mode) {
case INIT:
- final int vectorCount = container.size();
+ final ValueVector oldVector = container.getChild(name);
final RepeatedListVector vector = container.addOrGet(name, RepeatedListVector.TYPE, RepeatedListVector.class);
innerVector = vector;
writer = new RepeatedListWriter(null, vector, this);
- if (vectorCount != container.size()) {
+ // oldVector will be null if it's first batch being created and it might not be same as newly added vector
+ // if new batch has schema change
+ if (oldVector == null || oldVector != vector) {
writer.allocate();
}
writer.setPosition(${index});
@@ -176,11 +180,13 @@ public class ${mode}ListWriter extends AbstractFieldWriter {
</#if>
switch (mode) {
case INIT:
- final int vectorCount = container.size();
+ final ValueVector oldVector = container.getChild(name);
final Repeated${capName}Vector vector = container.addOrGet(name, ${upperName}_TYPE, Repeated${capName}Vector.class);
innerVector = vector;
writer = new Repeated${capName}WriterImpl(vector, this);
- if(vectorCount != container.size()) {
+ // oldVector will be null if it's first batch being created and it might not be same as newly added vector
+ // if new batch has schema change
+ if (oldVector == null || oldVector != vector) {
writer.allocate();
}
writer.setPosition(${index});