[jira] [Commented] (DRILL-6542) IndexOutOfBoundsException for multilevel lateral queries with schema changed partitioned complex data

2018-07-12 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/DRILL-6542?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16542471#comment-16542471
 ] 

ASF GitHub Bot commented on DRILL-6542:
---

sohami closed pull request #1374: DRILL-6542 : IndexOutOfBoundsException for 
multilevel lateral queries…
URL: https://github.com/apache/drill/pull/1374
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unnest/Unnest.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unnest/Unnest.java
index 77a2ffa4d92..1a042b4aad6 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unnest/Unnest.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unnest/Unnest.java
@@ -64,4 +64,6 @@ void setup(FragmentContext context, RecordBatch incoming, 
RecordBatch outgoing,
* time a new batch comes in.
*/
   void resetGroupIndex();
+
+  void close();
 }
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unnest/UnnestImpl.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unnest/UnnestImpl.java
index ffc64f92373..1d3b8f236cd 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unnest/UnnestImpl.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unnest/UnnestImpl.java
@@ -25,6 +25,7 @@
 import org.apache.drill.exec.record.BatchSchema.SelectionVectorMode;
 import org.apache.drill.exec.record.RecordBatch;
 import org.apache.drill.exec.record.TransferPair;
+import org.apache.drill.exec.vector.SchemaChangeCallBack;
 import org.apache.drill.exec.vector.ValueVector;
 import org.apache.drill.exec.vector.complex.RepeatedValueVector;
 import org.slf4j.Logger;
@@ -51,6 +52,7 @@
   private SelectionVectorMode svMode;
   private RepeatedValueVector fieldToUnnest;
   private RepeatedValueVector.RepeatedAccessor accessor;
+  private RecordBatch outgoing;
 
   /**
* The output batch limit starts at OUTPUT_ROW_COUNT, but may be decreased
@@ -97,8 +99,16 @@ public final int unnestRecords(final int recordCount) {
 
 logger.debug("Unnest: currentRecord: {}, innerValueCount: {}, record 
count: {}, output limit: {}", innerValueCount,
 recordCount, outputLimit);
+final SchemaChangeCallBack callBack = new SchemaChangeCallBack();
 for (TransferPair t : transfers) {
   t.splitAndTransfer(innerValueIndex, count);
+
+  // Get the corresponding ValueVector in output container and transfer 
the data
+  final ValueVector vectorWithData = t.getTo();
+  final ValueVector outputVector = 
outgoing.getContainer().addOrGet(vectorWithData.getField(), callBack);
+  Preconditions.checkState(!callBack.getSchemaChangedAndReset(), "Outgoing 
container doesn't have " +
+"expected ValueVector of type %s, present in TransferPair of unnest 
field", vectorWithData.getClass());
+  vectorWithData.makeTransferPair(outputVector).transfer();
 }
 innerValueIndex += count;
 return count;
@@ -110,6 +120,7 @@ public final void setup(FragmentContext context, 
RecordBatch incoming, RecordBat
   List transfers, LateralContract lateral) throws 
SchemaChangeException {
 
 this.svMode = incoming.getSchema().getSelectionVectorMode();
+this.outgoing = outgoing;
 if (svMode == NONE) {
   this.transfers = ImmutableList.copyOf(transfers);
   this.lateral = lateral;
@@ -123,4 +134,13 @@ public void resetGroupIndex() {
 this.innerValueIndex = 0;
   }
 
+  @Override
+  public void close() {
+if (transfers != null) {
+  for (TransferPair tp : transfers) {
+tp.getTo().close();
+  }
+  transfers = null;
+}
+  }
 }
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unnest/UnnestRecordBatch.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unnest/UnnestRecordBatch.java
index 3ef547c5f46..ed772fe4fba 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unnest/UnnestRecordBatch.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unnest/UnnestRecordBatch.java
@@ -24,6 +24,7 @@
 import org.apache.drill.exec.ExecConstants;
 import org.apache.drill.exec.exception.OutOfMemoryException;
 import org.apache.drill.exec.exception.SchemaChangeException;
+import org.apache.drill.exec.expr.TypeHelper;
 import org.apache.drill.exec.ops.FragmentContext;
 import org.apache.drill.exec.ops.MetricDef;
 import org.apache.drill.exec.physical.config.UnnestPOP;
@@ -48,7 +49,7 @@
 public class UnnestRecordBatch extends 
AbstractTableFunctionRecordBatch {
   private static fina

[jira] [Commented] (DRILL-6542) IndexOutOfBoundsException for multilevel lateral queries with schema changed partitioned complex data

2018-07-12 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/DRILL-6542?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16542376#comment-16542376
 ] 

ASF GitHub Bot commented on DRILL-6542:
---

sohami commented on a change in pull request #1374: DRILL-6542 : 
IndexOutOfBoundsException for multilevel lateral queries…
URL: https://github.com/apache/drill/pull/1374#discussion_r202218606
 
 

 ##
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unnest/UnnestImpl.java
 ##
 @@ -97,8 +99,16 @@ public final int unnestRecords(final int recordCount) {
 
 logger.debug("Unnest: currentRecord: {}, innerValueCount: {}, record 
count: {}, output limit: {}", innerValueCount,
 recordCount, outputLimit);
+final SchemaChangeCallBack callBack = new SchemaChangeCallBack();
 for (TransferPair t : transfers) {
   t.splitAndTransfer(innerValueIndex, count);
+
+  // Get the corresponding ValueVector in output container and transfer 
the data
+  final ValueVector vectorWithData = t.getTo();
+  final ValueVector outputVector = 
outgoing.getContainer().addOrGet(vectorWithData.getField(), callBack);
+  Preconditions.checkState(!callBack.getSchemaChangedAndReset(), "Outgoing 
container doesn't have " +
+"expected ValueVector of type %s, present in TransferPair of unnest 
field", vectorWithData.getClass());
+  vectorWithData.makeTransferPair(outputVector).transfer();
 
 Review comment:
   Yes we have to do 2 transfers since there is no api for 
getTransferPairToSingleMap to take target vector. For New Schema there are 2 
cases, in one we have to preserve the output container vector (when schema 
change is for non-unnest column) but reset transfers whereas in other case we 
have to create a new vector in the container (when schema change is on unnest 
column). That's the reason it is done this way.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> IndexOutOfBoundsException for multilevel lateral queries with schema changed 
> partitioned complex data
> -
>
> Key: DRILL-6542
> URL: https://issues.apache.org/jira/browse/DRILL-6542
> Project: Apache Drill
>  Issue Type: Bug
>Affects Versions: 1.14.0
>Reporter: Kedar Sankar Behera
>Assignee: Sorabh Hamirwasia
>Priority: Major
> Fix For: 1.14.0
>
>
> IndexOutOfBoundsException for multilevel lateral queries with schema changed 
> partitioned complex data
> query:
> {code}
> select customer.c_custkey, customer.c_name, orders.orderkey, 
> orders.totalprice, olineitems.l_partkey, olineitems.l_linenumber, 
> olineitems.l_quantity from customer, 
> lateral (select t1.o.o_orderkey as orderkey, t1.o.o_totalprice as totalprice, 
> t1.o.o_lineitems as lineitems from unnest(customer.c_orders) t1(o)) orders, 
> lateral (select t2.l.l_partkey as l_partkey, t2.l.l_linenumber as 
> l_linenumber, t2.l.l_quantity as l_quantity from unnest(orders.lineitems) 
> t2(l)) olineitems 
> order by customer.c_custkey, orders.orderkey, orders.totalprice, 
> olineitems.l_partkey, olineitems.l_linenumber, olineitems.l_quantity limit 50;
> {code}
> Error:
> {code}
> [Error Id: 7427fa7e-af4a-4f11-acd9-ced71848a1ed on drill182:31010]
> org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: 
> IndexOutOfBoundsException: writerIndex: 1 (expected: readerIndex(0) <= 
> writerIndex <= capacity(0))
> Fragment 0:0
> [Error Id: 7427fa7e-af4a-4f11-acd9-ced71848a1ed on drill182:31010]
>  at 
> org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:633)
>  ~[drill-common-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.work.fragment.FragmentExecutor.sendFinalState(FragmentExecutor.java:361)
>  [drill-java-exec-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.work.fragment.FragmentExecutor.cleanup(FragmentExecutor.java:216)
>  [drill-java-exec-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.work.fragment.FragmentExecutor.run(FragmentExecutor.java:327)
>  [drill-java-exec-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.common.SelfCleaningRunnable.run(SelfCleaningRunnable.java:38)
>  [drill-common-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
>  [na:1.8.0_161]
>  at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>  [na:1.8.0_161]
>  at java.lang.Thread.run(Thread.java:748) [na:1.8.0_161]
> Caused

[jira] [Commented] (DRILL-6542) IndexOutOfBoundsException for multilevel lateral queries with schema changed partitioned complex data

2018-07-11 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/DRILL-6542?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16540713#comment-16540713
 ] 

ASF GitHub Bot commented on DRILL-6542:
---

parthchandra commented on a change in pull request #1374: DRILL-6542 : 
IndexOutOfBoundsException for multilevel lateral queries…
URL: https://github.com/apache/drill/pull/1374#discussion_r201848742
 
 

 ##
 File path: 
exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/unnest/UnnestImpl.java
 ##
 @@ -97,8 +99,16 @@ public final int unnestRecords(final int recordCount) {
 
 logger.debug("Unnest: currentRecord: {}, innerValueCount: {}, record 
count: {}, output limit: {}", innerValueCount,
 recordCount, outputLimit);
+final SchemaChangeCallBack callBack = new SchemaChangeCallBack();
 for (TransferPair t : transfers) {
   t.splitAndTransfer(innerValueIndex, count);
+
+  // Get the corresponding ValueVector in output container and transfer 
the data
+  final ValueVector vectorWithData = t.getTo();
+  final ValueVector outputVector = 
outgoing.getContainer().addOrGet(vectorWithData.getField(), callBack);
+  Preconditions.checkState(!callBack.getSchemaChangedAndReset(), "Outgoing 
container doesn't have " +
+"expected ValueVector of type %s, present in TransferPair of unnest 
field", vectorWithData.getClass());
+  vectorWithData.makeTransferPair(outputVector).transfer();
 
 Review comment:
   So we do two transfers? Cheaper to transfer directly to output vector.  We 
can create a new transfer pair with the source vector in the transfer pair we 
set up.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> IndexOutOfBoundsException for multilevel lateral queries with schema changed 
> partitioned complex data
> -
>
> Key: DRILL-6542
> URL: https://issues.apache.org/jira/browse/DRILL-6542
> Project: Apache Drill
>  Issue Type: Bug
>Affects Versions: 1.14.0
>Reporter: Kedar Sankar Behera
>Assignee: Sorabh Hamirwasia
>Priority: Major
> Fix For: 1.14.0
>
>
> IndexOutOfBoundsException for multilevel lateral queries with schema changed 
> partitioned complex data
> query:
> {code}
> select customer.c_custkey, customer.c_name, orders.orderkey, 
> orders.totalprice, olineitems.l_partkey, olineitems.l_linenumber, 
> olineitems.l_quantity from customer, 
> lateral (select t1.o.o_orderkey as orderkey, t1.o.o_totalprice as totalprice, 
> t1.o.o_lineitems as lineitems from unnest(customer.c_orders) t1(o)) orders, 
> lateral (select t2.l.l_partkey as l_partkey, t2.l.l_linenumber as 
> l_linenumber, t2.l.l_quantity as l_quantity from unnest(orders.lineitems) 
> t2(l)) olineitems 
> order by customer.c_custkey, orders.orderkey, orders.totalprice, 
> olineitems.l_partkey, olineitems.l_linenumber, olineitems.l_quantity limit 50;
> {code}
> Error:
> {code}
> [Error Id: 7427fa7e-af4a-4f11-acd9-ced71848a1ed on drill182:31010]
> org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: 
> IndexOutOfBoundsException: writerIndex: 1 (expected: readerIndex(0) <= 
> writerIndex <= capacity(0))
> Fragment 0:0
> [Error Id: 7427fa7e-af4a-4f11-acd9-ced71848a1ed on drill182:31010]
>  at 
> org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:633)
>  ~[drill-common-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.work.fragment.FragmentExecutor.sendFinalState(FragmentExecutor.java:361)
>  [drill-java-exec-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.work.fragment.FragmentExecutor.cleanup(FragmentExecutor.java:216)
>  [drill-java-exec-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.work.fragment.FragmentExecutor.run(FragmentExecutor.java:327)
>  [drill-java-exec-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.common.SelfCleaningRunnable.run(SelfCleaningRunnable.java:38)
>  [drill-common-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
>  [na:1.8.0_161]
>  at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>  [na:1.8.0_161]
>  at java.lang.Thread.run(Thread.java:748) [na:1.8.0_161]
> Caused by: java.lang.IndexOutOfBoundsException: writerIndex: 1 (expected: 
> readerIndex(0) <= writerIndex <= capacity(0))
>  at io.netty.buffer.AbstractByteBuf.writerIndex(AbstractByteBuf.java:104) 
> ~[netty-buffer-4.0.48.Final.jar:4.0.48.Final]
>  at 

[jira] [Commented] (DRILL-6542) IndexOutOfBoundsException for multilevel lateral queries with schema changed partitioned complex data

2018-07-10 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/DRILL-6542?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16539358#comment-16539358
 ] 

ASF GitHub Bot commented on DRILL-6542:
---

sohami commented on issue #1374: DRILL-6542 : IndexOutOfBoundsException for 
multilevel lateral queries…
URL: https://github.com/apache/drill/pull/1374#issuecomment-403996831
 
 
   @parthchandra - Please help to review this.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> IndexOutOfBoundsException for multilevel lateral queries with schema changed 
> partitioned complex data
> -
>
> Key: DRILL-6542
> URL: https://issues.apache.org/jira/browse/DRILL-6542
> Project: Apache Drill
>  Issue Type: Bug
>Affects Versions: 1.14.0
>Reporter: Kedar Sankar Behera
>Assignee: Sorabh Hamirwasia
>Priority: Major
> Fix For: 1.14.0
>
>
> IndexOutOfBoundsException for multilevel lateral queries with schema changed 
> partitioned complex data
> query:
> {code}
> select customer.c_custkey, customer.c_name, orders.orderkey, 
> orders.totalprice, olineitems.l_partkey, olineitems.l_linenumber, 
> olineitems.l_quantity from customer, 
> lateral (select t1.o.o_orderkey as orderkey, t1.o.o_totalprice as totalprice, 
> t1.o.o_lineitems as lineitems from unnest(customer.c_orders) t1(o)) orders, 
> lateral (select t2.l.l_partkey as l_partkey, t2.l.l_linenumber as 
> l_linenumber, t2.l.l_quantity as l_quantity from unnest(orders.lineitems) 
> t2(l)) olineitems 
> order by customer.c_custkey, orders.orderkey, orders.totalprice, 
> olineitems.l_partkey, olineitems.l_linenumber, olineitems.l_quantity limit 50;
> {code}
> Error:
> {code}
> [Error Id: 7427fa7e-af4a-4f11-acd9-ced71848a1ed on drill182:31010]
> org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: 
> IndexOutOfBoundsException: writerIndex: 1 (expected: readerIndex(0) <= 
> writerIndex <= capacity(0))
> Fragment 0:0
> [Error Id: 7427fa7e-af4a-4f11-acd9-ced71848a1ed on drill182:31010]
>  at 
> org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:633)
>  ~[drill-common-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.work.fragment.FragmentExecutor.sendFinalState(FragmentExecutor.java:361)
>  [drill-java-exec-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.work.fragment.FragmentExecutor.cleanup(FragmentExecutor.java:216)
>  [drill-java-exec-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.work.fragment.FragmentExecutor.run(FragmentExecutor.java:327)
>  [drill-java-exec-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.common.SelfCleaningRunnable.run(SelfCleaningRunnable.java:38)
>  [drill-common-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
>  [na:1.8.0_161]
>  at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>  [na:1.8.0_161]
>  at java.lang.Thread.run(Thread.java:748) [na:1.8.0_161]
> Caused by: java.lang.IndexOutOfBoundsException: writerIndex: 1 (expected: 
> readerIndex(0) <= writerIndex <= capacity(0))
>  at io.netty.buffer.AbstractByteBuf.writerIndex(AbstractByteBuf.java:104) 
> ~[netty-buffer-4.0.48.Final.jar:4.0.48.Final]
>  at 
> org.apache.drill.exec.vector.UInt1Vector.splitAndTransferTo(UInt1Vector.java:329)
>  ~[vector-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.vector.NullableBigIntVector.splitAndTransferTo(NullableBigIntVector.java:312)
>  ~[vector-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.vector.NullableBigIntVector$TransferImpl.splitAndTransfer(NullableBigIntVector.java:339)
>  ~[vector-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.vector.complex.RepeatedMapVector$SingleMapTransferPair.splitAndTransfer(RepeatedMapVector.java:298)
>  ~[vector-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.physical.impl.unnest.UnnestImpl.unnestRecords(UnnestImpl.java:101)
>  ~[drill-java-exec-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.physical.impl.unnest.UnnestRecordBatch.doWork(UnnestRecordBatch.java:283)
>  ~[drill-java-exec-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.physical.impl.unnest.UnnestRecordBatch.innerNext(UnnestRecordBatch.java:236)
>  ~[drill-java-exec-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.record.AbstractRecordBatch.next(AbstractRecordBatch.java:172)
>  ~[dri

[jira] [Commented] (DRILL-6542) IndexOutOfBoundsException for multilevel lateral queries with schema changed partitioned complex data

2018-07-10 Thread ASF GitHub Bot (JIRA)


[ 
https://issues.apache.org/jira/browse/DRILL-6542?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16539357#comment-16539357
 ] 

ASF GitHub Bot commented on DRILL-6542:
---

sohami opened a new pull request #1374: DRILL-6542 : IndexOutOfBoundsException 
for multilevel lateral queries…
URL: https://github.com/apache/drill/pull/1374
 
 
   … with schema changed partitioned complex data


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> IndexOutOfBoundsException for multilevel lateral queries with schema changed 
> partitioned complex data
> -
>
> Key: DRILL-6542
> URL: https://issues.apache.org/jira/browse/DRILL-6542
> Project: Apache Drill
>  Issue Type: Bug
>Affects Versions: 1.14.0
>Reporter: Kedar Sankar Behera
>Assignee: Sorabh Hamirwasia
>Priority: Major
> Fix For: 1.14.0
>
>
> IndexOutOfBoundsException for multilevel lateral queries with schema changed 
> partitioned complex data
> query:
> {code}
> select customer.c_custkey, customer.c_name, orders.orderkey, 
> orders.totalprice, olineitems.l_partkey, olineitems.l_linenumber, 
> olineitems.l_quantity from customer, 
> lateral (select t1.o.o_orderkey as orderkey, t1.o.o_totalprice as totalprice, 
> t1.o.o_lineitems as lineitems from unnest(customer.c_orders) t1(o)) orders, 
> lateral (select t2.l.l_partkey as l_partkey, t2.l.l_linenumber as 
> l_linenumber, t2.l.l_quantity as l_quantity from unnest(orders.lineitems) 
> t2(l)) olineitems 
> order by customer.c_custkey, orders.orderkey, orders.totalprice, 
> olineitems.l_partkey, olineitems.l_linenumber, olineitems.l_quantity limit 50;
> {code}
> Error:
> {code}
> [Error Id: 7427fa7e-af4a-4f11-acd9-ced71848a1ed on drill182:31010]
> org.apache.drill.common.exceptions.UserException: SYSTEM ERROR: 
> IndexOutOfBoundsException: writerIndex: 1 (expected: readerIndex(0) <= 
> writerIndex <= capacity(0))
> Fragment 0:0
> [Error Id: 7427fa7e-af4a-4f11-acd9-ced71848a1ed on drill182:31010]
>  at 
> org.apache.drill.common.exceptions.UserException$Builder.build(UserException.java:633)
>  ~[drill-common-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.work.fragment.FragmentExecutor.sendFinalState(FragmentExecutor.java:361)
>  [drill-java-exec-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.work.fragment.FragmentExecutor.cleanup(FragmentExecutor.java:216)
>  [drill-java-exec-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.work.fragment.FragmentExecutor.run(FragmentExecutor.java:327)
>  [drill-java-exec-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.common.SelfCleaningRunnable.run(SelfCleaningRunnable.java:38)
>  [drill-common-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
>  [na:1.8.0_161]
>  at 
> java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
>  [na:1.8.0_161]
>  at java.lang.Thread.run(Thread.java:748) [na:1.8.0_161]
> Caused by: java.lang.IndexOutOfBoundsException: writerIndex: 1 (expected: 
> readerIndex(0) <= writerIndex <= capacity(0))
>  at io.netty.buffer.AbstractByteBuf.writerIndex(AbstractByteBuf.java:104) 
> ~[netty-buffer-4.0.48.Final.jar:4.0.48.Final]
>  at 
> org.apache.drill.exec.vector.UInt1Vector.splitAndTransferTo(UInt1Vector.java:329)
>  ~[vector-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.vector.NullableBigIntVector.splitAndTransferTo(NullableBigIntVector.java:312)
>  ~[vector-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.vector.NullableBigIntVector$TransferImpl.splitAndTransfer(NullableBigIntVector.java:339)
>  ~[vector-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.vector.complex.RepeatedMapVector$SingleMapTransferPair.splitAndTransfer(RepeatedMapVector.java:298)
>  ~[vector-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.physical.impl.unnest.UnnestImpl.unnestRecords(UnnestImpl.java:101)
>  ~[drill-java-exec-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.physical.impl.unnest.UnnestRecordBatch.doWork(UnnestRecordBatch.java:283)
>  ~[drill-java-exec-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.physical.impl.unnest.UnnestRecordBatch.innerNext(UnnestRecordBatch.java:236)
>  ~[drill-java-exec-1.14.0-SNAPSHOT.jar:1.14.0-SNAPSHOT]
>  at 
> org.apache.drill.exec.record.AbstractRecordBatch.next(AbstractRecordBatch.java:172)
>  ~[drill-java-exec-