Return-Path: X-Original-To: apmail-drill-commits-archive@www.apache.org Delivered-To: apmail-drill-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id BBA8E17B99 for ; Mon, 6 Apr 2015 05:10:23 +0000 (UTC) Received: (qmail 52640 invoked by uid 500); 6 Apr 2015 05:10:23 -0000 Delivered-To: apmail-drill-commits-archive@drill.apache.org Received: (qmail 52607 invoked by uid 500); 6 Apr 2015 05:10:23 -0000 Mailing-List: contact commits-help@drill.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: commits@drill.apache.org Delivered-To: mailing list commits@drill.apache.org Received: (qmail 52598 invoked by uid 99); 6 Apr 2015 05:10:23 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 06 Apr 2015 05:10:23 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 7D8E4E00CC; Mon, 6 Apr 2015 05:10:23 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: amansinha@apache.org To: commits@drill.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: drill git commit: DRILL-2591: In UnionAllRecordBactch, the mechansim to detect schema change is corrected Date: Mon, 6 Apr 2015 05:10:23 +0000 (UTC) Repository: drill Updated Branches: refs/heads/master 862ab91e9 -> a53e12336 DRILL-2591: In UnionAllRecordBactch, the mechansim to detect schema change is corrected Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/a53e1233 Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/a53e1233 Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/a53e1233 Branch: refs/heads/master Commit: a53e12336c29b421f1df51da480af9a65d70bb72 Parents: 862ab91 Author: Hsuan-Yi Chu Authored: Fri Mar 27 11:37:07 2015 -0700 Committer: Aman Sinha Committed: Sun Apr 5 21:43:41 2015 -0700 ---------------------------------------------------------------------- .../impl/union/UnionAllRecordBatch.java | 31 ++++++++-- .../physical/visitor/FinalColumnReorderer.java | 20 ++++--- .../java/org/apache/drill/TestUnionAll.java | 63 +++++++++++++++++++- .../src/test/resources/store/json/dateData.json | 12 ++++ .../test/resources/store/json/timeStmpData.json | 14 +++++ .../testframework/testUnionAllQueries/q18.tsv | 15 +++++ 6 files changed, 141 insertions(+), 14 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/a53e1233/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllRecordBatch.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllRecordBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllRecordBatch.java index 806104a..61de3a4 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllRecordBatch.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/union/UnionAllRecordBatch.java @@ -284,6 +284,11 @@ public class UnionAllRecordBatch extends AbstractRecordBatch { private IterOutcome upstream = IterOutcome.NOT_YET; private boolean leftIsFinish = false; + // These two schemas are obtained from the first record batches of the left and right inputs + // They are used to check if the schema is changed between recordbatches + private BatchSchema leftSchema; + private BatchSchema rightSchema; + public UnionAllInput(UnionAllRecordBatch unionAllRecordBatch, RecordBatch left, RecordBatch right) { this.unionAllRecordBatch = unionAllRecordBatch; leftSide = new OneSideInput(left); @@ -321,13 +326,20 @@ public class UnionAllRecordBatch extends AbstractRecordBatch { upstream = iterOutcome; return upstream; + case OK_NEW_SCHEMA: + if(!rightSide.getRecordBatch().getSchema().equals(rightSchema)) { + throw new SchemaChangeException("Schema change detected in the right input of Union-All. This is not currently supported"); + } + + upstream = IterOutcome.OK; + // fall through case OK: unionAllRecordBatch.setCurrentRecordBatch(rightSide.getRecordBatch()); upstream = iterOutcome; return upstream; default: - throw new SchemaChangeException("Schema change detected in the right input of Union-All. This is not currently supported"); + throw new IllegalStateException(String.format("Unknown state %s.", upstream)); } } else { IterOutcome iterOutcome = leftSide.nextBatch(); @@ -338,7 +350,14 @@ public class UnionAllRecordBatch extends AbstractRecordBatch { upstream = iterOutcome; return upstream; - case OK: + case OK_NEW_SCHEMA: + if(!leftSide.getRecordBatch().getSchema().equals(leftSchema)) { + throw new SchemaChangeException("Schema change detected in the left input of Union-All. This is not currently supported"); + } + + upstream = IterOutcome.OK; + // fall through + case OK: unionAllRecordBatch.setCurrentRecordBatch(leftSide.getRecordBatch()); upstream = iterOutcome; return upstream; @@ -350,7 +369,7 @@ public class UnionAllRecordBatch extends AbstractRecordBatch { return upstream; default: - throw new SchemaChangeException("Schema change detected in the left input of Union-All. This is not currently supported"); + throw new IllegalStateException(String.format("Unknown state %s.", upstream)); } } } @@ -360,8 +379,10 @@ public class UnionAllRecordBatch extends AbstractRecordBatch { // where the output type is chosen based on DRILL's implicit casting rules private void inferOutputFields() { outputFields = Lists.newArrayList(); - Iterator leftIter = leftSide.getRecordBatch().getSchema().iterator(); - Iterator rightIter = rightSide.getRecordBatch().getSchema().iterator(); + leftSchema = leftSide.getRecordBatch().getSchema(); + rightSchema = rightSide.getRecordBatch().getSchema(); + Iterator leftIter = leftSchema.iterator(); + Iterator rightIter = rightSchema.iterator(); int index = 1; while(leftIter.hasNext() && rightIter.hasNext()) { http://git-wip-us.apache.org/repos/asf/drill/blob/a53e1233/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/FinalColumnReorderer.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/FinalColumnReorderer.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/FinalColumnReorderer.java index 1aa033b..375d69f 100644 --- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/FinalColumnReorderer.java +++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/FinalColumnReorderer.java @@ -45,14 +45,10 @@ public class FinalColumnReorderer extends BasePrelVisitor