You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@drill.apache.org by me...@apache.org on 2015/03/18 22:18:46 UTC

[1/7] drill git commit: DRILL-2491: Fix use of injectable QueryDateTimeInfo in localtimestamp function

Repository: drill
Updated Branches:
  refs/heads/master 3f93454f0 -> 12a7d0179


DRILL-2491: Fix use of injectable QueryDateTimeInfo in localtimestamp function


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

Branch: refs/heads/master
Commit: 151b9be86a7ebb43ff6a5c5538095a0c858844f0
Parents: 3f93454
Author: Mehant Baid <me...@gmail.com>
Authored: Tue Mar 17 18:02:03 2015 -0700
Committer: Mehant Baid <me...@gmail.com>
Committed: Tue Mar 17 18:02:03 2015 -0700

----------------------------------------------------------------------
 .../apache/drill/exec/expr/fn/impl/DateTypeFunctions.java |  2 +-
 .../apache/drill/exec/fn/impl/TestNewDateFunctions.java   | 10 ++++++++++
 2 files changed, 11 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/151b9be8/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/DateTypeFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/DateTypeFunctions.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/DateTypeFunctions.java
index a628afc..668c9ba 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/DateTypeFunctions.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/DateTypeFunctions.java
@@ -297,7 +297,7 @@ public class DateTypeFunctions {
 
         public void setup() {
 
-            org.joda.time.DateTime now = (new org.joda.time.DateTime(dateTime)).withZoneRetainFields(org.joda.time.DateTimeZone.UTC);
+            org.joda.time.DateTime now = (new org.joda.time.DateTime(dateTime.getQueryStartTime())).withZoneRetainFields(org.joda.time.DateTimeZone.UTC);
             queryStartDate = now.getMillis();
         }
 

http://git-wip-us.apache.org/repos/asf/drill/blob/151b9be8/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestNewDateFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestNewDateFunctions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestNewDateFunctions.java
index 6f912f8..0e9276c 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestNewDateFunctions.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestNewDateFunctions.java
@@ -93,4 +93,14 @@ public class TestNewDateFunctions extends BaseTestQuery {
         .baselineValues(true)
         .go();
   }
+
+  @Test
+  public void testLocalTimestamp() throws Exception {
+    testBuilder()
+        .sqlQuery("select extract(day from localtimestamp) = extract(day from current_date) as col from cp.`employee.json` limit 1")
+        .unOrdered()
+        .baselineColumns("col")
+        .baselineValues(true)
+        .go();
+  }
 }


[7/7] drill git commit: DRILL-2309: Fix reduce aggregate rule to create new aggregate calls based on input row type

Posted by me...@apache.org.
DRILL-2309: Fix reduce aggregate rule to create new aggregate calls based on input row type


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

Branch: refs/heads/master
Commit: 12a7d01791bb9ad0126f2dccf2100f09668861d1
Parents: 29fe695
Author: Mehant Baid <me...@gmail.com>
Authored: Tue Mar 17 19:45:38 2015 -0700
Committer: Mehant Baid <me...@gmail.com>
Committed: Tue Mar 17 23:31:34 2015 -0700

----------------------------------------------------------------------
 .../planner/logical/DrillReduceAggregatesRule.java | 14 +++++++++++---
 .../drill/exec/fn/impl/TestAggregateFunctions.java | 17 +++++++++++++++++
 .../src/test/resources/jsoninput/nullable3.json    |  3 +++
 3 files changed, 31 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/12a7d017/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillReduceAggregatesRule.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillReduceAggregatesRule.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillReduceAggregatesRule.java
index 94fed87..af5c776 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillReduceAggregatesRule.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/logical/DrillReduceAggregatesRule.java
@@ -26,6 +26,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 
+import com.google.common.collect.Lists;
 import org.apache.drill.exec.planner.sql.DrillSqlOperator;
 import org.eigenbase.rel.AggregateCall;
 import org.eigenbase.rel.AggregateRel;
@@ -46,7 +47,6 @@ import org.eigenbase.sql.fun.SqlAvgAggFunction;
 import org.eigenbase.sql.fun.SqlStdOperatorTable;
 import org.eigenbase.sql.fun.SqlSumAggFunction;
 import org.eigenbase.sql.fun.SqlSumEmptyIsZeroAggFunction;
-import org.eigenbase.sql.type.SqlTypeUtil;
 import org.eigenbase.util.CompositeList;
 import org.eigenbase.util.ImmutableIntList;
 import org.eigenbase.util.Util;
@@ -247,8 +247,16 @@ public class DrillReduceAggregatesRule extends RelOptRule {
       // anything else:  preserve original call
       RexBuilder rexBuilder = oldAggRel.getCluster().getRexBuilder();
       final int nGroups = oldAggRel.getGroupCount();
-      List<RelDataType> oldArgTypes = SqlTypeUtil
-          .projectTypes(oldAggRel.getRowType(), oldCall.getArgList());
+
+      List<RelDataType> oldArgTypes = new ArrayList<>();
+      List<Integer> ordinals = oldCall.getArgList();
+
+      assert ordinals.size() <= inputExprs.size();
+
+      for (int ordinal : ordinals) {
+        oldArgTypes.add(inputExprs.get(ordinal).getType());
+      }
+
       return rexBuilder.addAggCall(
           oldCall,
           nGroups,

http://git-wip-us.apache.org/repos/asf/drill/blob/12a7d017/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunctions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunctions.java
index f3c7fa5..72ad31a 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunctions.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestAggregateFunctions.java
@@ -168,4 +168,21 @@ public class TestAggregateFunctions extends BaseTestQuery {
         .go();
   }
 
+  @Test
+  public void testCountWithAvg() throws Exception {
+    testBuilder()
+        .sqlQuery("select count(a) col1, avg(b) col2 from cp.`jsoninput/nullable3.json`")
+        .unOrdered()
+        .baselineColumns("col1", "col2")
+        .baselineValues(2l, 3.0d)
+        .go();
+
+    testBuilder()
+        .sqlQuery("select count(a) col1, avg(a) col2 from cp.`jsoninput/nullable3.json`")
+        .unOrdered()
+        .baselineColumns("col1", "col2")
+        .baselineValues(2l, 1.0d)
+        .go();
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/12a7d017/exec/java-exec/src/test/resources/jsoninput/nullable3.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/jsoninput/nullable3.json b/exec/java-exec/src/test/resources/jsoninput/nullable3.json
new file mode 100644
index 0000000..7c1f6a7
--- /dev/null
+++ b/exec/java-exec/src/test/resources/jsoninput/nullable3.json
@@ -0,0 +1,3 @@
+{"a" : 1, "b" : 3}
+{"a" : null, "b" : 3}
+{"a" : 1, "b" : null}


[5/7] drill git commit: DRILL-2106: Fix SplitUpComplexExpression rule to correctly detect last used column reference in the project expression

Posted by me...@apache.org.
DRILL-2106: Fix SplitUpComplexExpression rule to correctly detect last used column reference in the project expression


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

Branch: refs/heads/master
Commit: 47bcacaeed46dd1594d36c5d7e4939d9e4c67bab
Parents: 8faa664
Author: Mehant Baid <me...@gmail.com>
Authored: Sat Mar 14 12:20:30 2015 -0700
Committer: Mehant Baid <me...@gmail.com>
Committed: Tue Mar 17 18:08:04 2015 -0700

----------------------------------------------------------------------
 .../drill/exec/planner/physical/PrelUtil.java   | 36 ++++++++++++++++++++
 .../visitor/SplitUpComplexExpressions.java      | 13 ++++---
 .../exec/physical/impl/flatten/TestFlatten.java | 15 ++++++++
 .../resources/flatten/drill-2106-result.json    | 12 +++++++
 4 files changed, 71 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/47bcacae/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/PrelUtil.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/PrelUtil.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/PrelUtil.java
index aa835e6..d904c3a 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/PrelUtil.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/PrelUtil.java
@@ -125,6 +125,14 @@ public class PrelUtil {
     return new SelectionVectorRemoverPrel(prel);
   }
 
+  public static int getLastUsedColumnReference(List<RexNode> projects) {
+    LastUsedRefVisitor lastUsed = new LastUsedRefVisitor();
+    for (RexNode rex : projects) {
+      rex.accept(lastUsed);
+    }
+    return lastUsed.getLastUsedReference();
+  }
+
   public static ProjectPushInfo getColumns(RelDataType rowType, List<RexNode> projects) {
     final List<String> fieldNames = rowType.getFieldNames();
     if (fieldNames.isEmpty()) {
@@ -241,6 +249,34 @@ public class PrelUtil {
     }
   }
 
+  // Simple visitor class to determine the last used reference in the expression
+  private static class LastUsedRefVisitor extends RexVisitorImpl {
+
+    int lastUsedRef = -1;
+
+    protected LastUsedRefVisitor() {
+      super(true);
+    }
+
+    @Override
+    public Void visitInputRef(RexInputRef inputRef) {
+      lastUsedRef = Math.max(lastUsedRef, inputRef.getIndex());
+      return null;
+    }
+
+    @Override
+    public Void visitCall(RexCall call) {
+      for (RexNode operand : call.operands) {
+        operand.accept(this);
+      }
+      return null;
+    }
+
+    public int getLastUsedReference() {
+      return lastUsedRef;
+    }
+  }
+
   /** Visitor that finds the set of inputs that are used. */
   private static class RefFieldsVisitor extends RexVisitorImpl<PathSegment> {
     final Set<SchemaPath> columns = Sets.newLinkedHashSet();

http://git-wip-us.apache.org/repos/asf/drill/blob/47bcacae/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/SplitUpComplexExpressions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/SplitUpComplexExpressions.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/SplitUpComplexExpressions.java
index 11b6c43..d263ad1 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/SplitUpComplexExpressions.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/SplitUpComplexExpressions.java
@@ -82,18 +82,22 @@ public class SplitUpComplexExpressions extends BasePrelVisitor<Prel, Object, Rel
   @Override
   public Prel visitProject(ProjectPrel project, Object unused) throws RelConversionException {
 
+    // Apply the rule to the child
+    RelNode originalInput = ((Prel)project.getInput(0)).accept(this, null);
+    project = (ProjectPrel) project.copy(project.getTraitSet(), Lists.newArrayList(originalInput));
+
     List<RexNode> exprList = new ArrayList<>();
 
     List<RelDataTypeField> relDataTypes = new ArrayList();
     List<RelDataTypeField> origRelDataTypes = new ArrayList();
     int i = 0;
+    final int lastColumnReferenced = PrelUtil.getLastUsedColumnReference(project.getProjects());
 
-    ProjectPushInfo columnInfo = PrelUtil.getColumns(project.getInput(0).getRowType(), project.getProjects());
-
-    if (columnInfo == null ) {
+    if (lastColumnReferenced == -1) {
       return project;
     }
-    int lastRexInput = columnInfo.desiredFields.size();
+
+    final int lastRexInput = lastColumnReferenced + 1;
     RexVisitorComplexExprSplitter exprSplitter = new RexVisitorComplexExprSplitter(factory, funcReg, lastRexInput);
 
     for (RexNode rex : project.getChildExps()) {
@@ -103,7 +107,6 @@ public class SplitUpComplexExpressions extends BasePrelVisitor<Prel, Object, Rel
     }
     List<RexNode> complexExprs = exprSplitter.getComplexExprs();
 
-    RelNode originalInput = ((Prel)project.getInput(0)).accept(this, null);
     ProjectPrel childProject;
 
     List<RexNode> allExprs = new ArrayList();

http://git-wip-us.apache.org/repos/asf/drill/blob/47bcacae/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/flatten/TestFlatten.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/flatten/TestFlatten.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/flatten/TestFlatten.java
index dc37079..d64dc91 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/flatten/TestFlatten.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/flatten/TestFlatten.java
@@ -249,4 +249,19 @@ public class TestFlatten extends BaseTestQuery {
             .build().run();
   }
 
+  @Test
+  public void testDRILL_2106() throws Exception {
+    testBuilder()
+        .sqlQuery("select rl, flatten(rl) frl from (select `integer`, flatten(rl) as rl from cp.`jsoninput/input2.json`)")
+        .unOrdered()
+        .jsonBaselineFile("flatten/drill-2106-result.json")
+        .go();
+
+    testBuilder()
+        .sqlQuery("select rl, flatten(rl) frl from (select flatten(rl) as rl, `integer` from cp.`jsoninput/input2.json`)")
+        .unOrdered()
+        .jsonBaselineFile("flatten/drill-2106-result.json")
+        .go();
+
+  }
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/47bcacae/exec/java-exec/src/test/resources/flatten/drill-2106-result.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/flatten/drill-2106-result.json b/exec/java-exec/src/test/resources/flatten/drill-2106-result.json
new file mode 100644
index 0000000..35e3c0d
--- /dev/null
+++ b/exec/java-exec/src/test/resources/flatten/drill-2106-result.json
@@ -0,0 +1,12 @@
+{"rl": [2,1], "frl": 2}
+{"rl": [2,1], "frl": 1}
+{"rl": [4,6], "frl": 4}
+{"rl": [4,6], "frl": 6}
+{"rl": [2,1], "frl": 2}
+{"rl": [2,1], "frl": 1}
+{"rl": [4,6], "frl": 4}
+{"rl": [4,6], "frl": 6}
+{"rl": [2,1], "frl": 2}
+{"rl": [2,1], "frl": 1}
+{"rl": [4,6], "frl": 4}
+{"rl": [4,6], "frl": 6}
\ No newline at end of file


[6/7] drill git commit: DRILL-2180: Star column is enabled to work along with complex expression

Posted by me...@apache.org.
DRILL-2180: Star column is enabled to work along with complex expression


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

Branch: refs/heads/master
Commit: 29fe695bdf5d4a14d605b3a0dbb9b1042425538a
Parents: 47bcaca
Author: Hsuan-Yi Chu <hs...@usc.edu>
Authored: Mon Mar 16 12:32:58 2015 -0700
Committer: Mehant Baid <me...@gmail.com>
Committed: Tue Mar 17 18:08:11 2015 -0700

----------------------------------------------------------------------
 .../visitor/SplitUpComplexExpressions.java      | 15 ++++++++--
 .../exec/physical/impl/flatten/TestFlatten.java | 29 ++++++++++++++++++++
 .../src/test/resources/store/text/sample.json   | 26 ++++++++++++++++++
 3 files changed, 68 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/29fe695b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/SplitUpComplexExpressions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/SplitUpComplexExpressions.java b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/SplitUpComplexExpressions.java
index d263ad1..9e01c42 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/SplitUpComplexExpressions.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/visitor/SplitUpComplexExpressions.java
@@ -23,6 +23,7 @@ import com.google.common.collect.Lists;
 import net.hydromatic.optiq.tools.RelConversionException;
 
 import org.apache.drill.exec.expr.fn.FunctionImplementationRegistry;
+import org.apache.drill.exec.planner.StarColumnHelper;
 import org.apache.drill.exec.planner.logical.DrillRel;
 import org.apache.drill.exec.planner.logical.DrillScanRel;
 import org.apache.drill.exec.planner.logical.DrillTable;
@@ -110,10 +111,18 @@ public class SplitUpComplexExpressions extends BasePrelVisitor<Prel, Object, Rel
     ProjectPrel childProject;
 
     List<RexNode> allExprs = new ArrayList();
+    int exprIndex = 0;
+    List<String> fieldNames = originalInput.getRowType().getFieldNames();
     for (int index = 0; index < lastRexInput; index++) {
       RexBuilder builder = new RexBuilder(factory);
       allExprs.add(builder.makeInputRef( new RelDataTypeDrillImpl(new RelDataTypeHolder(), factory), index));
-      relDataTypes.add(new RelDataTypeFieldImpl("EXPR$" + index, allExprs.size(), factory.createSqlType(SqlTypeName.ANY) ));
+
+      if(fieldNames.get(index).contains(StarColumnHelper.STAR_COLUMN)) {
+        relDataTypes.add(new RelDataTypeFieldImpl(fieldNames.get(index), allExprs.size(), factory.createSqlType(SqlTypeName.ANY)));
+      } else {
+        relDataTypes.add(new RelDataTypeFieldImpl("EXPR$" + exprIndex, allExprs.size(), factory.createSqlType(SqlTypeName.ANY)));
+        exprIndex++;
+      }
     }
     RexNode currRexNode;
     int index = lastRexInput - 1;
@@ -127,9 +136,11 @@ public class SplitUpComplexExpressions extends BasePrelVisitor<Prel, Object, Rel
           allExprs.add(builder.makeInputRef( new RelDataTypeDrillImpl(new RelDataTypeHolder(), factory), index));
         }
         index++;
+        exprIndex++;
+
         currRexNode = complexExprs.remove(0);
         allExprs.add(currRexNode);
-        relDataTypes.add(new RelDataTypeFieldImpl("EXPR$" + index, allExprs.size(), factory.createSqlType(SqlTypeName.ANY) ));
+        relDataTypes.add(new RelDataTypeFieldImpl("EXPR$" + exprIndex, allExprs.size(), factory.createSqlType(SqlTypeName.ANY)));
         childProject = new ProjectPrel(project.getCluster(), project.getTraitSet(), originalInput, ImmutableList.copyOf(allExprs), new RelRecordType(relDataTypes));
         originalInput = childProject;
       }

http://git-wip-us.apache.org/repos/asf/drill/blob/29fe695b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/flatten/TestFlatten.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/flatten/TestFlatten.java b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/flatten/TestFlatten.java
index d64dc91..415296f 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/flatten/TestFlatten.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/physical/impl/flatten/TestFlatten.java
@@ -20,6 +20,7 @@ package org.apache.drill.exec.physical.impl.flatten;
 import static org.junit.Assert.assertEquals;
 
 import org.apache.drill.BaseTestQuery;
+import org.apache.drill.common.util.FileUtils;
 import org.apache.drill.exec.proto.UserBitShared;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -264,4 +265,32 @@ public class TestFlatten extends BaseTestQuery {
         .go();
 
   }
+
+  @Test // see DRILL-2146
+  public void testFalttenWithStar() throws Exception {
+    String root = FileUtils.getResourceAsFile("/store/text/sample.json").toURI().toString();
+    String q1 = String.format("select *, flatten(j.topping) tt, flatten(j.batters.batter) bb, j.id " +
+        "from dfs_test.`%s` j " +
+        "where j.type = 'donut'", root);
+    String q2 = String.format("select *, flatten(j.topping) tt, flatten(j.batters.batter) bb, j.id, j.type " +
+        "from dfs_test.`%s` j " +
+        "where j.type = 'donut'", root);
+
+    test(q1);
+    test(q2);
+  }
+
+  @Test // see DRILL-2012
+  public void testMultipleFalttenWithWhereClause() throws Exception {
+    String root = FileUtils.getResourceAsFile("/store/text/sample.json").toURI().toString();
+    String q1 = String.format("select flatten(j.topping) tt " +
+        "from dfs_test.`%s` j " +
+        "where j.type = 'donut'", root);
+    String q2 = String.format("select j.type, flatten(j.topping) tt " +
+         "from dfs_test.`%s` j " +
+         "where j.type = 'donut'", root);
+
+    test(q1);
+    test(q2);
+  }
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/29fe695b/exec/java-exec/src/test/resources/store/text/sample.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/store/text/sample.json b/exec/java-exec/src/test/resources/store/text/sample.json
new file mode 100644
index 0000000..a2f243e
--- /dev/null
+++ b/exec/java-exec/src/test/resources/store/text/sample.json
@@ -0,0 +1,26 @@
+{
+    "id": "0001",
+    "type": "donut",
+    "name": "Cake",
+    "ppu": 0.55,
+    "batters":
+        {
+            "batter":
+                [
+                    { "id": "1001", "type": "Regular" },
+                    { "id": "1002", "type": "Chocolate" },
+                    { "id": "1003", "type": "Blueberry" },
+                    { "id": "1004", "type": "Devil's Food" }
+                ]
+        },
+    "topping":
+        [
+            { "id": "5001", "type": "None" },
+            { "id": "5002", "type": "Glazed" },
+            { "id": "5005", "type": "Sugar" },
+            { "id": "5007", "type": "Powdered Sugar" },
+            { "id": "5006", "type": "Chocolate with Sprinkles" },
+            { "id": "5003", "type": "Chocolate" },
+            { "id": "5004", "type": "Maple" }
+        ]
+}
\ No newline at end of file


[4/7] drill git commit: DRILL-2389: Remove timestamp with time zone

Posted by me...@apache.org.
DRILL-2389: Remove timestamp with time zone


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

Branch: refs/heads/master
Commit: 8faa66424b81e4341b36c1aeecc767edbb233d38
Parents: 7a56df1
Author: Mehant Baid <me...@gmail.com>
Authored: Tue Mar 17 18:07:53 2015 -0700
Committer: Mehant Baid <me...@gmail.com>
Committed: Tue Mar 17 18:07:53 2015 -0700

----------------------------------------------------------------------
 .../src/main/codegen/data/AggrTypes1.tdd        |  6 --
 exec/java-exec/src/main/codegen/data/Casts.tdd  |  6 --
 .../main/codegen/data/ComparisonTypesMain.tdd   |  1 -
 .../src/main/codegen/data/DateIntervalFunc.tdd  |  2 +-
 .../src/main/codegen/data/ExtractTypes.tdd      |  2 +-
 .../src/main/codegen/data/ValueVectorTypes.tdd  |  1 -
 .../main/codegen/templates/CastDateDate.java    |  6 +-
 .../main/codegen/templates/CastDateVarChar.java |  6 +-
 .../main/codegen/templates/CastVarCharDate.java |  8 +--
 .../templates/ConvertToNullableHolder.java      |  5 +-
 .../templates/DateIntervalAggrFunctions1.java   | 14 +---
 .../DateDateArithmeticFunctions.java            | 10 ---
 .../DateIntervalArithmeticFunctions.java        | 22 +-----
 .../DateToCharFunctions.java                    |  3 -
 .../DateTruncFunctions.java                     |  4 +-
 .../DateIntervalFunctionTemplates/Extract.java  |  6 +-
 .../ToDateTypeFunctions.java                    |  4 --
 .../codegen/templates/FixedValueVectors.java    | 52 +-------------
 .../templates/JsonOutputRecordWriter.java       |  1 -
 .../codegen/templates/NullableValueVectors.java |  2 +-
 .../templates/ParquetOutputRecordWriter.java    |  1 -
 .../codegen/templates/ParquetTypeHelper.java    |  1 -
 .../main/codegen/templates/SqlAccessors.java    | 13 +---
 .../templates/StringOutputRecordWriter.java     |  1 -
 .../src/main/codegen/templates/TypeHelper.java  |  2 +-
 .../bytecode/ScalarReplacementTypes.java        |  4 --
 .../expr/fn/impl/CastBigIntTimeStampTZ.java     | 53 --------------
 .../exec/expr/fn/impl/DateTypeFunctions.java    | 75 +-------------------
 .../drill/exec/expr/fn/impl/HashFunctions.java  | 32 ---------
 .../drill/exec/fn/impl/TestDateFunctions.java   |  4 +-
 .../fn/interp/ExpressionInterpreterTest.java    |  7 +-
 .../drill/exec/record/vector/TestDateTypes.java |  1 -
 .../date/date_difference_arithmetic.json        |  1 -
 .../test/resources/functions/date/to_char.json  |  3 +-
 .../record/vector/test_all_date_literals.json   |  1 -
 .../apache/drill/jdbc/test/TestJdbcQuery.java   |  3 +-
 36 files changed, 25 insertions(+), 338 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/codegen/data/AggrTypes1.tdd
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/data/AggrTypes1.tdd b/exec/java-exec/src/main/codegen/data/AggrTypes1.tdd
index 45d30a2..8952417 100644
--- a/exec/java-exec/src/main/codegen/data/AggrTypes1.tdd
+++ b/exec/java-exec/src/main/codegen/data/AggrTypes1.tdd
@@ -31,8 +31,6 @@
       {inputType: "NullableDate", outputType: "Date", runningType: "Date", major: "Date", initialValue: "Long.MAX_VALUE"},
       {inputType: "TimeStamp", outputType: "TimeStamp", runningType: "TimeStamp", major: "Date", initialValue: "Long.MAX_VALUE"},
       {inputType: "NullableTimeStamp", outputType: "TimeStamp", runningType: "TimeStamp", major: "Date", initialValue: "Long.MAX_VALUE"},
-      {inputType: "TimeStampTZ", outputType: "TimeStampTZ", runningType: "TimeStampTZ", major: "Date", initialValue: "Long.MAX_VALUE"},
-      {inputType: "NullableTimeStampTZ", outputType: "TimeStampTZ", runningType: "TimeStampTZ", major: "Date", initialValue: "Long.MAX_VALUE"},
       {inputType: "Time", outputType: "Time", runningType: "Time", major: "Date", initialValue: "Integer.MAX_VALUE"},
       {inputType: "NullableTime", outputType: "Time", runningType: "Time", major: "Date", initialValue: "Integer.MAX_VALUE"},
       {inputType: "IntervalDay", outputType: "IntervalDay", runningType: "BigInt", major: "Date", initialValue: "Long.MAX_VALUE"},
@@ -60,8 +58,6 @@
       {inputType: "NullableDate", outputType: "Date", runningType: "Date", major: "Date", initialValue: "Long.MIN_VALUE"},
       {inputType: "TimeStamp", outputType: "TimeStamp", runningType: "TimeStamp", major: "Date", initialValue: "Long.MIN_VALUE"},
       {inputType: "NullableTimeStamp", outputType: "TimeStamp", runningType: "TimeStamp", major: "Date", initialValue: "Long.MIN_VALUE"},
-      {inputType: "TimeStampTZ", outputType: "TimeStampTZ", runningType: "TimeStampTZ", major: "Date", initialValue: "Long.MIN_VALUE"},
-      {inputType: "NullableTimeStampTZ", outputType: "TimeStampTZ", runningType: "TimeStampTZ", major: "Date", initialValue: "Long.MIN_VALUE"},
       {inputType: "Time", outputType: "Time", runningType: "Time", major: "Date", initialValue: "Integer.MIN_VALUE"},
       {inputType: "NullableTime", outputType: "Time", runningType: "Time", major: "Date", initialValue: "Integer.MIN_VALUE"},
       {inputType: "IntervalDay", outputType: "IntervalDay", runningType: "BigInt", major: "Date", initialValue: "Long.MIN_VALUE"},
@@ -108,8 +104,6 @@
       {inputType: "NullableDate", outputType: "BigInt", runningType: "BigInt", major: "Date", initialValue: "0"},
       {inputType: "TimeStamp", outputType: "BigInt", runningType: "BigInt", major: "Date", initialValue: "0"},
       {inputType: "NullableTimeStamp", outputType: "BigInt", runningType: "BigInt", major: "Date", initialValue: "0"},
-      {inputType: "TimeStampTZ", outputType: "BigInt", runningType: "BigInt", major: "Date", initialValue: "0"},
-      {inputType: "NullableTimeStampTZ", outputType: "BigInt", runningType: "BigInt", major: "Date", initialValue: "0"},
       {inputType: "Time", outputType: "BigInt", runningType: "BigInt", major: "Date", initialValue: "0"},
       {inputType: "NullableTime", outputType: "BigInt", runningType: "BigInt", major: "Date", initialValue: "0"},
       {inputType: "IntervalDay", outputType: "BigInt", runningType: "BigInt", major: "Date", initialValue: "0"},

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/codegen/data/Casts.tdd
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/data/Casts.tdd b/exec/java-exec/src/main/codegen/data/Casts.tdd
index 6fe7404..7d4914c 100644
--- a/exec/java-exec/src/main/codegen/data/Casts.tdd
+++ b/exec/java-exec/src/main/codegen/data/Casts.tdd
@@ -55,15 +55,10 @@
     {from: "VarBinary", to: "VarBinary", major: "SrcVarlenTargetVarlen"},
 
     {from: "Date", to: "TimeStamp", major: "Date"},
-    {from: "Date", to: "TimeStampTZ", major: "Date"},
     {from: "TimeStamp", to: "Date", major: "Date"},
-    {from: "TimeStamp", to: "TimeStampTZ", major: "Date"},
-    {from: "TimeStampTZ", to: "Date", major: "Date"},
-    {from: "TimeStampTZ", to: "TimeStamp", major: "Date"},
 
     {from: "VarChar", to: "Date", major: "VarCharDate", alias: "datetype"},
     {from: "VarChar", to: "TimeStamp", major: "VarCharDate", alias: "timestamptype"},
-    {from: "VarChar", to: "TimeStampTZ", major: "VarCharDate", alias: "timestamptztype"},
     {from: "VarChar", to: "Time", major: "VarCharDate", alias: "timetype"},
 
     {from: "VarBinary", to: "Date", major: "VarBinaryDate", alias: "datetype"},
@@ -73,7 +68,6 @@
     {from: "Date", to: "VarChar", major: "DateVarChar", bufferLength: "10"}
     {from: "TimeStamp", to: "VarChar", major: "DateVarChar", bufferLength: "23"},
     {from: "Time", to: "VarChar", major: "DateVarChar", bufferLength: "12"},
-    {from: "TimeStampTZ", to: "VarChar", major: "DateVarChar", bufferLength: "54"},
 
     {from: "VarChar", to: "Interval", major: "VarCharInterval"},
     {from: "VarChar", to: "IntervalDay", major: "VarCharInterval"},

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/codegen/data/ComparisonTypesMain.tdd
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/data/ComparisonTypesMain.tdd b/exec/java-exec/src/main/codegen/data/ComparisonTypesMain.tdd
index c4d924c..d5d3f30 100644
--- a/exec/java-exec/src/main/codegen/data/ComparisonTypesMain.tdd
+++ b/exec/java-exec/src/main/codegen/data/ComparisonTypesMain.tdd
@@ -50,7 +50,6 @@
     {comparables: ["TimeStamp"], mode: "primitive"},
     {comparables: ["Date"], mode: "primitive"},
     {comparables: ["Time"], mode: "primitive"},
-    {comparables: ["TimeStampTZ"], mode: "primitive"},
     {comparables: ["IntervalYear"], mode: "primitive"},
 
     {comparables: ["IntervalDay"], mode: "intervalDay"},

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/codegen/data/DateIntervalFunc.tdd
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/data/DateIntervalFunc.tdd b/exec/java-exec/src/main/codegen/data/DateIntervalFunc.tdd
index ea295b3..8b842c3 100644
--- a/exec/java-exec/src/main/codegen/data/DateIntervalFunc.tdd
+++ b/exec/java-exec/src/main/codegen/data/DateIntervalFunc.tdd
@@ -14,6 +14,6 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 {
-    {dates: ["Date", "TimeStamp", "Time", "TimeStampTZ"] },
+    {dates: ["Date", "TimeStamp", "Time"] },
     {intervals: ["Interval", "IntervalDay", "IntervalYear", "Int", "BigInt"] }
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/codegen/data/ExtractTypes.tdd
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/data/ExtractTypes.tdd b/exec/java-exec/src/main/codegen/data/ExtractTypes.tdd
index 594f78f..70d7861 100644
--- a/exec/java-exec/src/main/codegen/data/ExtractTypes.tdd
+++ b/exec/java-exec/src/main/codegen/data/ExtractTypes.tdd
@@ -16,5 +16,5 @@
 
 {
   toTypes: [Second, Minute, Hour, Day, Month, Year],
-  fromTypes: [Date, Time, TimeStamp, TimeStampTZ, Interval, IntervalDay, IntervalYear]
+  fromTypes: [Date, Time, TimeStamp, Interval, IntervalDay, IntervalYear]
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/codegen/data/ValueVectorTypes.tdd
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/data/ValueVectorTypes.tdd b/exec/java-exec/src/main/codegen/data/ValueVectorTypes.tdd
index 813f43a..3f69e25 100644
--- a/exec/java-exec/src/main/codegen/data/ValueVectorTypes.tdd
+++ b/exec/java-exec/src/main/codegen/data/ValueVectorTypes.tdd
@@ -90,7 +90,6 @@
       javaType: "DrillBuf",
       boxedType: "DrillBuf",
       minor: [
-        { class: "TimeStampTZ", millisecondsSize: 8, friendlyType: "DateTime", fields: [ {name: "value", type:"long"}, {name: "index", type: "int"}] },
         { class: "IntervalDay", millisecondsOffset: 4, friendlyType: "Period", fields: [ {name: "days", type:"int"}, {name: "milliseconds", type:"int"}] }
       ]
     },

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/codegen/templates/CastDateDate.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/CastDateDate.java b/exec/java-exec/src/main/codegen/templates/CastDateDate.java
index 4a72297..1cd0b5a 100644
--- a/exec/java-exec/src/main/codegen/templates/CastDateDate.java
+++ b/exec/java-exec/src/main/codegen/templates/CastDateDate.java
@@ -18,7 +18,7 @@
 <@pp.dropOutputFile />
 
 <#list cast.types as type>
-<#if type.major == "Date">  <#-- Template file to convert between Date types (Date, TimeStamp, TimeStampTZ) -->
+<#if type.major == "Date">  <#-- Template file to convert between Date types (Date, TimeStamp) -->
 
 <@pp.changeOutputFile name="/org/apache/drill/exec/expr/fn/impl/gcast/Cast${type.from}To${type.to}.java" />
 
@@ -56,10 +56,6 @@ public class Cast${type.from}To${type.to} implements DrillSimpleFunc {
     out.value = (new org.joda.time.DateMidnight(in.value, org.joda.time.DateTimeZone.UTC)).getMillis();
     <#elseif type.to == "TimeStamp">
     out.value = in.value;
-    <#elseif type.to == "TimeStampTZ">
-    out.value = in.value;
-    // While casting from other date formats, we always use UTC as the timezone
-    out.index = org.apache.drill.exec.expr.fn.impl.DateUtility.timezoneMap.get("UTC");
     </#if>
   }
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/codegen/templates/CastDateVarChar.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/CastDateVarChar.java b/exec/java-exec/src/main/codegen/templates/CastDateVarChar.java
index 570f367..0c31b96 100644
--- a/exec/java-exec/src/main/codegen/templates/CastDateVarChar.java
+++ b/exec/java-exec/src/main/codegen/templates/CastDateVarChar.java
@@ -20,7 +20,7 @@
 
 
 <#list cast.types as type>
-<#if type.major == "DateVarChar">  <#-- Template to convert functions from Date, Time, TimeStamp, TimeStampTZ to VarChar -->
+<#if type.major == "DateVarChar">  <#-- Template to convert functions from Date, Time, TimeStamp to VarChar -->
 
 <@pp.changeOutputFile name="/org/apache/drill/exec/expr/fn/impl/gcast/Cast${type.from}To${type.to}.java" />
 
@@ -67,11 +67,7 @@ public class Cast${type.from}To${type.to} implements DrillSimpleFunc {
       org.joda.time.LocalTime temp = new org.joda.time.LocalTime(in.value, org.joda.time.DateTimeZone.UTC);
       String str = temp.toString();
       <#else>
-      <#if type.from == "TimeStampTZ">
-      org.joda.time.MutableDateTime temp = new org.joda.time.MutableDateTime(in.value, org.joda.time.DateTimeZone.forID(org.apache.drill.exec.expr.fn.impl.DateUtility.timezoneList[in.index]));
-      <#else>
       org.joda.time.MutableDateTime temp = new org.joda.time.MutableDateTime(in.value, org.joda.time.DateTimeZone.UTC);
-      </#if>
       String str = org.apache.drill.exec.expr.fn.impl.DateUtility.format${type.from}.print(temp);
       </#if>
       out.buffer = buffer;

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/codegen/templates/CastVarCharDate.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/CastVarCharDate.java b/exec/java-exec/src/main/codegen/templates/CastVarCharDate.java
index b6c5612..68f9b8c 100644
--- a/exec/java-exec/src/main/codegen/templates/CastVarCharDate.java
+++ b/exec/java-exec/src/main/codegen/templates/CastVarCharDate.java
@@ -18,7 +18,7 @@
 <@pp.dropOutputFile />
 
 <#list cast.types as type>
-<#if type.major == "VarCharDate" || type.major == "VarBinaryDate">  <#-- Template to convert from VarChar/ VarBinary to Date, Time, TimeStamp, TimeStampTZ -->
+<#if type.major == "VarCharDate" || type.major == "VarBinaryDate">  <#-- Template to convert from VarChar/ VarBinary to Date, Time, TimeStamp -->
 
 <@pp.changeOutputFile name="/org/apache/drill/exec/expr/fn/impl/gcast/Cast${type.from}To${type.to}.java" />
 
@@ -69,12 +69,6 @@ public class Cast${type.from}To${type.to} implements DrillSimpleFunc {
       org.joda.time.format.DateTimeFormatter f = org.apache.drill.exec.expr.fn.impl.DateUtility.getDateTimeFormatter();
       out.value = org.joda.time.DateTime.parse(input, f).withZoneRetainFields(org.joda.time.DateTimeZone.UTC).getMillis();
 
-      <#elseif type.to == "TimeStampTZ">
-      org.joda.time.format.DateTimeFormatter f = org.apache.drill.exec.expr.fn.impl.DateUtility.getDateTimeFormatter();
-      org.joda.time.DateTime dt = org.joda.time.DateTime.parse(input, f);
-      out.value = dt.getMillis();
-      out.index = org.apache.drill.exec.expr.fn.impl.DateUtility.getIndex(dt.getZone().toString());
-
       <#elseif type.to == "Time">
       org.joda.time.format.DateTimeFormatter f = org.apache.drill.exec.expr.fn.impl.DateUtility.getTimeFormatter();
       out.value = (int) ((f.parseDateTime(input)).withZoneRetainFields(org.joda.time.DateTimeZone.UTC).getMillis());

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/codegen/templates/ConvertToNullableHolder.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/ConvertToNullableHolder.java b/exec/java-exec/src/main/codegen/templates/ConvertToNullableHolder.java
index 68595fc..045c919 100644
--- a/exec/java-exec/src/main/codegen/templates/ConvertToNullableHolder.java
+++ b/exec/java-exec/src/main/codegen/templates/ConvertToNullableHolder.java
@@ -47,10 +47,7 @@ public class ${className} implements DrillSimpleFunc {
   public void eval() {
     output.isSet = 1;
 <#if type.major != "VarLen">
-  <#if (minor.class == "TimeStampTZ")>
-    output.value = input.value;
-    output.index = input.index;
-  <#elseif (minor.class == "Interval")>
+  <#if (minor.class == "Interval")>
     output.months = input.months;
     output.days = input.days;
     output.milliseconds = input.milliseconds;

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/codegen/templates/DateIntervalAggrFunctions1.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/DateIntervalAggrFunctions1.java b/exec/java-exec/src/main/codegen/templates/DateIntervalAggrFunctions1.java
index 56e37ce..e934167 100644
--- a/exec/java-exec/src/main/codegen/templates/DateIntervalAggrFunctions1.java
+++ b/exec/java-exec/src/main/codegen/templates/DateIntervalAggrFunctions1.java
@@ -80,12 +80,7 @@ public static class ${type.inputType}${aggrtype.className} implements DrillAggFu
 
 	  <#if aggrtype.funcName == "min">
 
-    <#if type.outputType == "TimeStampTZ">
-    if (in.value < value.value) {
-      value.value = in.value;
-      value.index = in.index;
-    }
-    <#elseif type.outputType == "Interval">
+    <#if type.outputType == "Interval">
 
     long inMS = (long) in.months * org.apache.drill.exec.expr.fn.impl.DateUtility.monthsToMillis+
                        in.days * (org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis) +
@@ -104,12 +99,7 @@ public static class ${type.inputType}${aggrtype.className} implements DrillAggFu
     value.value = Math.min(value.value, in.value);
     </#if>
 	  <#elseif aggrtype.funcName == "max">
-    <#if type.outputType == "TimeStampTZ">
-    if (in.value < value.value) {
-      value.value = in.value;
-      value.index = in.index;
-    }
-    <#elseif type.outputType == "Interval">
+    <#if type.outputType == "Interval">
     long inMS = (long) in.months * org.apache.drill.exec.expr.fn.impl.DateUtility.monthsToMillis+
                        in.days * (org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis) +
                        in.milliseconds;

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateDateArithmeticFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateDateArithmeticFunctions.java b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateDateArithmeticFunctions.java
index a550a69..5fb2136 100644
--- a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateDateArithmeticFunctions.java
+++ b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateDateArithmeticFunctions.java
@@ -62,16 +62,6 @@ public static class G${type}Difference implements DrillSimpleFunc {
         long difference = (left.value - right.value);
         out.milliseconds = (int) (difference % org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis);
         out.days = (int) (difference / org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis);
-        <#elseif type == "TimeStampTZ">
-        if (left.index != right.index) {
-            // The two inputs are in different time zones convert one of them
-            org.joda.time.DateTime leftInput = new org.joda.time.DateTime(left.value, org.joda.time.DateTimeZone.forID(org.apache.drill.exec.expr.fn.impl.DateUtility.timezoneList[left.index]));
-            // convert left timestamp to the time zone of the right timestamp
-            left.value = (leftInput.withZone(org.joda.time.DateTimeZone.forID(org.apache.drill.exec.expr.fn.impl.DateUtility.timezoneList[right.index]))).getMillis();
-        }
-        long difference = (left.value - right.value);
-        out.milliseconds = (int) (difference % org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis);
-        out.days = (int) (difference / org.apache.drill.exec.expr.fn.impl.DateUtility.daysToStandardMillis);
         </#if>
     }
 }

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateIntervalArithmeticFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateIntervalArithmeticFunctions.java b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateIntervalArithmeticFunctions.java
index 87470d5..50d869e 100644
--- a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateIntervalArithmeticFunctions.java
+++ b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateIntervalArithmeticFunctions.java
@@ -21,7 +21,7 @@
 <#list dateIntervalFunc.dates as datetype>
 <#list dateIntervalFunc.intervals as intervaltype>
 
-<#if datetype == "Date" || datetype == "TimeStamp" || datetype == "TimeStampTZ">
+<#if datetype == "Date" || datetype == "TimeStamp">
 <@pp.changeOutputFile name="/org/apache/drill/exec/expr/fn/impl/${datetype}${intervaltype}Functions.java" />
 
 <#include "/@includes/license.ftl" />
@@ -49,7 +49,7 @@ public class ${datetype}${intervaltype}Functions {
 <#macro dateIntervalArithmeticBlock left right temp op output intervaltype datetype>
 
     <#-- Throw exception if we are adding integer to a TIMESTAMP -->
-    <#if (datetype == "TimeStamp" || datetype == "TimeStampTZ") && (intervaltype == "Int" || intervaltype == "BigInt")>
+    <#if (datetype == "TimeStamp") && (intervaltype == "Int" || intervaltype == "BigInt")>
     if (1 == 1) {
         /* Since this will be included in the run time generated code, there might be other logic that follows this
          * if the exception is raised without a condition, we will hit compilation issues while compiling run time code
@@ -73,11 +73,6 @@ public class ${datetype}${intervaltype}Functions {
     ${temp}.addDays((int) ${right}.value <#if op == '-'> * -1 </#if>);
     </#if>
 
-    <#-- copy the time zone index if its a timestamp -->
-    <#if datetype == "TimeStampTZ">
-    ${output}.index = ${left}.index;
-    </#if>
-
     ${output}.value = ${temp}.getMillis();
     </#if>
 </#macro>
@@ -93,13 +88,8 @@ public class ${datetype}${intervaltype}Functions {
     <#else>
     @Output ${datetype}Holder out;
     </#if>
-
         public void setup() {
-            <#if datetype == "TimeStampTZ">
-            temp = new org.joda.time.MutableDateTime(org.joda.time.DateTimeZone.forID(org.apache.drill.exec.expr.fn.impl.DateUtility.timezoneList[left.index]));
-            <#else>
             temp = new org.joda.time.MutableDateTime(org.joda.time.DateTimeZone.UTC);
-            </#if>
         }
 
         public void eval() {
@@ -121,11 +111,7 @@ public class ${datetype}${intervaltype}Functions {
     @Output ${datetype}Holder out;
     </#if>
         public void setup() {
-            <#if datetype == "TimeStampTZ">
-            temp = new org.joda.time.MutableDateTime(org.joda.time.DateTimeZone.forID(org.apache.drill.exec.expr.fn.impl.DateUtility.timezoneList[left.index]));
-            <#else>
             temp = new org.joda.time.MutableDateTime(org.joda.time.DateTimeZone.UTC);
-            </#if>
         }
 
         public void eval() {
@@ -143,11 +129,7 @@ public class ${datetype}${intervaltype}Functions {
     @Output ${datetype}Holder out;
 
         public void setup() {
-            <#if datetype == "TimeStampTZ">
-            temp = new org.joda.time.MutableDateTime(org.joda.time.DateTimeZone.forID(org.apache.drill.exec.expr.fn.impl.DateUtility.timezoneList[left.index]));
-            <#else>
             temp = new org.joda.time.MutableDateTime(org.joda.time.DateTimeZone.UTC);
-            </#if>
         }
 
         public void eval() {

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateToCharFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateToCharFunctions.java b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateToCharFunctions.java
index 4cf63dc..22c14de 100644
--- a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateToCharFunctions.java
+++ b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateToCharFunctions.java
@@ -66,9 +66,6 @@ public class G${type}ToChar implements DrillSimpleFunc {
 
     public void eval() {
         temp.setMillis(left.value);
-        <#if type == "TimeStampTZ">
-        temp.setZoneRetainFields(org.joda.time.DateTimeZone.forID(org.apache.drill.exec.expr.fn.impl.DateUtility.timezoneList[left.index]));
-        </#if>
 
         // print current value in the desired format
         String str = format.print(temp);

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateTruncFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateTruncFunctions.java b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateTruncFunctions.java
index 4c60c25..5ffff24 100644
--- a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateTruncFunctions.java
+++ b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/DateTruncFunctions.java
@@ -68,8 +68,8 @@ public static class G${type}DateTrunc implements DrillSimpleFunc {
         else if (org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(left.start, left.end, left.buffer).equalsIgnoreCase("SECOND")) dateTime.setRounding(dateTime.getChronology().secondOfMinute());
         else
         </#if>
-        <#if type == "TimeStamp" || type == "TimeStampTZ">
-            throw new UnsupportedOperationException("date_trunc function supports the following time units for TimeStamp(TZ): YEAR, MONTH, DAY, HOUR, MINUTE, SECOND");
+        <#if type == "TimeStamp">
+            throw new UnsupportedOperationException("date_trunc function supports the following time units for TimeStamp: YEAR, MONTH, DAY, HOUR, MINUTE, SECOND");
         out.value = dateTime.getMillis();
         <#elseif type == "Date">
             throw new UnsupportedOperationException("date_trunc function supports the following time units for Date: YEAR, MONTH, DAY");

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/Extract.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/Extract.java b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/Extract.java
index 857fece..e205247 100644
--- a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/Extract.java
+++ b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/Extract.java
@@ -33,7 +33,7 @@ public class ${className} {
 
 <#list extract.fromTypes as fromUnit>
 <#list extract.toTypes as toUnit>
-<#if fromUnit == "Date" || fromUnit == "Time" || fromUnit == "TimeStamp" || fromUnit == "TimeStampTZ">
+<#if fromUnit == "Date" || fromUnit == "Time" || fromUnit == "TimeStamp">
 <#if !(fromUnit == "Time" && (toUnit == "Year" || toUnit == "Month" || toUnit == "Day"))>
   @FunctionTemplate(name = "extract${toUnit}", scope = FunctionTemplate.FunctionScope.SIMPLE,
       nulls = FunctionTemplate.NullHandling.NULL_IF_NULL)
@@ -54,10 +54,6 @@ public class ${className} {
     public void eval() {
       dateTime.setMillis(in.value);
 
-    <#if fromUnit == "TimeStampTZ">
-      dateTime.setZoneRetainFields(org.joda.time.DateTimeZone.forID(org.apache.drill.exec.expr.fn.impl.DateUtility.timezoneList[in.index]));
-    </#if>
-
     <#if toUnit == "Second">
       out.value = dateTime.getSecondOfMinute();
       out.value += ((double) dateTime.getMillisOfSecond()) / 1000;

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/ToDateTypeFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/ToDateTypeFunctions.java b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/ToDateTypeFunctions.java
index baba963..c2e5a37 100644
--- a/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/ToDateTypeFunctions.java
+++ b/exec/java-exec/src/main/codegen/templates/DateIntervalFunctionTemplates/ToDateTypeFunctions.java
@@ -65,10 +65,6 @@ public class GTo${type} implements DrillSimpleFunc {
         out.value = (org.joda.time.DateMidnight.parse(input, format).withZoneRetainFields(org.joda.time.DateTimeZone.UTC)).getMillis();
         <#elseif type == "TimeStamp">
         out.value = org.joda.time.DateTime.parse(input, format).withZoneRetainFields(org.joda.time.DateTimeZone.UTC).getMillis();
-        <#elseif type == "TimeStampTZ">
-        org.joda.time.DateTime dt = org.joda.time.DateTime.parse(input, format);
-        out.value = dt.getMillis();
-        out.index = org.apache.drill.exec.expr.fn.impl.DateUtility.getIndex(dt.getZone().toString());
         <#elseif type == "Time">
         out.value = (int) ((format.parseDateTime(input)).withZoneRetainFields(org.joda.time.DateTimeZone.UTC).getMillis());
         </#if>

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/codegen/templates/FixedValueVectors.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/FixedValueVectors.java b/exec/java-exec/src/main/codegen/templates/FixedValueVectors.java
index 6cea8c8..b922767 100644
--- a/exec/java-exec/src/main/codegen/templates/FixedValueVectors.java
+++ b/exec/java-exec/src/main/codegen/templates/FixedValueVectors.java
@@ -260,26 +260,7 @@ public final class ${minor.class}Vector extends BaseDataValueVector implements F
       return data.slice(index * ${type.width}, ${type.width});
     }
 
-    <#if (minor.class == "TimeStampTZ")>
-    public void get(int index, ${minor.class}Holder holder){
-      holder.value = data.getLong(index * ${type.width});
-      holder.index = data.getInt((index * ${type.width})+ ${minor.millisecondsSize});
-    }
-
-    public void get(int index, Nullable${minor.class}Holder holder){
-      holder.isSet = 1;
-      holder.value = data.getLong(index * ${type.width});
-      holder.index = data.getInt((index * ${type.width})+ ${minor.millisecondsSize});
-    }
-
-    @Override
-    public ${friendlyType} getObject(int index) {
-      long l = data.getLong(index * ${type.width});
-      DateTime t = new DateTime(l);
-      return t;
-    }
-
-    <#elseif (minor.class == "Interval")>
+    <#if (minor.class == "Interval")>
     public void get(int index, ${minor.class}Holder holder){
 
       int offsetIndex = index * ${type.width};
@@ -566,36 +547,7 @@ public final class ${minor.class}Vector extends BaseDataValueVector implements F
      data.setBytes(index * ${type.width}, value, 0, ${type.width});
    }
 
-   <#if (minor.class == "TimeStampTZ")>
-   public void set(int index, long timestamp, int tzindex){
-     data.setLong((index * ${type.width}), timestamp);
-     data.setInt(((index * ${type.width}) + ${minor.millisecondsSize}), tzindex);
-   }
-   
-   public void set(int index, ${minor.class}Holder holder){
-     set(index, holder.value, holder.index);
-   }
-
-   public void set(int index, Nullable${minor.class}Holder holder){
-     set(index, holder.value, holder.index);
-   }
-
-   public void setSafe(int index, long timestamp, int tzindex){
-     if(index >= getValueCapacity()) {
-       reAlloc();
-     }
-     set(index, timestamp, tzindex);
-   }
-   
-   public void setSafe(int index, ${minor.class}Holder holder){
-     setSafe(index, holder.value, holder.index);
-   }
-
-   public void setSafe(int index, Nullable${minor.class}Holder holder){
-     setSafe(index, holder.value, holder.index);
-   }
-   
-   <#elseif (minor.class == "Interval")>
+  <#if (minor.class == "Interval")>
    public void set(int index, int months, int days, int milliseconds){
      int offsetIndex = index * ${type.width};
      data.setInt(offsetIndex, months);

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/codegen/templates/JsonOutputRecordWriter.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/JsonOutputRecordWriter.java b/exec/java-exec/src/main/codegen/templates/JsonOutputRecordWriter.java
index f0ddde2..1d0dc9d 100644
--- a/exec/java-exec/src/main/codegen/templates/JsonOutputRecordWriter.java
+++ b/exec/java-exec/src/main/codegen/templates/JsonOutputRecordWriter.java
@@ -132,7 +132,6 @@ public abstract class JSONOutputRecordWriter extends AbstractRecordWriter implem
               minor.class == "Time" ||
               minor.class == "TimeStamp" ||
               minor.class == "TimeTZ" ||
-              minor.class == "TimeStampTZ" ||
               minor.class == "IntervalDay" ||
               minor.class == "Interval" ||
               minor.class == "VarChar" ||

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/codegen/templates/NullableValueVectors.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/NullableValueVectors.java b/exec/java-exec/src/main/codegen/templates/NullableValueVectors.java
index 1618a99..2ec7492 100644
--- a/exec/java-exec/src/main/codegen/templates/NullableValueVectors.java
+++ b/exec/java-exec/src/main/codegen/templates/NullableValueVectors.java
@@ -588,7 +588,7 @@ public final class ${className} extends BaseValueVector implements <#if type.maj
       <#if type.major == "VarLen">lastSet = index;</#if>
     }
     
-    <#if !(type.major == "VarLen" || minor.class == "Decimal28Sparse" || minor.class == "Decimal38Sparse" || minor.class == "Decimal28Dense" || minor.class == "Decimal38Dense" || minor.class == "TimeStampTZ" || minor.class == "Interval" || minor.class == "IntervalDay")>
+    <#if !(type.major == "VarLen" || minor.class == "Decimal28Sparse" || minor.class == "Decimal38Sparse" || minor.class == "Decimal28Dense" || minor.class == "Decimal38Dense" || minor.class == "Interval" || minor.class == "IntervalDay")>
       public void setSafe(int index, ${minor.javaType!type.javaType} value) {
         <#if type.major == "VarLen">
         fillEmpties(index);

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/codegen/templates/ParquetOutputRecordWriter.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/ParquetOutputRecordWriter.java b/exec/java-exec/src/main/codegen/templates/ParquetOutputRecordWriter.java
index 80f3633..0d24041 100644
--- a/exec/java-exec/src/main/codegen/templates/ParquetOutputRecordWriter.java
+++ b/exec/java-exec/src/main/codegen/templates/ParquetOutputRecordWriter.java
@@ -203,7 +203,6 @@ public abstract class ParquetOutputRecordWriter extends AbstractRecordWriter imp
       </#if>
   <#elseif
         minor.class == "TimeTZ" ||
-        minor.class == "TimeStampTZ" ||
         minor.class == "IntervalDay" ||
         minor.class == "Interval" ||
         minor.class == "Decimal28Dense" ||

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/codegen/templates/ParquetTypeHelper.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/ParquetTypeHelper.java b/exec/java-exec/src/main/codegen/templates/ParquetTypeHelper.java
index 5dbc860..6ac488d 100644
--- a/exec/java-exec/src/main/codegen/templates/ParquetTypeHelper.java
+++ b/exec/java-exec/src/main/codegen/templates/ParquetTypeHelper.java
@@ -76,7 +76,6 @@ public class ParquetTypeHelper {
                     typeMap.put(MinorType.${minor.class?upper_case}, PrimitiveTypeName.BOOLEAN);
     <#elseif
             minor.class == "TimeTZ" ||
-            minor.class == "TimeStampTZ" ||
             minor.class == "IntervalDay" ||
             minor.class == "Interval" ||
             minor.class == "Decimal28Dense" ||

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/codegen/templates/SqlAccessors.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/SqlAccessors.java b/exec/java-exec/src/main/codegen/templates/SqlAccessors.java
index b569185..3039e5c 100644
--- a/exec/java-exec/src/main/codegen/templates/SqlAccessors.java
+++ b/exec/java-exec/src/main/codegen/templates/SqlAccessors.java
@@ -45,7 +45,7 @@ public class ${name}Accessor extends AbstractSqlAccessor{
     this.ac = vector.getAccessor();
   }
 
-  <#if minor.class != "TimeStampTZ" && minor.class != "TimeStamp" && minor.class != "Time" && minor.class != "Date">
+  <#if minor.class != "TimeStamp" && minor.class != "Time" && minor.class != "Date">
   public Object getObject(int index){
     return ac.getObject(index);
   }
@@ -103,16 +103,7 @@ public class ${name}Accessor extends AbstractSqlAccessor{
   </#switch>
 
   <#else>
-  <#if minor.class == "TimeStampTZ">
-  public Object getObject(int index) {
-    return getTimestamp(index);
-  }
-
-  @Override
-  public Timestamp getTimestamp(int index) {
-    return new Timestamp(ac.getObject(index).getMillis());
-  }
-  <#elseif minor.class == "Interval" || minor.class == "IntervalDay" || minor.class == "IntervalYear">
+  <#if minor.class == "Interval" || minor.class == "IntervalDay" || minor.class == "IntervalYear">
   @Override
   public String getString(int index) {
       return String.valueOf(ac.getAsStringBuilder(index));

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/codegen/templates/StringOutputRecordWriter.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/codegen/templates/StringOutputRecordWriter.java b/exec/java-exec/src/main/codegen/templates/StringOutputRecordWriter.java
index 070ed7b..f704cca 100644
--- a/exec/java-exec/src/main/codegen/templates/StringOutputRecordWriter.java
+++ b/exec/java-exec/src/main/codegen/templates/StringOutputRecordWriter.java
@@ -127,7 +127,6 @@ public abstract class StringOutputRecordWriter implements RecordWriter {
         minor.class == "Time" ||
         minor.class == "TimeTZ" ||
         minor.class == "TimeStamp" ||
-        minor.class == "TimeStampTZ" ||
         minor.class == "IntervalYear" ||
         minor.class == "IntervalDay" ||
         minor.class == "Interval" ||

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/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 ba5372f..d387b74 100644
--- a/exec/java-exec/src/main/codegen/templates/TypeHelper.java
+++ b/exec/java-exec/src/main/codegen/templates/TypeHelper.java
@@ -308,7 +308,7 @@ public class TypeHelper {
 <#list vv.types as type>
   <#list type.minor as minor>
     case ${minor.class?upper_case} :
-      <#if minor.class?starts_with("Var") || minor.class == "TimeStampTZ" || minor.class == "IntervalDay" || minor.class == "Interval" ||
+      <#if minor.class?starts_with("Var") || minor.class == "IntervalDay" || minor.class == "Interval" ||
         minor.class?starts_with("Decimal28") ||  minor.class?starts_with("Decimal38")>
         switch (type.getMode()) {
           case REQUIRED:

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/java/org/apache/drill/exec/compile/bytecode/ScalarReplacementTypes.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/compile/bytecode/ScalarReplacementTypes.java b/exec/java-exec/src/main/java/org/apache/drill/exec/compile/bytecode/ScalarReplacementTypes.java
index 93f4e0d..b52eb0c 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/compile/bytecode/ScalarReplacementTypes.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/compile/bytecode/ScalarReplacementTypes.java
@@ -49,12 +49,10 @@ import org.apache.drill.exec.expr.holders.NullableIntervalHolder;
 import org.apache.drill.exec.expr.holders.NullableIntervalYearHolder;
 import org.apache.drill.exec.expr.holders.NullableTimeHolder;
 import org.apache.drill.exec.expr.holders.NullableTimeStampHolder;
-import org.apache.drill.exec.expr.holders.NullableTimeStampTZHolder;
 import org.apache.drill.exec.expr.holders.NullableVarBinaryHolder;
 import org.apache.drill.exec.expr.holders.NullableVarCharHolder;
 import org.apache.drill.exec.expr.holders.TimeHolder;
 import org.apache.drill.exec.expr.holders.TimeStampHolder;
-import org.apache.drill.exec.expr.holders.TimeStampTZHolder;
 import org.apache.drill.exec.expr.holders.VarBinaryHolder;
 import org.apache.drill.exec.expr.holders.VarCharHolder;
 
@@ -87,7 +85,6 @@ public class ScalarReplacementTypes {
         DateHolder.class,
         TimeHolder.class,
         TimeStampHolder.class,
-        TimeStampTZHolder.class,
         VarCharHolder.class,
         VarBinaryHolder.class,
         NullableBitHolder.class,
@@ -109,7 +106,6 @@ public class ScalarReplacementTypes {
         NullableDateHolder.class,
         NullableTimeHolder.class,
         NullableTimeStampHolder.class,
-        NullableTimeStampTZHolder.class
     };
 
     CLASSES = ImmutableSet.copyOf(classList);

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CastBigIntTimeStampTZ.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CastBigIntTimeStampTZ.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CastBigIntTimeStampTZ.java
deleted file mode 100644
index d8ba5f4..0000000
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/CastBigIntTimeStampTZ.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/**
- * 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.exec.expr.fn.impl;
-
-import org.apache.drill.exec.expr.DrillSimpleFunc;
-import org.apache.drill.exec.expr.annotations.FunctionTemplate;
-import org.apache.drill.exec.expr.annotations.FunctionTemplate.NullHandling;
-import org.apache.drill.exec.expr.annotations.Output;
-import org.apache.drill.exec.expr.annotations.Param;
-import org.apache.drill.exec.expr.annotations.Workspace;
-import org.apache.drill.exec.expr.holders.BigIntHolder;
-import org.apache.drill.exec.expr.holders.TimeStampTZHolder;
-
-@SuppressWarnings("unused")
-@FunctionTemplate(names = {"castTIMESTAMPTZ", "to_timestamptz"}, scope = FunctionTemplate.FunctionScope.SIMPLE, nulls= NullHandling.NULL_IF_NULL)
-public class CastBigIntTimeStampTZ implements DrillSimpleFunc {
-
-    @Param
-    BigIntHolder in;
-    @Workspace
-    int timeZoneIndex;
-    @Output
-    TimeStampTZHolder out;
-
-    @Override
-    public void setup() {
-        org.joda.time.DateTime temp = new org.joda.time.DateTime();
-
-        // Store the local time zone index
-        timeZoneIndex = org.apache.drill.exec.expr.fn.impl.DateUtility.getIndex(temp.getZone().toString());
-    }
-
-    @Override
-    public void eval() {
-        out.value = in.value;
-        out.index = timeZoneIndex;
-    }
-}

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/DateTypeFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/DateTypeFunctions.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/DateTypeFunctions.java
index 668c9ba..9c932d6 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/DateTypeFunctions.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/DateTypeFunctions.java
@@ -35,7 +35,6 @@ import org.apache.drill.exec.expr.holders.IntervalHolder;
 import org.apache.drill.exec.expr.holders.IntervalYearHolder;
 import org.apache.drill.exec.expr.holders.TimeHolder;
 import org.apache.drill.exec.expr.holders.TimeStampHolder;
-import org.apache.drill.exec.expr.holders.TimeStampTZHolder;
 import org.apache.drill.exec.expr.holders.VarCharHolder;
 import org.apache.drill.exec.ops.QueryDateTimeInfo;
 
@@ -158,38 +157,6 @@ public class DateTypeFunctions {
         }
     }
 
-    @FunctionTemplate(name = "timestamptztype", scope = FunctionTemplate.FunctionScope.SIMPLE, nulls = NullHandling.NULL_IF_NULL)
-    public static class TimeStampTZType implements DrillSimpleFunc {
-
-        @Param  BigIntHolder inputYears;
-        @Param  BigIntHolder inputMonths;
-        @Param  BigIntHolder inputDays;
-        @Param  BigIntHolder inputHours;
-        @Param  BigIntHolder inputMinutes;
-        @Param  BigIntHolder inputSeconds;
-        @Param  BigIntHolder inputMilliSeconds;
-        @Param  VarCharHolder inputTimeZone;
-        @Output TimeStampTZHolder out;
-
-        public void setup() {
-        }
-
-        public void eval() {
-
-            String timeZone = (org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(inputTimeZone.start, inputTimeZone.end, inputTimeZone.buffer));
-            out.value = ((new org.joda.time.MutableDateTime((int)inputYears.value,
-                                                            (int)inputMonths.value,
-                                                            (int)inputDays.value,
-                                                            (int)inputHours.value,
-                                                            (int)inputMinutes.value,
-                                                            (int)inputSeconds.value,
-                                                            (int)inputMilliSeconds.value,
-                                                            org.joda.time.DateTimeZone.forID(timeZone)))).getMillis();
-
-            out.index = org.apache.drill.exec.expr.fn.impl.DateUtility.getIndex(timeZone);
-        }
-    }
-
     @FunctionTemplate(name = "timetype", scope = FunctionTemplate.FunctionScope.SIMPLE, nulls = NullHandling.NULL_IF_NULL)
     public static class TimeType implements DrillSimpleFunc {
 
@@ -231,46 +198,6 @@ public class DateTypeFunctions {
 
     }
 
-    @FunctionTemplate(names = {"current_timestamp", "now", "statement_timestamp", "transaction_timestamp"}, scope = FunctionTemplate.FunctionScope.SIMPLE, nulls = NullHandling.NULL_IF_NULL)
-    public static class CurrentTimeStamp implements DrillSimpleFunc {
-        @Workspace long queryStartDate;
-        @Workspace int timezoneIndex;
-        @Output TimeStampTZHolder out;
-        @Inject QueryDateTimeInfo dateTime;
-
-        public void setup() {
-
-            int timeZoneIndex = dateTime.getRootFragmentTimeZone();
-            org.joda.time.DateTimeZone timeZone = org.joda.time.DateTimeZone.forID(org.apache.drill.exec.expr.fn.impl.DateUtility.getTimeZone(timeZoneIndex));
-            org.joda.time.DateTime now = new org.joda.time.DateTime(dateTime.getQueryStartTime(), timeZone);
-            queryStartDate = now.getMillis();
-            timezoneIndex = org.apache.drill.exec.expr.fn.impl.DateUtility.getIndex(now.getZone().toString());
-        }
-
-        public void eval() {
-            out.value = queryStartDate;
-            out.index = timezoneIndex;
-        }
-
-    }
-
-    @FunctionTemplate(name = "clock_timestamp", scope = FunctionTemplate.FunctionScope.SIMPLE, nulls = NullHandling.NULL_IF_NULL, isRandom = true)
-    public static class ClockTimeStamp implements DrillSimpleFunc {
-        @Workspace int timezoneIndex;
-        @Output TimeStampTZHolder out;
-
-        public void setup() {
-            org.joda.time.DateTime now = new org.joda.time.DateTime();
-            timezoneIndex = org.apache.drill.exec.expr.fn.impl.DateUtility.getIndex(now.getZone().toString());
-        }
-
-        public void eval() {
-            org.joda.time.DateTime now = new org.joda.time.DateTime();
-            out.value = now.getMillis();
-            out.index = timezoneIndex;
-        }
-    }
-
     @FunctionTemplate(name = "timeofday", scope = FunctionTemplate.FunctionScope.SIMPLE, nulls = NullHandling.NULL_IF_NULL, isRandom = true)
     public static class TimeOfDay implements DrillSimpleFunc {
         @Inject DrillBuf buffer;
@@ -289,7 +216,7 @@ public class DateTypeFunctions {
         }
     }
 
-    @FunctionTemplate(name = "localtimestamp", scope = FunctionTemplate.FunctionScope.SIMPLE, nulls = NullHandling.NULL_IF_NULL)
+    @FunctionTemplate(names = {"localtimestamp", "current_timestamp", "now", "statement_timestamp", "transaction_timestamp"}, scope = FunctionTemplate.FunctionScope.SIMPLE, nulls = NullHandling.NULL_IF_NULL)
     public static class LocalTimeStamp implements DrillSimpleFunc {
         @Workspace long queryStartDate;
         @Output TimeStampHolder out;

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/HashFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/HashFunctions.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/HashFunctions.java
index 46fed6f..28b0be7 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/HashFunctions.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/HashFunctions.java
@@ -44,13 +44,11 @@ import org.apache.drill.exec.expr.holders.NullableFloat8Holder;
 import org.apache.drill.exec.expr.holders.NullableIntHolder;
 import org.apache.drill.exec.expr.holders.NullableTimeHolder;
 import org.apache.drill.exec.expr.holders.NullableTimeStampHolder;
-import org.apache.drill.exec.expr.holders.NullableTimeStampTZHolder;
 import org.apache.drill.exec.expr.holders.NullableVar16CharHolder;
 import org.apache.drill.exec.expr.holders.NullableVarBinaryHolder;
 import org.apache.drill.exec.expr.holders.NullableVarCharHolder;
 import org.apache.drill.exec.expr.holders.TimeHolder;
 import org.apache.drill.exec.expr.holders.TimeStampHolder;
-import org.apache.drill.exec.expr.holders.TimeStampTZHolder;
 import org.apache.drill.exec.expr.holders.Var16CharHolder;
 import org.apache.drill.exec.expr.holders.VarBinaryHolder;
 import org.apache.drill.exec.expr.holders.VarCharHolder;
@@ -372,36 +370,6 @@ public class HashFunctions {
   }
 
   @FunctionTemplate(name = "hash", scope = FunctionScope.SIMPLE, nulls = FunctionTemplate.NullHandling.INTERNAL)
-  public static class TimeStampTZHash implements DrillSimpleFunc {
-    @Param  TimeStampTZHolder in;
-    @Output IntHolder out;
-
-    public void setup() {
-    }
-
-    public void eval() {
-      out.value = org.apache.drill.exec.expr.fn.impl.XXHash.hash32(in.value ^ in.index, 0);
-    }
-  }
-
-  @FunctionTemplate(name = "hash", scope = FunctionScope.SIMPLE, nulls = FunctionTemplate.NullHandling.INTERNAL)
-  public static class NullableTimeStampTZHash implements DrillSimpleFunc {
-    @Param  NullableTimeStampTZHolder in;
-    @Output IntHolder out;
-
-    public void setup() {
-    }
-
-    public void eval() {
-      if (in.isSet == 0) {
-        out.value = 0;
-      } else {
-        out.value = org.apache.drill.exec.expr.fn.impl.XXHash.hash32(in.value ^ in.index, 0);
-      }
-    }
-  }
-
-  @FunctionTemplate(name = "hash", scope = FunctionScope.SIMPLE, nulls = FunctionTemplate.NullHandling.INTERNAL)
   public static class Decimal9Hash implements DrillSimpleFunc {
     @Param  Decimal9Holder in;
     @Output IntHolder out;

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestDateFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestDateFunctions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestDateFunctions.java
index 1ecae19..67aa4dd 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestDateFunctions.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestDateFunctions.java
@@ -98,7 +98,6 @@ public class TestDateFunctions extends PopUnitTestBase {
 
         String[] expectedResults = {"P365D",
                                     "P-366DT-60S",
-                                    "PT10800S",
                                     "PT39600S"};
         testCommon(expectedResults, "/functions/date/date_difference_arithmetic.json", "/test_simple_date.json");
     }
@@ -136,8 +135,7 @@ public class TestDateFunctions extends PopUnitTestBase {
 
         String expectedResults[] = {"2008-Feb-23",
                                     "12 20 30",
-                                    "2008 Feb 23 12:00:00",
-                                    "2008-02-23 20:00:00 America/Los_Angeles"};
+                                    "2008 Feb 23 12:00:00"};
         testCommon(expectedResults, "/functions/date/to_char.json", "/test_simple_date.json");
     }
 

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/test/java/org/apache/drill/exec/fn/interp/ExpressionInterpreterTest.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/interp/ExpressionInterpreterTest.java b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/interp/ExpressionInterpreterTest.java
index 63dcdb4..4942185 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/interp/ExpressionInterpreterTest.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/interp/ExpressionInterpreterTest.java
@@ -33,7 +33,7 @@ import org.apache.drill.common.util.DrillStringUtils;
 import org.apache.drill.exec.expr.ExpressionTreeMaterializer;
 import org.apache.drill.exec.expr.TypeHelper;
 import org.apache.drill.exec.expr.fn.interpreter.InterpreterEvaluator;
-import org.apache.drill.exec.expr.holders.TimeStampTZHolder;
+import org.apache.drill.exec.expr.holders.TimeStampHolder;
 import org.apache.drill.exec.ops.FragmentContext;
 import org.apache.drill.exec.ops.QueryDateTimeInfo;
 import org.apache.drill.exec.pop.PopUnitTestBase;
@@ -131,16 +131,13 @@ public class ExpressionInterpreterTest  extends PopUnitTestBase {
     org.joda.time.DateTime     now = new org.joda.time.DateTime(dateTime.getQueryStartTime(), timeZone);
 
     long queryStartDate = now.getMillis();
-    int timezoneIndex = org.apache.drill.exec.expr.fn.impl.DateUtility.getIndex(now.getZone().toString());
 
-    TimeStampTZHolder out = new TimeStampTZHolder();
+    TimeStampHolder out = new TimeStampHolder();
 
     out.value = queryStartDate;
-    out.index = timezoneIndex;
 
     ByteBuffer buffer = ByteBuffer.allocate(12);
     buffer.putLong(out.value);
-    buffer.putInt(out.index);
     long l = buffer.getLong(0);
     DateTime t = new DateTime(l);
 

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestDateTypes.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestDateTypes.java b/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestDateTypes.java
index 33cc2b8..4cc82e4 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestDateTypes.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/record/vector/TestDateTypes.java
@@ -224,7 +224,6 @@ public class TestDateTypes extends PopUnitTestBase {
 
             String result[] = {"2008-02-27",
                                "2008-02-27 01:02:03.000",
-                               "2008-02-27 01:02:03.000 UTC",
                                "10:11:13.999",
                                "2 years 2 months 3 days 0:1:3.89"};
 

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/test/resources/functions/date/date_difference_arithmetic.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/functions/date/date_difference_arithmetic.json b/exec/java-exec/src/test/resources/functions/date/date_difference_arithmetic.json
index bd8386c..e215b7b 100644
--- a/exec/java-exec/src/test/resources/functions/date/date_difference_arithmetic.json
+++ b/exec/java-exec/src/test/resources/functions/date/date_difference_arithmetic.json
@@ -23,7 +23,6 @@
             exprs: [
               { ref: "Date1", expr: "cast('2008-2-23' as date) - cast('2007-2-23' as date)"},
               { ref: "TimeStamp1", expr: "cast('2008-2-23 12:00:00' as timestamp) - cast('2009-2-23 12:01:00' as timestamp) "},
-              { ref: "TimeStampTZ1", expr: "cast('2008-2-23 12:00:00 America/Los_Angeles' as timestamptz) - cast('2008-2-23 12:00:00 America/New_York' as timestamptz)"},
               { ref: "Time2", expr: "cast('12:20:30' as time) - cast('1:20:30' as time)"}
             ]
         },

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/test/resources/functions/date/to_char.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/functions/date/to_char.json b/exec/java-exec/src/test/resources/functions/date/to_char.json
index 0059401..57bee61 100644
--- a/exec/java-exec/src/test/resources/functions/date/to_char.json
+++ b/exec/java-exec/src/test/resources/functions/date/to_char.json
@@ -23,8 +23,7 @@
             exprs: [
               { ref: "Date1", expr: "to_char((cast('2008-2-23' as date)), 'yyyy-MMM-dd')"},
               { ref: "Time1", expr: "to_char(cast('12:20:30' as time), 'HH mm ss')"},
-              { ref: "TimeStamp2", expr: "to_char(cast('2008-2-23 12:00:00' as timestamp), 'yyyy MMM dd HH:mm:ss')"},
-              { ref: "TimeStampTZ1", expr: "to_char(cast('2008-2-23 12:00:00 America/Los_Angeles' as timestamptz), 'yyyy-MM-dd HH:mm:ss ZZZ')"}
+              { ref: "TimeStamp2", expr: "to_char(cast('2008-2-23 12:00:00' as timestamp), 'yyyy MMM dd HH:mm:ss')"}
             ]
         },
         {

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/java-exec/src/test/resources/record/vector/test_all_date_literals.json
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/resources/record/vector/test_all_date_literals.json b/exec/java-exec/src/test/resources/record/vector/test_all_date_literals.json
index ac4959a..657b016 100644
--- a/exec/java-exec/src/test/resources/record/vector/test_all_date_literals.json
+++ b/exec/java-exec/src/test/resources/record/vector/test_all_date_literals.json
@@ -23,7 +23,6 @@
             exprs: [
               {ref: "Date", expr: "cast(datetype(2008, 2, 27) as varchar(100))"},
               {ref: "TimeStamp", expr: "cast(timestamptype(2008, 2, 27, 1, 2, 3, 0) as varchar(100))"},
-              {ref: "TimeStampTZ", expr: "cast(timestamptztype(2008, 2, 27, 1, 2, 3, 0, 'UTC') as varchar(100))"},
               {ref: "Time", expr: "cast(timetype(10,11,13, 999) as varchar(100))"},
               {ref: "Interval", expr: "cast(intervaltype(2, 2, 3, 0, 1, 3, 89) as varchar(100))"}
             ]

http://git-wip-us.apache.org/repos/asf/drill/blob/8faa6642/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java
----------------------------------------------------------------------
diff --git a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java
index b627c38..682fca3 100644
--- a/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java
+++ b/exec/jdbc/src/test/java/org/apache/drill/jdbc/test/TestJdbcQuery.java
@@ -231,11 +231,10 @@ public class TestJdbcQuery extends JdbcTestQueryBase{
           Statement statement = connection.createStatement();
 
           // show files
-          ResultSet resultSet = statement.executeQuery("select timestamp '2008-2-23 12:23:23', date '2001-01-01', timestamptztype('2008-2-23 1:20:23 US/Pacific') from cp.`employee.json` limit 1");
+          ResultSet resultSet = statement.executeQuery("select timestamp '2008-2-23 12:23:23', date '2001-01-01' from cp.`employee.json` limit 1");
 
           assert (resultSet.getMetaData().getColumnType(1) == Types.TIMESTAMP);
           assert (resultSet.getMetaData().getColumnType(2) == Types.DATE);
-          assert (resultSet.getMetaData().getColumnType(3) == Types.TIMESTAMP);
 
           System.out.println(JdbcAssert.toString(resultSet));
           resultSet.close();


[3/7] drill git commit: DRILL-2279: Raise exception if schema change is encountered in hash and streaming aggregate

Posted by me...@apache.org.
DRILL-2279: Raise exception if schema change is encountered in hash and streaming aggregate


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

Branch: refs/heads/master
Commit: 7a56df134f0b43323173776861603ef5f786bb03
Parents: bfbc0e0
Author: Mehant Baid <me...@gmail.com>
Authored: Wed Feb 18 18:37:39 2015 -0800
Committer: Mehant Baid <me...@gmail.com>
Committed: Tue Mar 17 18:05:53 2015 -0700

----------------------------------------------------------------------
 .../drill/exec/physical/impl/aggregate/HashAggBatch.java  |  9 ++++-----
 .../exec/physical/impl/aggregate/StreamingAggBatch.java   | 10 ++++------
 2 files changed, 8 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/7a56df13/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/HashAggBatch.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/HashAggBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/HashAggBatch.java
index 5946d43..c29fbf2 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/HashAggBatch.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/HashAggBatch.java
@@ -134,11 +134,10 @@ public class HashAggBatch extends AbstractRecordBatch<HashAggregate> {
         IterOutcome outcome = aggregator.getOutcome();
         return aggregator.getOutcome();
       case UPDATE_AGGREGATOR:
-        aggregator = null;
-        if (!createAggregator()) {
-          return IterOutcome.STOP;
-        }
-        continue;
+        context.fail(new SchemaChangeException("Hash aggregate does not support schema changes"));
+        cleanup();
+        killIncoming(false);
+        return IterOutcome.STOP;
       default:
         throw new IllegalStateException(String.format("Unknown state %s.", out));
       }

http://git-wip-us.apache.org/repos/asf/drill/blob/7a56df13/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/StreamingAggBatch.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/StreamingAggBatch.java b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/StreamingAggBatch.java
index 4acf3d6..33d2c7a 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/StreamingAggBatch.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/physical/impl/aggregate/StreamingAggBatch.java
@@ -145,12 +145,10 @@ public class StreamingAggBatch extends AbstractRecordBatch<StreamingAggregate> {
         first = false;
         return outcome;
       case UPDATE_AGGREGATOR:
-        first = false;
-        aggregator = null;
-        if (!createAggregator()) {
-          return IterOutcome.STOP;
-      }
-      continue;
+        context.fail(new SchemaChangeException("Streaming aggregate does not support schema changes"));
+        cleanup();
+        killIncoming(false);
+        return IterOutcome.STOP;
       default:
         throw new IllegalStateException(String.format("Unknown state %s.", out));
       }


[2/7] drill git commit: DRILL-1757 Support for wildcards in repeated_contains()

Posted by me...@apache.org.
DRILL-1757 Support for wildcards in repeated_contains()


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

Branch: refs/heads/master
Commit: bfbc0e01423ab85f362013a03ef0f00e95cd721b
Parents: 151b9be
Author: vsowrirajan <vs...@maprtech.com>
Authored: Thu Feb 19 12:04:52 2015 -0800
Committer: Mehant Baid <me...@gmail.com>
Committed: Tue Mar 17 18:05:47 2015 -0700

----------------------------------------------------------------------
 .../expr/fn/impl/SimpleRepeatedFunctions.java   | 19 ++++----
 .../fn/impl/TestNewSimpleRepeatedFunctions.java | 49 ++++++++++++++++++++
 2 files changed, 59 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/bfbc0e01/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SimpleRepeatedFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SimpleRepeatedFunctions.java b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SimpleRepeatedFunctions.java
index 1bfcb45..253c92a 100644
--- a/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SimpleRepeatedFunctions.java
+++ b/exec/java-exec/src/main/java/org/apache/drill/exec/expr/fn/impl/SimpleRepeatedFunctions.java
@@ -326,26 +326,27 @@ public class SimpleRepeatedFunctions {
     @Param RepeatedVarCharHolder listToSearch;
     @Param VarCharHolder targetValue;
     @Workspace VarCharHolder currVal;
+    @Workspace java.util.regex.Matcher matcher;
 
     @Output BitHolder out;
 
     public void setup() {
       currVal = new VarCharHolder();
+      matcher = java.util.regex.Pattern.compile(
+          org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(targetValue.start,  targetValue.end,  targetValue.buffer)).matcher("");
     }
 
     public void eval() {
       for (int i = listToSearch.start; i < listToSearch.end; i++) {
         out.value = 0;
         listToSearch.vector.getAccessor().get(i, currVal);
-        if (org.apache.drill.exec.expr.fn.impl.ByteFunctionHelpers.compare(
-            currVal.buffer, currVal.start, currVal.end, targetValue.buffer, targetValue.start, targetValue.end) == 0 ) {
-          out.value = 1;
-          break;
-        }
-      }
+        String in = org.apache.drill.exec.expr.fn.impl.StringFunctionHelpers.toStringFromUTF8(currVal.start, currVal.end, currVal.buffer);
+        matcher.reset(in);
+          if(matcher.find()) {
+             out.value = 1;
+             break;
+          }
+       }
     }
-
   }
-
-
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/drill/blob/bfbc0e01/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestNewSimpleRepeatedFunctions.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestNewSimpleRepeatedFunctions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestNewSimpleRepeatedFunctions.java
new file mode 100644
index 0000000..05807d6
--- /dev/null
+++ b/exec/java-exec/src/test/java/org/apache/drill/exec/fn/impl/TestNewSimpleRepeatedFunctions.java
@@ -0,0 +1,49 @@
+/**
+ * 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.exec.fn.impl;
+
+import org.apache.drill.BaseTestQuery;
+import org.junit.Test;
+
+public class TestNewSimpleRepeatedFunctions extends BaseTestQuery {
+  @Test
+  public void testRepeatedContainsForWildCards() throws Exception {
+     testBuilder().
+       sqlQuery("select repeated_contains(topping, 'Choc*') from cp.`testRepeatedWrite.json`")
+       .ordered()
+       .baselineColumns("EXPR$0")
+       .baselineValues(true)
+       .baselineValues(true)
+       .baselineValues(true)
+       .baselineValues(true)
+       .baselineValues(false)
+       .build().run();
+
+     testBuilder().
+       sqlQuery("select repeated_contains(topping, 'Pow*') from cp.`testRepeatedWrite.json`")
+       .ordered()
+       .baselineColumns("EXPR$0")
+       .baselineValues(true)
+       .baselineValues(false)
+       .baselineValues(false)
+       .baselineValues(true)
+       .baselineValues(false)
+       .build().run();
+
+  }
+}
\ No newline at end of file