[4/5] drill git commit: DRILL-2903: General improvements to tests in TestDrillbitResilience + Added RepeatTestRule to tests that are flaky + Added Controls.Builder to create controls string in tests +

2015-06-24 Thread mehant
DRILL-2903: General improvements to tests in TestDrillbitResilience
+ Added RepeatTestRule to tests that are flaky
+ Added Controls.Builder to create controls string in tests
+ Added @Ignore to failing tests (filed JIRAs)

Other fixes:
+ Added @Override to ScanBatch#close to avoid potential bugs
+ Added docs link in ProtobufLengthDecoder
+ Fixed logging issue in CountDownLatchImpl


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/00aa01fb
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/00aa01fb
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/00aa01fb

Branch: refs/heads/master
Commit: 00aa01fb90f3210d1e3027d7f759fb1085b814bd
Parents: 20ec0cd
Author: Sudheesh Katkam 
Authored: Fri May 29 16:50:23 2015 -0700
Committer: Mehant Baid 
Committed: Wed Jun 24 16:24:46 2015 -0700

--
 .../drill/common/util/RepeatTestRule.java   |  72 
 .../org/apache/drill/common/util/TestTools.java |  10 +-
 .../java/org/apache/drill/test/DrillTest.java   |   5 +-
 .../drill/exec/physical/impl/ScanBatch.java |   1 +
 .../drill/exec/rpc/ProtobufLengthDecoder.java   |   3 +-
 .../drill/exec/rpc/control/ControlTunnel.java   |   3 +-
 .../testing/CountDownLatchInjectionImpl.java|   2 +-
 .../drill/exec/testing/ExecutionControls.java   |   9 +-
 .../exec/work/batch/ControlMessageHandler.java  |   8 +-
 .../apache/drill/exec/work/foreman/Foreman.java |   1 -
 .../drill/exec/work/foreman/QueryManager.java   |   2 +-
 .../exec/work/fragment/FragmentExecutor.java|   1 +
 .../exec/server/TestDrillbitResilience.java | 398 +--
 .../org/apache/drill/exec/testing/Controls.java | 214 ++
 .../exec/testing/ControlsInjectionUtil.java | 100 -
 .../testing/TestCountDownLatchInjection.java|  10 +-
 .../exec/testing/TestExceptionInjection.java|  48 +--
 .../drill/exec/testing/TestPauseInjection.java  |  26 +-
 18 files changed, 621 insertions(+), 292 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/drill/blob/00aa01fb/common/src/main/java/org/apache/drill/common/util/RepeatTestRule.java
--
diff --git 
a/common/src/main/java/org/apache/drill/common/util/RepeatTestRule.java 
b/common/src/main/java/org/apache/drill/common/util/RepeatTestRule.java
new file mode 100644
index 000..bc2eabf
--- /dev/null
+++ b/common/src/main/java/org/apache/drill/common/util/RepeatTestRule.java
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.common.util;
+
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runners.model.Statement;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * A {@link TestRule} to repeat a test for a specified number of times. If 
"count" <= 0, the test is not run.
+ * For example,
+ * 
+ * {@code
+ * @Test
+ * @Repeat(count = 20) // repeats the test 20 times
+ * public void unitTest() {
+ *   // code
+ * }
+ * }
+ * 
+ */
+public class RepeatTestRule implements TestRule {
+
+  @Retention(RetentionPolicy.RUNTIME)
+  @Target({ElementType.METHOD})
+  public @interface Repeat {
+int count();
+  }
+
+  private static class RepeatStatement extends Statement {
+private final Statement statement;
+private final int count;
+
+private RepeatStatement(final Statement statement, final int count) {
+  this.statement = statement;
+  this.count = count;
+}
+
+@Override
+public void evaluate() throws Throwable {
+  for (int i = 0; i < count; ++i) {
+statement.evaluate();
+  }
+}
+  }
+
+  @Override
+  public Statement apply(final Statement base, final Description description) {
+final Repeat repeat = description.getAnnotation(Repeat.class);
+return repeat != null ? new RepeatStatement(base, repeat.count()) : base;
+  }
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/00aa01fb/com

[3/5] drill git commit: DRILL-3361: Include Bit type in the newPartitionFunction freemarker template

2015-06-24 Thread mehant
DRILL-3361: Include Bit type in the newPartitionFunction freemarker template


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/20ec0cd6
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/20ec0cd6
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/20ec0cd6

Branch: refs/heads/master
Commit: 20ec0cd63ba46d0f6d48ff232cb8650445e85d3a
Parents: 8b6fa14
Author: Steven Phillips 
Authored: Wed Jun 24 15:31:24 2015 -0700
Committer: Mehant Baid 
Committed: Wed Jun 24 16:15:26 2015 -0700

--
 exec/java-exec/src/main/codegen/templates/NewValueFunctions.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/drill/blob/20ec0cd6/exec/java-exec/src/main/codegen/templates/NewValueFunctions.java
--
diff --git a/exec/java-exec/src/main/codegen/templates/NewValueFunctions.java 
b/exec/java-exec/src/main/codegen/templates/NewValueFunctions.java
index b8ba4cc..d0e99d4 100644
--- a/exec/java-exec/src/main/codegen/templates/NewValueFunctions.java
+++ b/exec/java-exec/src/main/codegen/templates/NewValueFunctions.java
@@ -36,7 +36,7 @@ import org.apache.drill.exec.record.RecordBatch;
 
 public class GNewValueFunctions {
 <#list vv.types as type>
-<#if type.major == "Fixed">
+<#if type.major == "Fixed" || type.major = "Bit">
 
 <#list type.minor as minor>
 <#list vv.modes as mode>



[1/5] drill git commit: DRILL-3318: Bump calcite version to 1.1.0-drill-r9 Added unit test

2015-06-24 Thread mehant
Repository: drill
Updated Branches:
  refs/heads/master c04789dc2 -> 3f0d9221d


DRILL-3318: Bump calcite version to 1.1.0-drill-r9
Added unit test


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/25b7b5ef
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/25b7b5ef
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/25b7b5ef

Branch: refs/heads/master
Commit: 25b7b5ef56970f74e0e9f3d0e9f8070e78e1bfa9
Parents: c04789d
Author: Mehant Baid 
Authored: Tue Jun 23 17:57:31 2015 -0700
Committer: Mehant Baid 
Committed: Wed Jun 24 16:13:27 2015 -0700

--
 .../org/apache/drill/exec/TestWindowFunctions.java| 14 ++
 .../src/test/resources/jsoninput/large_int.json   |  2 ++
 pom.xml   |  2 +-
 3 files changed, 17 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/drill/blob/25b7b5ef/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java
--
diff --git 
a/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java 
b/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java
index e8daff2..2409005 100644
--- 
a/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java
+++ 
b/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java
@@ -288,4 +288,18 @@ public class TestWindowFunctions extends BaseTestQuery {
 .baselineValues(0.0d)
 .go();
   }
+
+  @Test
+  public void testWindowFunctionWithKnownType() throws Exception {
+final String query = "select sum(cast(col_int as int)) over (partition by 
col_varchar) as col1 " +
+"from cp.`jsoninput/large_int.json` limit 1";
+
+testBuilder()
+.sqlQuery(query)
+.unOrdered()
+.baselineColumns("col1")
+.baselineValues(2147483649l)
+.go();
+
+  }
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/25b7b5ef/exec/java-exec/src/test/resources/jsoninput/large_int.json
--
diff --git a/exec/java-exec/src/test/resources/jsoninput/large_int.json 
b/exec/java-exec/src/test/resources/jsoninput/large_int.json
new file mode 100644
index 000..486c02f
--- /dev/null
+++ b/exec/java-exec/src/test/resources/jsoninput/large_int.json
@@ -0,0 +1,2 @@
+{"col_int": 2147483647, "col_varchar": "foo"}
+{"col_int": 2, "col_varchar": "foo"}

http://git-wip-us.apache.org/repos/asf/drill/blob/25b7b5ef/pom.xml
--
diff --git a/pom.xml b/pom.xml
index df75c80..9f61247 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1226,7 +1226,7 @@
   
 org.apache.calcite
 calcite-core
-1.1.0-drill-r8
+1.1.0-drill-r9
 
   
 org.jgrapht



[5/5] drill git commit: DRILL-3345: TestWindowFrame fails to properly check cases involving multiple batches

2015-06-24 Thread mehant
DRILL-3345: TestWindowFrame fails to properly check cases involving multiple 
batches


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/3f0d9221
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/3f0d9221
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/3f0d9221

Branch: refs/heads/master
Commit: 3f0d9221d3f96c20db10e868cc33c2e972318ba6
Parents: 00aa01f
Author: adeneche 
Authored: Wed Jun 24 08:58:39 2015 -0700
Committer: Mehant Baid 
Committed: Wed Jun 24 16:54:36 2015 -0700

--
 .../impl/window/DefaultFrameTemplate.java   |  6 +++---
 .../exec/physical/impl/xsort/MSortTemplate.java | 21 +++-
 .../exec/record/selection/SelectionVector4.java | 16 +++
 3 files changed, 27 insertions(+), 16 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/drill/blob/3f0d9221/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/window/DefaultFrameTemplate.java
--
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/window/DefaultFrameTemplate.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/window/DefaultFrameTemplate.java
index ada068b..535deaa 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/window/DefaultFrameTemplate.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/window/DefaultFrameTemplate.java
@@ -242,11 +242,11 @@ public abstract class DefaultFrameTemplate implements 
WindowFramer {
 final int lastSize = last.getRecordCount();
 
 if (!isSamePartition(currentSize - 1, current, lastSize - 1, last)
-|| !isPeer(currentSize - 1, current, lastSize - 1, last)) {
-  logger.trace("frame changed, we are ready to process first saved batch");
+/*|| !isPeer(currentSize - 1, current, lastSize - 1, last)*/) {
+  logger.trace("partition changed, we are ready to process first saved 
batch");
   return true;
 } else {
-  logger.trace("frame didn't change, fetch next batch");
+  logger.trace("partition didn't change, fetch next batch");
   return false;
 }
   }

http://git-wip-us.apache.org/repos/asf/drill/blob/3f0d9221/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/MSortTemplate.java
--
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/MSortTemplate.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/MSortTemplate.java
index 6686fbe..37529ff 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/MSortTemplate.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/xsort/MSortTemplate.java
@@ -47,6 +47,11 @@ public abstract class MSortTemplate implements MSorter, 
IndexedSortable{
   private Queue newRunStarts;
   private FragmentContext context;
 
+  /**
+   * This is only useful for debugging and/or unit testing. Controls the 
maximum size of batches exposed to downstream
+   */
+  private int desiredRecordBatchCount;
+
   @Override
   public void setup(final FragmentContext context, final BufferAllocator 
allocator, final SelectionVector4 vector4, final VectorContainer hyperBatch) 
throws SchemaChangeException{
 // we pass in the local hyperBatch since that is where we'll be reading 
data.
@@ -71,15 +76,13 @@ public abstract class MSortTemplate implements MSorter, 
IndexedSortable{
 }
 final DrillBuf drillBuf = allocator.buffer(4 * totalCount);
 
-// This is only useful for debugging: change the maximum size of batches 
exposed to downstream
-// when we don't spill to disk
-int MSORT_BATCH_MAXSIZE;
 try {
-  MSORT_BATCH_MAXSIZE = 
context.getConfig().getInt(ExecConstants.EXTERNAL_SORT_MSORT_MAX_BATCHSIZE);
+  desiredRecordBatchCount = 
context.getConfig().getInt(ExecConstants.EXTERNAL_SORT_MSORT_MAX_BATCHSIZE);
 } catch(ConfigException.Missing e) {
-  MSORT_BATCH_MAXSIZE = Character.MAX_VALUE;
+  // value not found, use default value instead
+  desiredRecordBatchCount = Character.MAX_VALUE;
 }
-aux = new SelectionVector4(drillBuf, totalCount, MSORT_BATCH_MAXSIZE);
+aux = new SelectionVector4(drillBuf, totalCount, desiredRecordBatchCount);
   }
 
   /**
@@ -150,11 +153,11 @@ public abstract class MSortTemplate implements MSorter, 
IndexedSortable{
   if (outIndex < vector4.getTotalCount()) {
 copyRun(outIndex, vector4.getTotalCount());
   }
-  final SelectionVector4 tmp = aux.createNewWrapperCurrent();
+  final SelectionVector4 tmp = 
aux.createNewWrapperCurrent(desiredRecordBatchCount);
   aux.clear();
-  aux = this.vector4.createNewWrapperCu

[2/5] drill git commit: DRILL-3359: Also detect the window frame claimed in the window definition

2015-06-24 Thread mehant
DRILL-3359: Also detect the window frame claimed in the window definition


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/8b6fa14a
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/8b6fa14a
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/8b6fa14a

Branch: refs/heads/master
Commit: 8b6fa14acbf678ce8018799a15afea487247f011
Parents: 25b7b5e
Author: Hsuan-Yi Chu 
Authored: Wed Jun 24 15:31:25 2015 -0700
Committer: Mehant Baid 
Committed: Wed Jun 24 16:14:14 2015 -0700

--
 .../sql/parser/UnsupportedOperatorsVisitor.java | 80 ++--
 .../apache/drill/exec/TestWindowFunctions.java  | 14 
 2 files changed, 54 insertions(+), 40 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/drill/blob/8b6fa14a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/UnsupportedOperatorsVisitor.java
--
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/UnsupportedOperatorsVisitor.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/UnsupportedOperatorsVisitor.java
index 0c5afc1..9bbd537 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/UnsupportedOperatorsVisitor.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/UnsupportedOperatorsVisitor.java
@@ -141,46 +141,6 @@ public class UnsupportedOperatorsVisitor extends 
SqlShuttle {
 }
   }
 
-  // DRILL-3188
-  // Disable frame which is other than the default
-  // (i.e., BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
-  if(((SqlCall) nodeInSelectList).operand(1) instanceof SqlWindow) {
-SqlWindow window = (SqlWindow) ((SqlCall) 
nodeInSelectList).operand(1);
-
-SqlNode lowerBound = window.getLowerBound();
-SqlNode upperBound = window.getUpperBound();
-
-// If no frame is specified
-// it is a default frame
-boolean isSupported = (lowerBound == null && upperBound == null);
-
-// When OVER clause contain an ORDER BY clause the following 
frames are equivalent to the default frame:
-// RANGE UNBOUNDED PRECEDING
-// RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
-if(window.getOrderList().size() != 0
-&& !window.isRows()
-&& SqlWindow.isUnboundedPreceding(lowerBound)
-&& (upperBound == null || 
SqlWindow.isCurrentRow(upperBound))) {
-  isSupported = true;
-}
-
-// When OVER clause doesn't contain an ORDER BY clause, the 
following are equivalent to the default frame:
-// RANGE BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
-// ROWS BETWEEN UNBOUNDED PRECEDING AND UNBOUNDED FOLLOWING
-if(window.getOrderList().size() == 0
-&& SqlWindow.isUnboundedPreceding(lowerBound)
-&& SqlWindow.isUnboundedFollowing(upperBound)) {
-  isSupported = true;
-}
-
-if(!isSupported) {
-  
unsupportedOperatorCollector.setException(SqlUnsupportedException.ExceptionType.FUNCTION,
-  "This type of window frame is currently not supported \n" +
-  "See Apache Drill JIRA: DRILL-3188");
-  throw new UnsupportedOperationException();
-}
-  }
-
   // DRILL-3196
   // Disable multiple partitions in a SELECT-CLAUSE
   SqlNode window = ((SqlCall) nodeInSelectList).operand(1);
@@ -214,6 +174,46 @@ public class UnsupportedOperatorsVisitor extends 
SqlShuttle {
   }
 }
 
+// DRILL-3188
+// Disable frame which is other than the default
+// (i.e., BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW)
+if(sqlCall instanceof SqlWindow) {
+  SqlWindow window = (SqlWindow) sqlCall;
+
+  SqlNode lowerBound = window.getLowerBound();
+  SqlNode upperBound = window.getUpperBound();
+
+  // If no frame is specified
+  // it is a default frame
+  boolean isSupported = (lowerBound == null && upperBound == null);
+
+  // When OVER clause contain an ORDER BY clause the following frames are 
equivalent to the default frame:
+  // RANGE UNBOUNDED PRECEDING
+  // RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW
+  if(window.getOrderList().size() != 0
+  && !window.isRows()
+  && SqlWindow.isUnboundedPreceding(lowerBound)
+  && (upperBound == null || SqlWindow.isCurrentRow(upperBound))) {
+isSupported = true;
+  }
+
+  // When OVER clause doesn't contain an ORDER BY clause, the following 
are equivalent to the default

[4/4] drill git commit: DRILL-3304: improve TypeHelper error messages when UnsupportedOprationException is thrown

2015-06-24 Thread hg
DRILL-3304: improve TypeHelper error messages when UnsupportedOprationException 
is thrown


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/064af807
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/064af807
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/064af807

Branch: refs/heads/master
Commit: 064af8079f637b8596e0b303baf5ce26f2b925bd
Parents: 856b3d2
Author: adeneche 
Authored: Wed Jun 17 08:09:51 2015 -0700
Committer: Hanifi Gunes 
Committed: Wed Jun 24 14:40:45 2015 -0700

--
 .../drill/common/exceptions/ErrorHelper.java|  3 +-
 .../src/main/codegen/templates/TypeHelper.java  | 52 +++-
 2 files changed, 31 insertions(+), 24 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/drill/blob/064af807/common/src/main/java/org/apache/drill/common/exceptions/ErrorHelper.java
--
diff --git 
a/common/src/main/java/org/apache/drill/common/exceptions/ErrorHelper.java 
b/common/src/main/java/org/apache/drill/common/exceptions/ErrorHelper.java
index 5dd9b67..0aa5a1b 100644
--- a/common/src/main/java/org/apache/drill/common/exceptions/ErrorHelper.java
+++ b/common/src/main/java/org/apache/drill/common/exceptions/ErrorHelper.java
@@ -40,8 +40,9 @@ class ErrorHelper {
 
 Throwable ex = cause;
 while (ex != null) {
+  message = ex.getClass().getSimpleName();
   if (ex.getMessage() != null) {
-message = ex.getClass().getName() + ": " + ex.getMessage();
+message += ": " + ex.getMessage();
   }
 
   if (ex.getCause() != null && ex.getCause() != ex) {

http://git-wip-us.apache.org/repos/asf/drill/blob/064af807/exec/java-exec/src/main/codegen/templates/TypeHelper.java
--
diff --git a/exec/java-exec/src/main/codegen/templates/TypeHelper.java 
b/exec/java-exec/src/main/codegen/templates/TypeHelper.java
index ad818bd..d6ccd3a 100644
--- a/exec/java-exec/src/main/codegen/templates/TypeHelper.java
+++ b/exec/java-exec/src/main/codegen/templates/TypeHelper.java
@@ -16,8 +16,6 @@
  * limitations under the License.
  */
 
-import org.apache.drill.common.types.MajorType;
-
 <@pp.dropOutputFile />
 <@pp.changeOutputFile name="/org/apache/drill/exec/expr/TypeHelper.java" />
 
@@ -27,6 +25,8 @@ package org.apache.drill.exec.expr;
 
 <#include "/@includes/vv_imports.ftl" />
 import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.common.types.TypeProtos.DataMode;
+import org.apache.drill.common.types.TypeProtos.MinorType;
 import org.apache.drill.common.types.TypeProtos.MajorType;
 import org.apache.drill.exec.record.MaterializedField;
 import org.apache.drill.exec.vector.accessor.*;
@@ -43,6 +43,14 @@ public class TypeHelper {
   // a high value like this will not inflate the size for small values
   public static final int VARCHAR_DEFAULT_CAST_LEN = 65536;
 
+  private static String buildErrorMessage(final String operation, final 
MinorType type, final DataMode mode) {
+return String.format("Unable to %s for minor type [%s] and mode [%s]", 
operation, type, mode);
+  }
+
+  private static String buildErrorMessage(final String operation, final 
MajorType type) {
+return buildErrorMessage(operation, type.getMinorType(), type.getMode());
+  }
+
   public static int getSize(MajorType major) {
 switch (major.getMinorType()) {
 <#list vv.types as type>
@@ -57,15 +65,16 @@ public class TypeHelper {
   case FIXED16CHAR: return major.getWidth();
   case FIXEDBINARY: return major.getWidth();
 }
-throw new UnsupportedOperationException();
+throw new UnsupportedOperationException(buildErrorMessage("get size", 
major));
   }
 
   public static SqlAccessor getSqlAccessor(ValueVector vector){
-switch(vector.getField().getType().getMinorType()){
+final MajorType type = vector.getField().getType();
+switch(type.getMinorType()){
 <#list vv.types as type>
 <#list type.minor as minor>
 case ${minor.class?upper_case}:
-  switch (vector.getField().getType().getMode()) {
+  switch (type.getMode()) {
 case REQUIRED:
   return new ${minor.class}Accessor((${minor.class}Vector) vector);
 case OPTIONAL:
@@ -79,7 +88,7 @@ public class TypeHelper {
 case LIST:
   return new GenericAccessor(vector);
 }
-throw new UnsupportedOperationException("Unable to find sql accessor for 
minor type [" + vector.getField().getType().getMinorType() + "] and mode [" + 
vector.getField().getType().getMode() + "]");
+throw new UnsupportedOperationException(buildErrorMessage("find sql 
accessor", type));
   }
   
   public static ValueVector getNewVector(SchemaPath parentPath, String name, 
BufferAllocator allocator, MajorType type){
@@ -1

[1/4] drill git commit: DRILL-2494: Have PreparedStmt. set-param. methods throw "unsupported".

2015-06-24 Thread hg
Repository: drill
Updated Branches:
  refs/heads/master 856b3d2a1 -> c04789dc2


DRILL-2494: Have PreparedStmt. set-param. methods throw "unsupported".

Added (integration-level) unit test.

Modified set-parameter methods to throw SQLFeatureNotSupportedException.
(Intercepted common getParameter method.)

Inserted DrillPreparedStatement into hierarchy for place for documentation.

Documented that parameter-setting methods are not supported.


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/c04789dc
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/c04789dc
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/c04789dc

Branch: refs/heads/master
Commit: c04789dc22af31bf2c97aaf8511cb502d867d105
Parents: 4dc476d
Author: dbarclay 
Authored: Tue Jun 16 16:39:08 2015 -0700
Committer: Hanifi Gunes 
Committed: Wed Jun 24 14:40:45 2015 -0700

--
 .../drill/jdbc/DrillPreparedStatement.java  |  35 +
 .../jdbc/impl/DrillPreparedStatementImpl.java   |  14 +-
 .../drill/jdbc/PreparedStatementTest.java   | 139 +++
 3 files changed, 187 insertions(+), 1 deletion(-)
--


http://git-wip-us.apache.org/repos/asf/drill/blob/c04789dc/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillPreparedStatement.java
--
diff --git 
a/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillPreparedStatement.java 
b/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillPreparedStatement.java
new file mode 100644
index 000..6a8f4c1
--- /dev/null
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillPreparedStatement.java
@@ -0,0 +1,35 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership.  The ASF
+ * licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.drill.jdbc;
+
+import java.sql.SQLFeatureNotSupportedException;
+import java.sql.PreparedStatement;
+
+
+/**
+ * Drill-specific {@link PreparedStatement}.
+ *
+ * 
+ *   Setting parameters is not supported; parameter-setting methods such as
+ *   {@link setString(int, String)} throw
+ *   {@link SQLFeatureNotSupportedException}.
+ * 
+ * @see #unwrap
+ */
+public interface DrillPreparedStatement extends PreparedStatement {
+
+}

http://git-wip-us.apache.org/repos/asf/drill/blob/c04789dc/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillPreparedStatementImpl.java
--
diff --git 
a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillPreparedStatementImpl.java
 
b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillPreparedStatementImpl.java
index 5e9ec93..86683cb 100644
--- 
a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillPreparedStatementImpl.java
+++ 
b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillPreparedStatementImpl.java
@@ -17,8 +17,12 @@
  */
 package org.apache.drill.jdbc.impl;
 
+import org.apache.drill.jdbc.DrillPreparedStatement;
+
 import java.sql.SQLException;
+import java.sql.SQLFeatureNotSupportedException;
 
+import net.hydromatic.avatica.AvaticaParameter;
 import net.hydromatic.avatica.AvaticaPrepareResult;
 import net.hydromatic.avatica.AvaticaPreparedStatement;
 
@@ -31,7 +35,8 @@ import net.hydromatic.avatica.AvaticaPreparedStatement;
  * 
  */
 abstract class DrillPreparedStatementImpl extends AvaticaPreparedStatement
-implements DrillRemoteStatement {
+implements DrillPreparedStatement,
+   DrillRemoteStatement {
 
   protected DrillPreparedStatementImpl(DrillConnectionImpl connection,
AvaticaPrepareResult prepareResult,
@@ -49,8 +54,15 @@ abstract class DrillPreparedStatementImpl extends 
AvaticaPreparedStatement
   }
 
   @Override
+  protected AvaticaParameter getParameter(int param) throws SQLException {
+throw new SQLFeatureNotSupportedException(
+"Prepared-statement dynamic parameters are not supported.");
+  }
+
+  @Override
   public void cleanUp() {
 final DrillConnectionImpl connection1 = (DrillConnectionImpl) connection;
 connection1.openStatementsRegistry.removeStatement(this

[2/4] drill git commit: DRILL-2447: Add already-closed checks to remaining ResultSet methods.

2015-06-24 Thread hg
http://git-wip-us.apache.org/repos/asf/drill/blob/4dc476d5/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2489CallsAfterCloseThrowExceptionsTest.java
--
diff --git 
a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2489CallsAfterCloseThrowExceptionsTest.java
 
b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2489CallsAfterCloseThrowExceptionsTest.java
index 0e37efa..01008b2 100644
--- 
a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2489CallsAfterCloseThrowExceptionsTest.java
+++ 
b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/Drill2489CallsAfterCloseThrowExceptionsTest.java
@@ -52,20 +52,18 @@ import org.apache.drill.jdbc.JdbcTestBase;
 import org.apache.drill.jdbc.AlreadyClosedSqlException;
 
 /**
- * Currently, test for DRILL-2565--for key methods only:  for closed 
Connection,
- * Statement, ResultSet, etc., object, throw some kind of "object already 
closed"
- * SQLException,
- *
+ * Test for JDBC requirement that almost all methods throw {@link SQLException}
+ * when called on a closed object (Connection, Statement, ResultSet, etc.).
  * 
- * TO BE:  Test for DRILL-2489--on closed Connection, Statement, ResultSet, 
etc.,
- * objects, most methods must throw some kind of "object already closed" 
SQLException,
- * but few do.
+ *   NOTE:  This test currently covers only {@link Connection},
+ *   {@link Statement}, {@link ResultSet} and part of {@link DatabaseMetaData}
+ *   (but not {@link Statement} subclasses, {@link ResultsetMetadata}, or any
+ *   relevant secondary objects such as {@link Array} or {@link Struct}).
  * 
  * 
- *  NOTE:  Test currently covers only {@link Connection}, {@link Statement},
- *  {@link ResultSet} and part of {@link DatabaseMetaData} (but not
- *  {@link Statement} subclasses, {@link ResultsetMetadata}, or any relevant
- *  secondary objects such as {@link Clob} or {@link Array}.
+ *   Additionally, for JDBC interfaces other than ResultSet, only key methods
+ *   currently implement the check, so many test methods are currently disabled
+ *   with @{@link Ignore}.
  * 
  */
 public class Drill2489CallsAfterCloseThrowExceptionsTest extends JdbcTestBase {
@@ -101,14 +99,18 @@ public class Drill2489CallsAfterCloseThrowExceptionsTest 
extends JdbcTestBase {
   
   // - methods that do _not_ throw exception for closed Connection:
 
+  @Test
   public void testClosedConnection_close_doesNotThrow() throws SQLException {
 closedConnection.close();
   }
 
+  @Test
   public void testClosedConnection_isClosed_returnsTrue() throws SQLException {
 assertThat( closedConnection.isClosed(), equalTo( true ) );
   }
 
+  @Ignore( "until isValid is implemented" )
+  @Test
   public void testClosedConnection_isValid_returnsTrue() throws SQLException {
 assertThat( closedConnection.isValid( 1_000 ), equalTo( true ) );
   }
@@ -128,7 +130,6 @@ public class Drill2489CallsAfterCloseThrowExceptionsTest 
extends JdbcTestBase {
 closedConnection.clearWarnings();
   }
 
-  @Ignore( "until DRILL-2489 addressed" )
   @Test( expected = AlreadyClosedSqlException.class )
   public void testClosedConnection_commit_throws() throws SQLException {
 closedConnection.commit();
@@ -298,6 +299,7 @@ public class Drill2489CallsAfterCloseThrowExceptionsTest 
extends JdbcTestBase {
 closedConnection.prepareStatement( "sql", -4 );
   }
 
+  @Test( expected = AlreadyClosedSqlException.class )
   public void testClosedConnection_prepareStatement4_throws() throws 
SQLException {
 closedConnection.prepareStatement( "sql", -1, -2 );
   }
@@ -313,25 +315,21 @@ public class Drill2489CallsAfterCloseThrowExceptionsTest 
extends JdbcTestBase {
 closedConnection.prepareStatement( "sql", (int[]) null );
   }
 
-  @Ignore( "until DRILL-2489 addressed" )
   @Test( expected = AlreadyClosedSqlException.class )
   public void testClosedConnection_releaseSavepoint_throws() throws 
SQLException {
 closedConnection.releaseSavepoint( (Savepoint) null );
   }
 
-  @Ignore( "until DRILL-2489 addressed" )
   @Test( expected = AlreadyClosedSqlException.class )
   public void testClosedConnection_rollback1_throws() throws SQLException {
 closedConnection.rollback();
   }
 
-  @Ignore( "until DRILL-2489 addressed" )
   @Test( expected = AlreadyClosedSqlException.class )
   public void testClosedConnection_rollback2_throws() throws SQLException {
 closedConnection.rollback( (Savepoint) null );
   }
 
-  @Ignore( "until DRILL-2489 addressed" )
   @Test( expected = AlreadyClosedSqlException.class )
   public void testClosedConnection_setAutoCommit_throws() throws SQLException {
 closedConnection.setAutoCommit( true );
@@ -373,13 +371,11 @@ public class Drill2489CallsAfterCloseThrowExceptionsTest 
extends JdbcTestBase {
 closedConnection.setReadOnly( true );
   }
 
-  @Ignore( "until DRILL-2489 addressed" )
   @Test( expected = AlreadyClosedSqlExce

[3/4] drill git commit: DRILL-2447: Add already-closed checks to remaining ResultSet methods.

2015-06-24 Thread hg
DRILL-2447: Add already-closed checks to remaining ResultSet methods.

Extended coverage from just selected methods to all methods.  Added wrapper
methods checking state before delegating.  (Couldn't implement at just a few
choke points because Avatica makes them private and doesn't provide hooks.)
[DrillResultSetImpl]

Defined DrillResultSet.getQueryId() to throw SQLException as other methods do.
[DrillResultSet]

Re-enabled ResultSet test methods.  (Also re-enabled other test methods that
pass now with DRILL-2782 changes.  [Drill2489CallsAfterCloseThrowExceptionsTest]


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/4dc476d5
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/4dc476d5
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/4dc476d5

Branch: refs/heads/master
Commit: 4dc476d540bc4d091105f4b017732b70e59d26e3
Parents: 064af80
Author: dbarclay 
Authored: Fri Apr 24 16:48:55 2015 -0700
Committer: Hanifi Gunes 
Committed: Wed Jun 24 14:40:45 2015 -0700

--
 .../org/apache/drill/jdbc/DrillResultSet.java   |   22 +-
 .../drill/jdbc/impl/DrillResultSetImpl.java | 1257 +-
 ...l2489CallsAfterCloseThrowExceptionsTest.java |  239 +---
 3 files changed, 1244 insertions(+), 274 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/drill/blob/4dc476d5/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillResultSet.java
--
diff --git a/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillResultSet.java 
b/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillResultSet.java
index e0a7763..858fd61 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillResultSet.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/DrillResultSet.java
@@ -17,27 +17,9 @@
  */
 package org.apache.drill.jdbc;
 
-import java.io.InputStream;
-import java.io.Reader;
 import java.math.BigDecimal;
-import java.net.URL;
-import java.sql.Array;
-import java.sql.Blob;
-import java.sql.Clob;
-import java.sql.Date;
-import java.sql.NClob;
-import java.sql.Ref;
 import java.sql.ResultSet;
-import java.sql.ResultSetMetaData;
-import java.sql.RowId;
 import java.sql.SQLException;
-import java.sql.SQLWarning;
-import java.sql.SQLXML;
-import java.sql.Statement;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.Calendar;
-import java.util.Map;
 
 
 /**
@@ -49,8 +31,10 @@ public interface DrillResultSet extends ResultSet  {
   /**
* Gets the ID of the associated query (the query whose results this 
ResultSet
* presents).
+   *
+   * @throws  SQLException  if this method is called on a closed result set
*/
-  String getQueryId();
+  String getQueryId() throws SQLException;
 
   /**
* {@inheritDoc}

http://git-wip-us.apache.org/repos/asf/drill/blob/4dc476d5/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillResultSetImpl.java
--
diff --git 
a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillResultSetImpl.java 
b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillResultSetImpl.java
index 31593bf..1b37dc1 100644
--- a/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillResultSetImpl.java
+++ b/exec/jdbc/src/main/java/org/apache/drill/jdbc/impl/DrillResultSetImpl.java
@@ -17,18 +17,31 @@
  */
 package org.apache.drill.jdbc.impl;
 
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Date;
+import java.sql.NClob;
+import java.sql.Ref;
 import java.sql.ResultSetMetaData;
+import java.sql.RowId;
 import java.sql.SQLException;
+import java.sql.SQLWarning;
+import java.sql.SQLXML;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.Calendar;
 import java.util.TimeZone;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.LinkedBlockingDeque;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
 
 import net.hydromatic.avatica.AvaticaPrepareResult;
 import net.hydromatic.avatica.AvaticaResultSet;
-import net.hydromatic.avatica.AvaticaStatement;
 
 import org.apache.drill.common.exceptions.UserException;
 import org.apache.drill.exec.ExecConstants;
@@ -72,6 +85,7 @@ class DrillResultSetImpl extends AvaticaResultSet implements 
DrillResultSet {
   final DrillCursor cursor;
   boolean hasPendingCancelationNotification;
 
+
   DrillResultSetImpl(DrillStatementImpl statement, AvaticaPrepareResult 
prepareResult,
  ResultSetMetaData resultSetMetaData, TimeZone timeZone) {
 super(statement, prepareResult, resultSetMetaData, timeZone);
@@ -87,10 +101,6 @@ class DrillResultSetI

drill git commit: DRILL-3326: When inspecting SELECT-LIST, UnsupportedOperatorsVisitor will dig into AS clause

2015-06-24 Thread amansinha
Repository: drill
Updated Branches:
  refs/heads/master 5a34d8194 -> 856b3d2a1


DRILL-3326: When inspecting SELECT-LIST, UnsupportedOperatorsVisitor will dig 
into AS clause


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/856b3d2a
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/856b3d2a
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/856b3d2a

Branch: refs/heads/master
Commit: 856b3d2a1fd083034b1e4a9ed18402d2feb80f56
Parents: 5a34d81
Author: Hsuan-Yi Chu 
Authored: Fri Jun 19 11:59:51 2015 -0700
Committer: Aman Sinha 
Committed: Wed Jun 24 13:24:43 2015 -0700

--
 .../sql/parser/UnsupportedOperatorsVisitor.java|  5 +
 .../org/apache/drill/exec/TestWindowFunctions.java | 13 +
 2 files changed, 18 insertions(+)
--


http://git-wip-us.apache.org/repos/asf/drill/blob/856b3d2a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/UnsupportedOperatorsVisitor.java
--
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/UnsupportedOperatorsVisitor.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/UnsupportedOperatorsVisitor.java
index 544a838..0c5afc1 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/UnsupportedOperatorsVisitor.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/sql/parser/UnsupportedOperatorsVisitor.java
@@ -91,6 +91,11 @@ public class UnsupportedOperatorsVisitor extends SqlShuttle {
   // This is used to keep track of the window function which has been 
defined
   SqlNode definedWindow = null;
   for(SqlNode nodeInSelectList : sqlSelect.getSelectList()) {
+if(nodeInSelectList.getKind() == SqlKind.AS
+&& (((SqlCall) nodeInSelectList).getOperandList().get(0).getKind() 
== SqlKind.OVER)) {
+  nodeInSelectList = ((SqlCall) 
nodeInSelectList).getOperandList().get(0);
+}
+
 if(nodeInSelectList.getKind() == SqlKind.OVER) {
   // Throw exceptions if window functions are disabled
   
if(!context.getOptions().getOption(ExecConstants.ENABLE_WINDOW_FUNCTIONS).bool_val)
 {

http://git-wip-us.apache.org/repos/asf/drill/blob/856b3d2a/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java
--
diff --git 
a/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java 
b/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java
index 1c8b0db..e8daff2 100644
--- 
a/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java
+++ 
b/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java
@@ -197,6 +197,19 @@ public class TestWindowFunctions extends BaseTestQuery {
 }
   }
 
+  @Test(expected = UnsupportedFunctionException.class) // DRILL-3326
+  public void testWindowWithAlias() throws Exception {
+try {
+  String query = "explain plan for SELECT sum(n_nationkey) OVER (PARTITION 
BY n_name ORDER BY n_name ROWS BETWEEN CURRENT ROW AND 1 FOLLOWING) as col2 \n" 
+
+  "from cp.`tpch/nation.parquet`";
+
+  test(query);
+} catch(UserException ex) {
+  throwAsUnsupportedException(ex);
+  throw ex;
+}
+  }
+
   @Test // DRILL-3188
   public void testWindowFrameEquivalentToDefault() throws Exception {
 final String query1 = "explain plan for select sum(n_nationKey) 
over(partition by n_nationKey order by n_nationKey) \n" +



drill git commit: DRILL-3333: Parquet writer auto-partitioning and partition pruning

2015-06-24 Thread smp
Repository: drill
Updated Branches:
  refs/heads/master 3aa82bc92 -> 5a34d8194


DRILL-: Parquet writer auto-partitioning and partition pruning


Project: http://git-wip-us.apache.org/repos/asf/drill/repo
Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/5a34d819
Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/5a34d819
Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/5a34d819

Branch: refs/heads/master
Commit: 5a34d8194a660f82391e1143f445a7a890340e34
Parents: 3aa82bc
Author: Steven Phillips 
Authored: Tue Jun 23 18:41:12 2015 -0700
Committer: Steven Phillips 
Committed: Wed Jun 24 00:48:01 2015 -0700

--
 .../codegen/templates/AbstractRecordWriter.java |  18 +
 .../templates/EventBasedRecordWriter.java   |   8 +
 .../codegen/templates/NewValueFunctions.java| 103 +++
 .../main/codegen/templates/RecordWriter.java|  10 +-
 .../templates/StringOutputRecordWriter.java |  11 +-
 .../exec/physical/base/AbstractGroupScan.java   |   6 +
 .../drill/exec/physical/base/GroupScan.java |   7 +
 .../exec/physical/impl/WriterRecordBatch.java   |   2 +-
 .../planner/ParquetPartitionDescriptor.java |  62 ++
 .../exec/planner/logical/DrillRuleSets.java |   2 +
 .../logical/partition/PruneScanRule.java| 713 ---
 .../sql/handlers/CreateTableHandler.java|   4 +-
 .../drill/exec/store/NewValueFunction.java  | 209 ++
 .../exec/store/easy/json/JsonRecordWriter.java  |   3 +-
 .../exec/store/parquet/ParquetGroupScan.java| 310 +++-
 .../exec/store/parquet/ParquetRecordWriter.java |  42 +-
 .../exec/store/text/DrillTextRecordWriter.java  |   1 +
 17 files changed, 1237 insertions(+), 274 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/drill/blob/5a34d819/exec/java-exec/src/main/codegen/templates/AbstractRecordWriter.java
--
diff --git 
a/exec/java-exec/src/main/codegen/templates/AbstractRecordWriter.java 
b/exec/java-exec/src/main/codegen/templates/AbstractRecordWriter.java
index 6b6065f..5f1f42f 100644
--- a/exec/java-exec/src/main/codegen/templates/AbstractRecordWriter.java
+++ b/exec/java-exec/src/main/codegen/templates/AbstractRecordWriter.java
@@ -16,6 +16,8 @@
  * limitations under the License.
  */
 
+import java.lang.UnsupportedOperationException;
+
 <@pp.dropOutputFile />
 <@pp.changeOutputFile 
name="org/apache/drill/exec/store/AbstractRecordWriter.java" />
 <#include "/@includes/license.ftl" />
@@ -24,6 +26,8 @@ package org.apache.drill.exec.store;
 
 import org.apache.drill.exec.expr.holders.*;
 import org.apache.drill.exec.store.EventBasedRecordWriter.FieldConverter;
+import org.apache.drill.exec.vector.BitVector;
+import org.apache.drill.exec.vector.BitVector.Accessor;
 import org.apache.drill.exec.vector.complex.reader.FieldReader;
 
 import java.io.IOException;
@@ -31,6 +35,20 @@ import java.lang.UnsupportedOperationException;
 
 public abstract class AbstractRecordWriter implements RecordWriter {
 
+  private Accessor newPartitionVector;
+
+  protected void setPartitionVector(BitVector newPartitionVector) {
+this.newPartitionVector = newPartitionVector.getAccessor();
+  }
+
+  protected boolean newPartition(int index) {
+return newPartitionVector.get(index) == 1;
+  }
+
+  public void checkForNewPartition(int index) {
+// no op
+  }
+
   @Override
   public FieldConverter getNewMapConverter(int fieldId, String fieldName, 
FieldReader reader) {
 throw new UnsupportedOperationException("Doesn't support writing Map'");

http://git-wip-us.apache.org/repos/asf/drill/blob/5a34d819/exec/java-exec/src/main/codegen/templates/EventBasedRecordWriter.java
--
diff --git 
a/exec/java-exec/src/main/codegen/templates/EventBasedRecordWriter.java 
b/exec/java-exec/src/main/codegen/templates/EventBasedRecordWriter.java
index 797f3cb..cf1529d 100644
--- a/exec/java-exec/src/main/codegen/templates/EventBasedRecordWriter.java
+++ b/exec/java-exec/src/main/codegen/templates/EventBasedRecordWriter.java
@@ -16,6 +16,8 @@
  * limitations under the License.
  */
 
+import org.apache.drill.exec.planner.physical.WriterPrel;
+
 <@pp.dropOutputFile />
 <@pp.changeOutputFile 
name="org/apache/drill/exec/store/EventBasedRecordWriter.java" />
 <#include "/@includes/license.ftl" />
@@ -25,6 +27,8 @@ package org.apache.drill.exec.store;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 
+import org.apache.drill.common.expression.SchemaPath;
+import org.apache.drill.exec.planner.physical.WriterPrel;
 import org.apache.drill.exec.record.VectorAccessible;
 import org.apache.drill.exec.record.VectorWrapper;
 import org.apache.drill.exec.vector.complex.reader.FieldReader;
@@ -54,6 +58,7 @@ public class EventBasedRecordWriter {