You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by sa...@apache.org on 2017/01/31 19:47:59 UTC

phoenix git commit: PHOENIX-3589 Aggregate query is not blocked when projected columns are not part of group by

Repository: phoenix
Updated Branches:
  refs/heads/encodecolumns2 728829663 -> 315057bf0


PHOENIX-3589 Aggregate query is not blocked when projected columns are not part of group by


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

Branch: refs/heads/encodecolumns2
Commit: 315057bf0a301c5c6836db2dcc3c93633728cee9
Parents: 7288296
Author: Samarth <sa...@salesforce.com>
Authored: Tue Jan 31 11:47:51 2017 -0800
Committer: Samarth <sa...@salesforce.com>
Committed: Tue Jan 31 11:47:51 2017 -0800

----------------------------------------------------------------------
 .../expression/SingleCellColumnExpression.java   | 12 +++++++++++-
 .../phoenix/compile/QueryCompilerTest.java       | 19 +++++++++++++++++++
 2 files changed, 30 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/315057bf/phoenix-core/src/main/java/org/apache/phoenix/expression/SingleCellColumnExpression.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/expression/SingleCellColumnExpression.java b/phoenix-core/src/main/java/org/apache/phoenix/expression/SingleCellColumnExpression.java
index e27f9d0..ba147fe 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/expression/SingleCellColumnExpression.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/expression/SingleCellColumnExpression.java
@@ -167,5 +167,15 @@ public class SingleCellColumnExpression extends KeyValueColumnExpression {
             return super.accept(visitor);
         }
     }
-    
+
+    @Override
+    public boolean equals(Object obj) {
+        return keyValueColumnExpression.equals(obj);
+    }
+
+    @Override
+    public int hashCode() {
+        return keyValueColumnExpression.hashCode();
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/phoenix/blob/315057bf/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java b/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java
index bc35e22..3179d84 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/compile/QueryCompilerTest.java
@@ -920,6 +920,25 @@ public class QueryCompilerTest extends BaseConnectionlessQueryTest {
         }
     }
 
+    @Test
+    public void testAggregateOnColumnsNotInGroupByForImmutableEncodedTable() throws Exception {
+        String tableName = generateUniqueName();
+        String ddl = "CREATE IMMUTABLE TABLE  " + tableName +
+                "  (a_string varchar not null, col1 integer, col2 integer" +
+                "  CONSTRAINT pk PRIMARY KEY (a_string))";
+        String query = "SELECT col1, max(a_string) from " + tableName + " group by col2";
+        try (Connection conn = DriverManager.getConnection(getUrl())) {
+            conn.createStatement().execute(ddl);
+            try {
+                PreparedStatement statement = conn.prepareStatement(query);
+                statement.executeQuery();
+                fail();
+            } catch (SQLException e) { // expected
+                assertEquals(SQLExceptionCode.AGGREGATE_WITH_NOT_GROUP_BY_COLUMN.getErrorCode(), e.getErrorCode());
+            }
+        }
+    }
+
     @Test 
     public void testRegexpSubstrSetScanKeys() throws Exception {
         // First test scan keys are set when the offset is 0 or 1.