DRILL-3993: Add unit tests for DRILL-4469 & DRILL-5768
Project: http://git-wip-us.apache.org/repos/asf/drill/repo Commit: http://git-wip-us.apache.org/repos/asf/drill/commit/90b5e639 Tree: http://git-wip-us.apache.org/repos/asf/drill/tree/90b5e639 Diff: http://git-wip-us.apache.org/repos/asf/drill/diff/90b5e639 Branch: refs/heads/master Commit: 90b5e6392d09db44ddef058b8c8caf88f52e23a2 Parents: d06a7cb Author: Volodymyr Vysotskyi <vvo...@gmail.com> Authored: Fri Jan 5 15:35:45 2018 +0200 Committer: Volodymyr Vysotskyi <vvo...@gmail.com> Committed: Tue Jan 16 12:10:13 2018 +0200 ---------------------------------------------------------------------- .../apache/drill/exec/TestWindowFunctions.java | 22 ++++++++++++++++++-- .../exec/fn/impl/TestAggregateFunctions.java | 15 +++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/drill/blob/90b5e639/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java ---------------------------------------------------------------------- diff --git a/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java b/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java index 3851228..db72ec2 100644 --- a/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java +++ b/exec/java-exec/src/test/java/org/apache/drill/exec/TestWindowFunctions.java @@ -1,4 +1,4 @@ -/** +/* * 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 @@ -20,7 +20,6 @@ package org.apache.drill.exec; import org.apache.drill.test.BaseTestQuery; import org.apache.drill.categories.UnlikelyTest; import org.apache.drill.common.exceptions.UserException; -import org.apache.drill.common.util.DrillFileUtils; import org.apache.drill.exec.proto.UserBitShared; import org.apache.drill.exec.work.foreman.SqlUnsupportedException; import org.apache.drill.exec.work.foreman.UnsupportedFunctionException; @@ -935,4 +934,23 @@ public class TestWindowFunctions extends BaseTestQuery { assert(ex.getMessage().contains("Expression 'n_nationkey' is not being grouped")); } } + + @Test // DRILL-4469 + public void testWindowOnSubqueryWithStar() throws Exception { + String query = "SELECT SUM(n_nationkey) OVER w as s\n" + + "FROM (SELECT * FROM cp.`tpch/nation.parquet`) subQry\n" + + "WINDOW w AS (PARTITION BY REGION ORDER BY n_nationkey)\n" + + "limit 1"; + + final String[] expectedPlan = {"Project.*\\$0=\\[ITEM\\(\\$1, 'n_nationkey'\\)\\].*"}; + PlanTestBase.testPlanMatchingPatterns(query, expectedPlan, new String[]{}); + + testBuilder() + .sqlQuery(query) + .ordered() + .baselineColumns("s") + .baselineValues(0L) + .build() + .run(); + } } http://git-wip-us.apache.org/repos/asf/drill/blob/90b5e639/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 ebad2f7..120f1e6 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 @@ -20,6 +20,7 @@ package org.apache.drill.exec.fn.impl; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import org.apache.commons.lang3.tuple.Pair; +import org.apache.drill.common.exceptions.UserRemoteException; import org.apache.drill.test.BaseTestQuery; import org.apache.drill.categories.OperatorTest; import org.apache.drill.PlanTestBase; @@ -42,6 +43,9 @@ import java.nio.file.Paths; import java.util.List; import java.util.Map; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + @Category({SqlFunctionTest.class, OperatorTest.class, PlannerTest.class}) public class TestAggregateFunctions extends BaseTestQuery { @@ -608,4 +612,15 @@ public class TestAggregateFunctions extends BaseTestQuery { .baselineValues(1L, 1L, 1L, 0L, 1L) .go(); } + + @Test // DRILL-5768 + public void testGroupByWithoutAggregate() throws Exception { + try { + test("select * from cp.`tpch/nation.parquet` group by n_regionkey"); + fail("Exception was not thrown"); + } catch (UserRemoteException e) { + assertTrue("No expected current \"Expression 'tpch/nation.parquet.**' is not being grouped\"", + e.getMessage().matches(".*Expression 'tpch/nation\\.parquet\\.\\*\\*' is not being grouped(.*\\n)*")); + } + } }