Repository: drill
Updated Branches:
  refs/heads/master 30ba97c17 -> af0aff8f4


DRILL-2361: Allow column aliases to include dots.


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

Branch: refs/heads/master
Commit: af0aff8f4b3786112ef5650a56a760654389d1fb
Parents: 30ba97c
Author: AdamPD <a...@pharmadata.net.au>
Authored: Thu Oct 1 17:54:04 2015 -0700
Committer: Aman Sinha <asi...@maprtech.com>
Committed: Fri Oct 2 12:06:38 2015 -0700

----------------------------------------------------------------------
 .../drill/common/expression/FieldReference.java |  2 +-
 .../exec/planner/physical/AggPrelBase.java      |  6 ++--
 .../drill/exec/planner/physical/JoinPrel.java   |  4 +--
 .../drill/exec/planner/physical/PrelUtil.java   |  2 +-
 .../java/org/apache/drill/TestBugFixes.java     | 33 ++++++++++++++++++++
 5 files changed, 40 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/drill/blob/af0aff8f/common/src/main/java/org/apache/drill/common/expression/FieldReference.java
----------------------------------------------------------------------
diff --git 
a/common/src/main/java/org/apache/drill/common/expression/FieldReference.java 
b/common/src/main/java/org/apache/drill/common/expression/FieldReference.java
index e1f7c4b..d97be14 100644
--- 
a/common/src/main/java/org/apache/drill/common/expression/FieldReference.java
+++ 
b/common/src/main/java/org/apache/drill/common/expression/FieldReference.java
@@ -107,7 +107,7 @@ public class FieldReference extends SchemaPath {
         JsonProcessingException {
       String ref = this._parseString(jp, ctxt);
       ref = ref.replace("`", "");
-      return new FieldReference(ref, ExpressionPosition.UNKNOWN);
+      return new FieldReference(ref, ExpressionPosition.UNKNOWN, false);
     }
 
   }

http://git-wip-us.apache.org/repos/asf/drill/blob/af0aff8f/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/AggPrelBase.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/AggPrelBase.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/AggPrelBase.java
index 0e5ea0e..732ff15 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/AggPrelBase.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/AggPrelBase.java
@@ -127,13 +127,13 @@ public abstract class AggPrelBase extends 
DrillAggregateRelBase implements Prel
     final List<String> fields = getRowType().getFieldNames();
 
     for (int group : BitSets.toIter(groupSet)) {
-      FieldReference fr = new FieldReference(childFields.get(group), 
ExpressionPosition.UNKNOWN);
+      FieldReference fr = 
FieldReference.getWithQuotedRef(childFields.get(group));
       keys.add(new NamedExpression(fr, fr));
     }
 
     for (Ord<AggregateCall> aggCall : Ord.zip(aggCalls)) {
       int aggExprOrdinal = groupSet.cardinality() + aggCall.i;
-      FieldReference ref = new FieldReference(fields.get(aggExprOrdinal));
+      FieldReference ref = 
FieldReference.getWithQuotedRef(fields.get(aggExprOrdinal));
       LogicalExpression expr = toDrill(aggCall.e, childFields);
       NamedExpression ne = new NamedExpression(expr, ref);
       aggExprs.add(ne);
@@ -169,7 +169,7 @@ public abstract class AggPrelBase extends 
DrillAggregateRelBase implements Prel
   protected LogicalExpression toDrill(AggregateCall call, List<String> fn) {
     List<LogicalExpression> args = Lists.newArrayList();
     for (Integer i : call.getArgList()) {
-      args.add(new FieldReference(fn.get(i)));
+      args.add(FieldReference.getWithQuotedRef(fn.get(i)));
     }
 
     // for count(1).

http://git-wip-us.apache.org/repos/asf/drill/blob/af0aff8f/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/JoinPrel.java
----------------------------------------------------------------------
diff --git 
a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/JoinPrel.java
 
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/JoinPrel.java
index 45e8bc0..6df2949 100644
--- 
a/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/JoinPrel.java
+++ 
b/exec/java-exec/src/main/java/org/apache/drill/exec/planner/physical/JoinPrel.java
@@ -144,8 +144,8 @@ public abstract class JoinPrel extends DrillJoinRelBase 
implements Prel{
         }
 
       }
-      conditions.add(new JoinCondition(comp1.getKind().toString(), new 
FieldReference(leftFields.get(pair.left)),
-          new FieldReference(rightFields.get(pair.right))));
+      conditions.add(new JoinCondition(comp1.getKind().toString(), 
FieldReference.getWithQuotedRef(leftFields.get(pair.left)),
+          FieldReference.getWithQuotedRef(rightFields.get(pair.right))));
     }
 
   }

http://git-wip-us.apache.org/repos/asf/drill/blob/af0aff8f/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 d63bf54..ae70a50 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
@@ -66,7 +66,7 @@ public class PrelUtil {
     final List<String> childFields = rowType.getFieldNames();
 
     for (RelFieldCollation fc: collation.getFieldCollations() ) {
-      FieldReference fr = new 
FieldReference(childFields.get(fc.getFieldIndex()), ExpressionPosition.UNKNOWN);
+      FieldReference fr = new 
FieldReference(childFields.get(fc.getFieldIndex()), ExpressionPosition.UNKNOWN, 
false);
       orderExpr.add(new Ordering(fc.getDirection(), fr, fc.nullDirection));
     }
 

http://git-wip-us.apache.org/repos/asf/drill/blob/af0aff8f/exec/java-exec/src/test/java/org/apache/drill/TestBugFixes.java
----------------------------------------------------------------------
diff --git a/exec/java-exec/src/test/java/org/apache/drill/TestBugFixes.java 
b/exec/java-exec/src/test/java/org/apache/drill/TestBugFixes.java
index b5ed1d1..202ed2a 100644
--- a/exec/java-exec/src/test/java/org/apache/drill/TestBugFixes.java
+++ b/exec/java-exec/src/test/java/org/apache/drill/TestBugFixes.java
@@ -111,4 +111,37 @@ public class TestBugFixes extends BaseTestQuery {
     test("select * from cp.`tpch/nation.parquet` n left outer join 
cp.`tpch/region.parquet` r on n.n_regionkey = r.r_regionkey and r.r_name not 
like '%ASIA' order by r.r_name;");
   }
 
+  @Test
+  public void testDRILL2361_AggColumnAliasWithDots() throws Exception {
+    testBuilder()
+      .sqlQuery("select count(*) as `test.alias` from cp.`employee.json`")
+      .unOrdered()
+      .baselineColumns("`test.alias`")
+      .baselineValues(1155L)
+      .build().run();
+  }
+
+  @Test
+  public void testDRILL2361_SortColumnAliasWithDots() throws Exception {
+    testBuilder()
+            .sqlQuery("select o_custkey as `x.y.z` from 
cp.`tpch/orders.parquet` where o_orderkey < 5 order by `x.y.z`")
+            .unOrdered()
+            .baselineColumns("`x.y.z`")
+            .baselineValues(370)
+            .baselineValues(781)
+            .baselineValues(1234)
+            .baselineValues(1369)
+            .build().run();
+  }
+
+  @Test
+  public void testDRILL2361_JoinColumnAliasWithDots() throws Exception {
+    testBuilder()
+            .sqlQuery("select count(*) as cnt from (select o_custkey as `x.y` 
from cp.`tpch/orders.parquet`) o inner join cp.`tpch/customer.parquet` c on 
o.`x.y` = c.c_custkey")
+            .unOrdered()
+            .baselineColumns("cnt")
+            .baselineValues(15000L)
+            .build().run();
+  }
+
 }

Reply via email to