phoenix git commit: PHOENIX-3837 cherry pick PHOENIX-3837, PHOENIX-4361 for 4.x-HBase-1.1

2018-04-18 Thread ewang
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.1 716096498 -> 6b38c1e3d


PHOENIX-3837 cherry pick PHOENIX-3837,PHOENIX-4361 for 4.x-HBase-1.1


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

Branch: refs/heads/4.x-HBase-1.1
Commit: 6b38c1e3d47bbd41a45c36080b82e29ae1e5db42
Parents: 7160964
Author: aertoria 
Authored: Mon Nov 27 11:58:01 2017 -0800
Committer: aertoria 
Committed: Wed Apr 18 16:07:33 2018 -0700

--
 .../apache/phoenix/end2end/AlterTableIT.java|   2 +-
 .../phoenix/end2end/index/IndexMetadataIT.java  |  55 +
 phoenix-core/src/main/antlr3/PhoenixSQL.g   |   5 +-
 .../apache/phoenix/jdbc/PhoenixStatement.java   |  10 +-
 .../phoenix/parse/AddColumnStatement.java   |   2 +-
 .../phoenix/parse/AlterIndexStatement.java  |  14 ++
 .../apache/phoenix/parse/ParseNodeFactory.java  |   6 +-
 .../phoenix/query/ConnectionQueryServices.java  |   2 +
 .../query/ConnectionQueryServicesImpl.java  |  24 +-
 .../query/ConnectionlessQueryServicesImpl.java  |   7 +
 .../query/DelegateConnectionQueryServices.java  |   8 +-
 .../apache/phoenix/schema/MetaDataClient.java   | 244 +--
 12 files changed, 175 insertions(+), 204 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/6b38c1e3/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
index d999f6a..dd895dc 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
@@ -1080,7 +1080,7 @@ public class AlterTableIT extends ParallelStatsDisabledIT 
{
} catch (SQLException e) {

assertEquals(SQLExceptionCode.CANNOT_CREATE_TXN_TABLE_IF_TXNS_DISABLED.getErrorCode(),
 e.getErrorCode());
}
-   // altering a table to be transactional  should fail if 
transactions are disabled
+   // altering a table to be transactional should fail if 
transactions are disabled
conn.createStatement().execute("CREATE TABLE " + 
dataTableFullName + "(k INTEGER PRIMARY KEY, v VARCHAR)");
try {
conn.createStatement().execute("ALTER TABLE " + 
dataTableFullName + " SET TRANSACTIONAL=true");

http://git-wip-us.apache.org/repos/asf/phoenix/blob/6b38c1e3/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
index 0ce36dd..986c317 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
@@ -674,4 +674,59 @@ public class IndexMetadataIT extends 
ParallelStatsDisabledIT {
 conn.close();
 }
 }
+
+
+
+@Test
+public void testIndexAlterPhoenixProperty() throws Exception {
+Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+Connection conn = DriverManager.getConnection(getUrl(), props);
+String testTable = generateUniqueName();
+
+
+String ddl = "create table " + testTable  + " (k varchar primary key, 
v1 varchar)";
+Statement stmt = conn.createStatement();
+stmt.execute(ddl);
+String indexName = "IDX_" + generateUniqueName();
+
+ddl = "CREATE INDEX " + indexName + " ON " + testTable  + " (v1) ";
+stmt.execute(ddl);
+conn.createStatement().execute("ALTER INDEX "+indexName+" ON " + 
testTable +" ACTIVE SET GUIDE_POSTS_WIDTH = 10");
+
+ResultSet rs = conn.createStatement().executeQuery(
+"select GUIDE_POSTS_WIDTH from SYSTEM.\"CATALOG\" where 
TABLE_NAME='" + indexName + "'");assertTrue(rs.next());
+assertEquals(10,rs.getInt(1));
+
+conn.createStatement().execute("ALTER INDEX "+indexName+" ON " + 
testTable +" ACTIVE SET GUIDE_POSTS_WIDTH = 20");
+rs = conn.createStatement().executeQuery(
+"select GUIDE_POSTS_WIDTH from SYSTEM.\"CATALOG\" where 
TABLE_NAME='" + indexName + "'");assertTrue(rs.next());
+assertEquals(20,rs.getInt(1));
+

phoenix git commit: PHOENIX-4370 Surface hbase metrics from perconnection to global metrics

2018-03-14 Thread ewang
Repository: phoenix
Updated Branches:
  refs/heads/4.x-cdh5.11.2 430463e0f -> 25026b6cc


PHOENIX-4370 Surface hbase metrics from perconnection to global metrics

Signed-off-by: ethan wang 


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

Branch: refs/heads/4.x-cdh5.11.2
Commit: 25026b6cc90e4983d2f1a37aa04ec944a5c417e1
Parents: 430463e
Author: aertoria 
Authored: Sun Dec 17 13:33:56 2017 -0800
Committer: ethan wang 
Committed: Wed Mar 14 12:02:15 2018 -0700

--
 .../phoenix/monitoring/PhoenixMetricsIT.java| 24 -
 .../phoenix/iterate/ScanningResultIterator.java | 24 +
 .../phoenix/monitoring/GlobalClientMetrics.java | 27 ++--
 3 files changed, 72 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/25026b6c/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java
index 19afb96..e45ddcd 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java
@@ -29,6 +29,19 @@ import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_SELECT_SQ
 import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_SPOOL_FILE_COUNTER;
 import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_TASK_END_TO_END_TIME;
 import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_TASK_EXECUTION_TIME;
+
+import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_RPC_CALLS;
+import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_REMOTE_RPC_CALLS;
+import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_MILLS_BETWEEN_NEXTS;
+import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_NOT_SERVING_REGION_EXCEPTION;
+import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_BYTES_REGION_SERVER_RESULTS;
+import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_BYTES_IN_REMOTE_RESULTS;
+import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_SCANNED_REGIONS;
+import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_RPC_RETRIES;
+import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_REMOTE_RPC_RETRIES;
+import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_ROWS_SCANNED;
+import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_ROWS_FILTERED;
+
 import static org.apache.phoenix.monitoring.MetricType.MEMORY_CHUNK_BYTES;
 import static org.apache.phoenix.monitoring.MetricType.SCAN_BYTES;
 import static org.apache.phoenix.monitoring.MetricType.TASK_EXECUTED_COUNTER;
@@ -136,6 +149,11 @@ public class PhoenixMetricsIT extends 
BaseUniqueNamesOwnClusterIT {
 assertTrue(GLOBAL_QUERY_TIME.getMetric().getTotalSum() > 0);
 assertTrue(GLOBAL_TASK_END_TO_END_TIME.getMetric().getTotalSum() > 0);
 assertTrue(GLOBAL_TASK_EXECUTION_TIME.getMetric().getTotalSum() > 0);
+
+assertTrue(GLOBAL_HBASE_COUNT_RPC_CALLS.getMetric().getTotalSum() > 0);
+
assertTrue(GLOBAL_HBASE_COUNT_MILLS_BETWEEN_NEXTS.getMetric().getTotalSum() > 
0);
+
assertTrue(GLOBAL_HBASE_COUNT_BYTES_REGION_SERVER_RESULTS.getMetric().getTotalSum()
 > 0);
+
assertTrue(GLOBAL_HBASE_COUNT_SCANNED_REGIONS.getMetric().getTotalSum() > 0);
 }
 
 @Test
@@ -181,6 +199,11 @@ public class PhoenixMetricsIT extends 
BaseUniqueNamesOwnClusterIT {
 assertEquals(0, GLOBAL_FAILED_QUERY_COUNTER.getMetric().getTotalSum());
 assertEquals(0, GLOBAL_SPOOL_FILE_COUNTER.getMetric().getTotalSum());
 assertEquals(0, 
GLOBAL_MUTATION_BATCH_FAILED_COUNT.getMetric().getTotalSum());
+
+assertTrue(GLOBAL_HBASE_COUNT_RPC_CALLS.getMetric().getTotalSum() > 0);
+
assertTrue(GLOBAL_HBASE_COUNT_MILLS_BETWEEN_NEXTS.getMetric().getTotalSum() > 
0);
+
assertTrue(GLOBAL_HBASE_COUNT_BYTES_REGION_SERVER_RESULTS.getMetric().getTotalSum()
 > 0);
+
assertTrue(GLOBAL_HBASE_COUNT_SCANNED_REGIONS.getMetric().getTotalSum() > 0);
 }
 
 private static void resetGlobalMetrics() {
@@ -1075,5 +1098,4 @@ public class 

phoenix git commit: PHOENIX-4370 Surface hbase metrics from perconnection to global metrics

2018-03-14 Thread ewang
Repository: phoenix
Updated Branches:
  refs/heads/5.x-HBase-2.0 a6ba7fd6c -> 3f892a4ed


PHOENIX-4370 Surface hbase metrics from perconnection to global metrics

Signed-off-by: ethan wang 


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

Branch: refs/heads/5.x-HBase-2.0
Commit: 3f892a4ed78d48babc5a45f3fc4efc237a01ed5f
Parents: a6ba7fd
Author: aertoria 
Authored: Sun Dec 17 13:33:56 2017 -0800
Committer: ethan wang 
Committed: Wed Mar 14 11:52:56 2018 -0700

--
 .../phoenix/monitoring/PhoenixMetricsIT.java| 24 -
 .../phoenix/iterate/ScanningResultIterator.java | 24 +
 .../phoenix/monitoring/GlobalClientMetrics.java | 27 ++--
 3 files changed, 72 insertions(+), 3 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/3f892a4e/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java
index 19afb96..e45ddcd 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/monitoring/PhoenixMetricsIT.java
@@ -29,6 +29,19 @@ import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_SELECT_SQ
 import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_SPOOL_FILE_COUNTER;
 import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_TASK_END_TO_END_TIME;
 import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_TASK_EXECUTION_TIME;
+
+import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_RPC_CALLS;
+import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_REMOTE_RPC_CALLS;
+import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_MILLS_BETWEEN_NEXTS;
+import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_NOT_SERVING_REGION_EXCEPTION;
+import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_BYTES_REGION_SERVER_RESULTS;
+import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_BYTES_IN_REMOTE_RESULTS;
+import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_SCANNED_REGIONS;
+import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_RPC_RETRIES;
+import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_REMOTE_RPC_RETRIES;
+import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_ROWS_SCANNED;
+import static 
org.apache.phoenix.monitoring.GlobalClientMetrics.GLOBAL_HBASE_COUNT_ROWS_FILTERED;
+
 import static org.apache.phoenix.monitoring.MetricType.MEMORY_CHUNK_BYTES;
 import static org.apache.phoenix.monitoring.MetricType.SCAN_BYTES;
 import static org.apache.phoenix.monitoring.MetricType.TASK_EXECUTED_COUNTER;
@@ -136,6 +149,11 @@ public class PhoenixMetricsIT extends 
BaseUniqueNamesOwnClusterIT {
 assertTrue(GLOBAL_QUERY_TIME.getMetric().getTotalSum() > 0);
 assertTrue(GLOBAL_TASK_END_TO_END_TIME.getMetric().getTotalSum() > 0);
 assertTrue(GLOBAL_TASK_EXECUTION_TIME.getMetric().getTotalSum() > 0);
+
+assertTrue(GLOBAL_HBASE_COUNT_RPC_CALLS.getMetric().getTotalSum() > 0);
+
assertTrue(GLOBAL_HBASE_COUNT_MILLS_BETWEEN_NEXTS.getMetric().getTotalSum() > 
0);
+
assertTrue(GLOBAL_HBASE_COUNT_BYTES_REGION_SERVER_RESULTS.getMetric().getTotalSum()
 > 0);
+
assertTrue(GLOBAL_HBASE_COUNT_SCANNED_REGIONS.getMetric().getTotalSum() > 0);
 }
 
 @Test
@@ -181,6 +199,11 @@ public class PhoenixMetricsIT extends 
BaseUniqueNamesOwnClusterIT {
 assertEquals(0, GLOBAL_FAILED_QUERY_COUNTER.getMetric().getTotalSum());
 assertEquals(0, GLOBAL_SPOOL_FILE_COUNTER.getMetric().getTotalSum());
 assertEquals(0, 
GLOBAL_MUTATION_BATCH_FAILED_COUNT.getMetric().getTotalSum());
+
+assertTrue(GLOBAL_HBASE_COUNT_RPC_CALLS.getMetric().getTotalSum() > 0);
+
assertTrue(GLOBAL_HBASE_COUNT_MILLS_BETWEEN_NEXTS.getMetric().getTotalSum() > 
0);
+
assertTrue(GLOBAL_HBASE_COUNT_BYTES_REGION_SERVER_RESULTS.getMetric().getTotalSum()
 > 0);
+
assertTrue(GLOBAL_HBASE_COUNT_SCANNED_REGIONS.getMetric().getTotalSum() > 0);
 }
 
 private static void resetGlobalMetrics() {
@@ -1075,5 +1098,4 @@ public class 

phoenix git commit: PHOENIX-3837 Feature enabling to set property on an index with Alter statement PHOENIX-4361 Remove redundant argument in separateAndValidateProperties in CQSI pSigned-off-by: aerto

2018-02-23 Thread ewang
Repository: phoenix
Updated Branches:
  refs/heads/5.x-HBase-2.0 6c9855139 -> beb3a7676


PHOENIX-3837 Feature enabling to set property on an index with Alter statement
PHOENIX-4361 Remove redundant argument in separateAndValidateProperties in CQSI
pSigned-off-by: aertoria 


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

Branch: refs/heads/5.x-HBase-2.0
Commit: beb3a767690f4faafb6ee08ae0b14a5a8f3133d5
Parents: 6c98551
Author: aertoria 
Authored: Mon Nov 27 11:58:01 2017 -0800
Committer: aertoria 
Committed: Fri Feb 23 13:06:50 2018 -0800

--
 .../apache/phoenix/end2end/AlterTableIT.java|   2 +-
 .../phoenix/end2end/index/IndexMetadataIT.java  |  55 ++
 phoenix-core/src/main/antlr3/PhoenixSQL.g   |   5 +-
 .../apache/phoenix/jdbc/PhoenixStatement.java   |  10 +-
 .../phoenix/parse/AddColumnStatement.java   |   2 +-
 .../phoenix/parse/AlterIndexStatement.java  |  14 +
 .../apache/phoenix/parse/ParseNodeFactory.java  |   6 +-
 .../phoenix/query/ConnectionQueryServices.java  |   2 +
 .../query/ConnectionQueryServicesImpl.java  |  25 +-
 .../query/ConnectionlessQueryServicesImpl.java  |  10 +-
 .../query/DelegateConnectionQueryServices.java  |   8 +-
 .../apache/phoenix/schema/MetaDataClient.java   | 572 +--
 12 files changed, 530 insertions(+), 181 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/beb3a767/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
index cfc59bd..4e731c1 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
@@ -1081,7 +1081,7 @@ public class AlterTableIT extends ParallelStatsDisabledIT 
{
} catch (SQLException e) {

assertEquals(SQLExceptionCode.CANNOT_CREATE_TXN_TABLE_IF_TXNS_DISABLED.getErrorCode(),
 e.getErrorCode());
}
-   // altering a table to be transactional  should fail if 
transactions are disabled
+   // altering a table to be transactional should fail if 
transactions are disabled
conn.createStatement().execute("CREATE TABLE " + 
dataTableFullName + "(k INTEGER PRIMARY KEY, v VARCHAR)");
try {
conn.createStatement().execute("ALTER TABLE " + 
dataTableFullName + " SET TRANSACTIONAL=true");

http://git-wip-us.apache.org/repos/asf/phoenix/blob/beb3a767/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
index 0ce36dd..986c317 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
@@ -674,4 +674,59 @@ public class IndexMetadataIT extends 
ParallelStatsDisabledIT {
 conn.close();
 }
 }
+
+
+
+@Test
+public void testIndexAlterPhoenixProperty() throws Exception {
+Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+Connection conn = DriverManager.getConnection(getUrl(), props);
+String testTable = generateUniqueName();
+
+
+String ddl = "create table " + testTable  + " (k varchar primary key, 
v1 varchar)";
+Statement stmt = conn.createStatement();
+stmt.execute(ddl);
+String indexName = "IDX_" + generateUniqueName();
+
+ddl = "CREATE INDEX " + indexName + " ON " + testTable  + " (v1) ";
+stmt.execute(ddl);
+conn.createStatement().execute("ALTER INDEX "+indexName+" ON " + 
testTable +" ACTIVE SET GUIDE_POSTS_WIDTH = 10");
+
+ResultSet rs = conn.createStatement().executeQuery(
+"select GUIDE_POSTS_WIDTH from SYSTEM.\"CATALOG\" where 
TABLE_NAME='" + indexName + "'");assertTrue(rs.next());
+assertEquals(10,rs.getInt(1));
+
+conn.createStatement().execute("ALTER INDEX "+indexName+" ON " + 
testTable +" ACTIVE SET GUIDE_POSTS_WIDTH = 20");
+rs = conn.createStatement().executeQuery(
+"select GUIDE_POSTS_WIDTH 

phoenix git commit: PHOENIX-3837 Feature enabling to set property on an index with Alter statement

2017-12-07 Thread ewang
Repository: phoenix
Updated Branches:
  refs/heads/master ee728a4d1 -> 1c3387d0e


PHOENIX-3837 Feature enabling to set property on an index with Alter statement

Signed-off-by: aertoria 


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

Branch: refs/heads/master
Commit: 1c3387d0eb2fcec2423dda029aa65ca66f547416
Parents: ee728a4
Author: aertoria 
Authored: Mon Nov 27 11:58:01 2017 -0800
Committer: aertoria 
Committed: Thu Dec 7 11:51:17 2017 -0800

--
 .../apache/phoenix/end2end/AlterTableIT.java|   2 +-
 .../phoenix/end2end/index/IndexMetadataIT.java  |  55 ++
 phoenix-core/src/main/antlr3/PhoenixSQL.g   |   5 +-
 .../apache/phoenix/jdbc/PhoenixStatement.java   |  10 +-
 .../phoenix/parse/AddColumnStatement.java   |   2 +-
 .../phoenix/parse/AlterIndexStatement.java  |  14 +
 .../apache/phoenix/parse/ParseNodeFactory.java  |   6 +-
 .../phoenix/query/ConnectionQueryServices.java  |   2 +
 .../query/ConnectionQueryServicesImpl.java  |  20 +
 .../query/ConnectionlessQueryServicesImpl.java  |   7 +
 .../query/DelegateConnectionQueryServices.java  |   8 +-
 .../apache/phoenix/schema/MetaDataClient.java   | 566 +--
 12 files changed, 520 insertions(+), 177 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/1c3387d0/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
index 5265b09..17f08c4 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
@@ -1080,7 +1080,7 @@ public class AlterTableIT extends ParallelStatsDisabledIT 
{
} catch (SQLException e) {

assertEquals(SQLExceptionCode.CANNOT_CREATE_TXN_TABLE_IF_TXNS_DISABLED.getErrorCode(),
 e.getErrorCode());
}
-   // altering a table to be transactional  should fail if 
transactions are disabled
+   // altering a table to be transactional should fail if 
transactions are disabled
conn.createStatement().execute("CREATE TABLE " + 
dataTableFullName + "(k INTEGER PRIMARY KEY, v VARCHAR)");
try {
conn.createStatement().execute("ALTER TABLE " + 
dataTableFullName + " SET TRANSACTIONAL=true");

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1c3387d0/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
index 0ce36dd..986c317 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
@@ -674,4 +674,59 @@ public class IndexMetadataIT extends 
ParallelStatsDisabledIT {
 conn.close();
 }
 }
+
+
+
+@Test
+public void testIndexAlterPhoenixProperty() throws Exception {
+Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+Connection conn = DriverManager.getConnection(getUrl(), props);
+String testTable = generateUniqueName();
+
+
+String ddl = "create table " + testTable  + " (k varchar primary key, 
v1 varchar)";
+Statement stmt = conn.createStatement();
+stmt.execute(ddl);
+String indexName = "IDX_" + generateUniqueName();
+
+ddl = "CREATE INDEX " + indexName + " ON " + testTable  + " (v1) ";
+stmt.execute(ddl);
+conn.createStatement().execute("ALTER INDEX "+indexName+" ON " + 
testTable +" ACTIVE SET GUIDE_POSTS_WIDTH = 10");
+
+ResultSet rs = conn.createStatement().executeQuery(
+"select GUIDE_POSTS_WIDTH from SYSTEM.\"CATALOG\" where 
TABLE_NAME='" + indexName + "'");assertTrue(rs.next());
+assertEquals(10,rs.getInt(1));
+
+conn.createStatement().execute("ALTER INDEX "+indexName+" ON " + 
testTable +" ACTIVE SET GUIDE_POSTS_WIDTH = 20");
+rs = conn.createStatement().executeQuery(
+"select GUIDE_POSTS_WIDTH from SYSTEM.\"CATALOG\" where 
TABLE_NAME='" + indexName + "'");assertTrue(rs.next());
+   

phoenix git commit: PHOENIX-3837 Feature enabling to set property on an index with Alter statement

2017-12-07 Thread ewang
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 1df7aa5bb -> 794d42833


PHOENIX-3837 Feature enabling to set property on an index with Alter statement

Signed-off-by: aertoria 


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

Branch: refs/heads/4.x-HBase-0.98
Commit: 794d4283392fdf80471c51f1c2055845848d979e
Parents: 1df7aa5
Author: aertoria 
Authored: Mon Nov 27 11:58:01 2017 -0800
Committer: aertoria 
Committed: Thu Dec 7 09:18:05 2017 -0800

--
 .../apache/phoenix/end2end/AlterTableIT.java|   2 +-
 .../phoenix/end2end/index/IndexMetadataIT.java  |  55 ++
 phoenix-core/src/main/antlr3/PhoenixSQL.g   |   5 +-
 .../apache/phoenix/jdbc/PhoenixStatement.java   |  10 +-
 .../phoenix/parse/AddColumnStatement.java   |   2 +-
 .../phoenix/parse/AlterIndexStatement.java  |  14 +
 .../apache/phoenix/parse/ParseNodeFactory.java  |   6 +-
 .../phoenix/query/ConnectionQueryServices.java  |   2 +
 .../query/ConnectionQueryServicesImpl.java  |  20 +
 .../query/ConnectionlessQueryServicesImpl.java  |   7 +
 .../query/DelegateConnectionQueryServices.java  |   8 +-
 .../apache/phoenix/schema/MetaDataClient.java   | 566 +--
 12 files changed, 520 insertions(+), 177 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/794d4283/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
index c21b023..ab75d34 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AlterTableIT.java
@@ -1082,7 +1082,7 @@ public class AlterTableIT extends ParallelStatsDisabledIT 
{
} catch (SQLException e) {

assertEquals(SQLExceptionCode.CANNOT_CREATE_TXN_TABLE_IF_TXNS_DISABLED.getErrorCode(),
 e.getErrorCode());
}
-   // altering a table to be transactional  should fail if 
transactions are disabled
+   // altering a table to be transactional should fail if 
transactions are disabled
conn.createStatement().execute("CREATE TABLE " + 
dataTableFullName + "(k INTEGER PRIMARY KEY, v VARCHAR)");
try {
conn.createStatement().execute("ALTER TABLE " + 
dataTableFullName + " SET TRANSACTIONAL=true");

http://git-wip-us.apache.org/repos/asf/phoenix/blob/794d4283/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
index 0ce36dd..986c317 100644
--- 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
+++ 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/IndexMetadataIT.java
@@ -674,4 +674,59 @@ public class IndexMetadataIT extends 
ParallelStatsDisabledIT {
 conn.close();
 }
 }
+
+
+
+@Test
+public void testIndexAlterPhoenixProperty() throws Exception {
+Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+Connection conn = DriverManager.getConnection(getUrl(), props);
+String testTable = generateUniqueName();
+
+
+String ddl = "create table " + testTable  + " (k varchar primary key, 
v1 varchar)";
+Statement stmt = conn.createStatement();
+stmt.execute(ddl);
+String indexName = "IDX_" + generateUniqueName();
+
+ddl = "CREATE INDEX " + indexName + " ON " + testTable  + " (v1) ";
+stmt.execute(ddl);
+conn.createStatement().execute("ALTER INDEX "+indexName+" ON " + 
testTable +" ACTIVE SET GUIDE_POSTS_WIDTH = 10");
+
+ResultSet rs = conn.createStatement().executeQuery(
+"select GUIDE_POSTS_WIDTH from SYSTEM.\"CATALOG\" where 
TABLE_NAME='" + indexName + "'");assertTrue(rs.next());
+assertEquals(10,rs.getInt(1));
+
+conn.createStatement().execute("ALTER INDEX "+indexName+" ON " + 
testTable +" ACTIVE SET GUIDE_POSTS_WIDTH = 20");
+rs = conn.createStatement().executeQuery(
+"select GUIDE_POSTS_WIDTH from SYSTEM.\"CATALOG\" where 
TABLE_NAME='" + indexName + 

phoenix git commit: PHOENIX-4361: Remove redundant argument in separateAndValidateProperties in CQSI

2017-11-17 Thread ewang
Repository: phoenix
Updated Branches:
  refs/heads/5.x-HBase-2.0 8ab7cc142 -> 9e6987a92


PHOENIX-4361: Remove redundant argument in separateAndValidateProperties in CQSI

Signed-off-by: aertoria 


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

Branch: refs/heads/5.x-HBase-2.0
Commit: 9e6987a92e34e515a53f8cf9a9f696402ffc4434
Parents: 8ab7cc1
Author: Chinmay Kulkarni 
Authored: Wed Nov 15 18:31:20 2017 -0800
Committer: aertoria 
Committed: Fri Nov 17 11:37:37 2017 -0800

--
 .../org/apache/phoenix/query/ConnectionQueryServicesImpl.java   | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/9e6987a9/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index 8ab42d6..66e4661 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -1726,7 +1726,7 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
 Set tableDescriptors = Collections.emptySet();
 Set origTableDescriptors = Collections.emptySet();
 boolean nonTxToTx = false;
-Pair tableDescriptorPair = 
separateAndValidateProperties(table, stmtProperties, 
colFamiliesForPColumnsToBeAdded, families, tableProps);
+Pair tableDescriptorPair = 
separateAndValidateProperties(table, stmtProperties, 
colFamiliesForPColumnsToBeAdded, tableProps);
 HTableDescriptor tableDescriptor = tableDescriptorPair.getSecond();
 HTableDescriptor origTableDescriptor = tableDescriptorPair.getFirst();
 if (tableDescriptor != null) {
@@ -1944,7 +1944,8 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
 this.addCoprocessors(tableDescriptor.getName(), tableDescriptor, 
tableType, tableProps);
 }
 
-private Pair 
separateAndValidateProperties(PTable table, Map>> properties, Set colFamiliesForPColumnsToBeAdded, 
List>> families, Map 
tableProps) throws SQLException {
+private Pair 
separateAndValidateProperties(PTable table, Map>> properties,
+  Set colFamiliesForPColumnsToBeAdded, Map 
tableProps) throws SQLException {
 Map> stmtFamiliesPropsMap = new 
HashMap<>(properties.size());
 Map commonFamilyProps = new HashMap<>();
 boolean addingColumns = colFamiliesForPColumnsToBeAdded != null && 
!colFamiliesForPColumnsToBeAdded.isEmpty();



phoenix git commit: PHOENIX-4361: Remove redundant argument in separateAndValidateProperties in CQSI

2017-11-17 Thread ewang
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 d9d235402 -> d11f8d71e


PHOENIX-4361: Remove redundant argument in separateAndValidateProperties in CQSI

Signed-off-by: aertoria 


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

Branch: refs/heads/4.x-HBase-0.98
Commit: d11f8d71ed1bd9207b9ece5268cedd3cc58780fb
Parents: d9d2354
Author: Chinmay Kulkarni 
Authored: Wed Nov 15 18:31:20 2017 -0800
Committer: aertoria 
Committed: Fri Nov 17 11:33:32 2017 -0800

--
 .../org/apache/phoenix/query/ConnectionQueryServicesImpl.java   | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/d11f8d71/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index 7f03239..bc30161 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -1718,7 +1718,7 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
 Set tableDescriptors = Collections.emptySet();
 Set origTableDescriptors = Collections.emptySet();
 boolean nonTxToTx = false;
-Pair tableDescriptorPair = 
separateAndValidateProperties(table, stmtProperties, 
colFamiliesForPColumnsToBeAdded, families, tableProps);
+Pair tableDescriptorPair = 
separateAndValidateProperties(table, stmtProperties, 
colFamiliesForPColumnsToBeAdded, tableProps);
 HTableDescriptor tableDescriptor = tableDescriptorPair.getSecond();
 HTableDescriptor origTableDescriptor = tableDescriptorPair.getFirst();
 if (tableDescriptor != null) {
@@ -1936,7 +1936,8 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
 this.addCoprocessors(tableDescriptor.getName(), tableDescriptor, 
tableType, tableProps);
 }
 
-private Pair 
separateAndValidateProperties(PTable table, Map>> properties, Set colFamiliesForPColumnsToBeAdded, 
List>> families, Map 
tableProps) throws SQLException {
+private Pair 
separateAndValidateProperties(PTable table, Map>> properties,
+  Set colFamiliesForPColumnsToBeAdded, Map 
tableProps) throws SQLException {
 Map> stmtFamiliesPropsMap = new 
HashMap<>(properties.size());
 Map commonFamilyProps = new HashMap<>();
 boolean addingColumns = colFamiliesForPColumnsToBeAdded != null && 
!colFamiliesForPColumnsToBeAdded.isEmpty();



phoenix git commit: PHOENIX-4361: Remove redundant argument in separateAndValidateProperties in CQSI

2017-11-17 Thread ewang
Repository: phoenix
Updated Branches:
  refs/heads/master ef3bce18f -> ddd3ef28d


PHOENIX-4361: Remove redundant argument in separateAndValidateProperties in CQSI

Signed-off-by: aertoria 


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

Branch: refs/heads/master
Commit: ddd3ef28d36f963b295cef74db372f13040ea22a
Parents: ef3bce1
Author: Chinmay Kulkarni 
Authored: Wed Nov 15 18:31:20 2017 -0800
Committer: aertoria 
Committed: Fri Nov 17 11:26:00 2017 -0800

--
 .../org/apache/phoenix/query/ConnectionQueryServicesImpl.java   | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/ddd3ef28/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
 
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
index f8f8501..7a255a1 100644
--- 
a/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
+++ 
b/phoenix-core/src/main/java/org/apache/phoenix/query/ConnectionQueryServicesImpl.java
@@ -1722,7 +1722,7 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
 Set tableDescriptors = Collections.emptySet();
 Set origTableDescriptors = Collections.emptySet();
 boolean nonTxToTx = false;
-Pair tableDescriptorPair = 
separateAndValidateProperties(table, stmtProperties, 
colFamiliesForPColumnsToBeAdded, families, tableProps);
+Pair tableDescriptorPair = 
separateAndValidateProperties(table, stmtProperties, 
colFamiliesForPColumnsToBeAdded, tableProps);
 HTableDescriptor tableDescriptor = tableDescriptorPair.getSecond();
 HTableDescriptor origTableDescriptor = tableDescriptorPair.getFirst();
 if (tableDescriptor != null) {
@@ -1940,7 +1940,8 @@ public class ConnectionQueryServicesImpl extends 
DelegateQueryServices implement
 this.addCoprocessors(tableDescriptor.getName(), tableDescriptor, 
tableType, tableProps);
 }
 
-private Pair 
separateAndValidateProperties(PTable table, Map>> properties, Set colFamiliesForPColumnsToBeAdded, 
List>> families, Map 
tableProps) throws SQLException {
+private Pair 
separateAndValidateProperties(PTable table, Map>> properties,
+  Set colFamiliesForPColumnsToBeAdded, Map 
tableProps) throws SQLException {
 Map> stmtFamiliesPropsMap = new 
HashMap<>(properties.size());
 Map commonFamilyProps = new HashMap<>();
 boolean addingColumns = colFamiliesForPColumnsToBeAdded != null && 
!colFamiliesForPColumnsToBeAdded.isEmpty();



phoenix git commit: PHOENIX-4283 fix a coearceByte issue which causes nested group by big int incorrect

2017-10-16 Thread ewang
Repository: phoenix
Updated Branches:
  refs/heads/master ff803 -> bab06d688


PHOENIX-4283 fix a coearceByte issue which causes nested group by big int 
incorrect

Signed-off-by: aertoria 


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

Branch: refs/heads/master
Commit: bab06d688acde9801ae171420f94871b8e78684f
Parents: ff80555
Author: aertoria 
Authored: Sun Oct 15 18:36:44 2017 -0700
Committer: aertoria 
Committed: Mon Oct 16 11:13:34 2017 -0700

--
 .../org/apache/phoenix/end2end/AggregateIT.java | 21 +++-
 .../org/apache/phoenix/schema/types/PLong.java  |  3 ++-
 2 files changed, 22 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/bab06d68/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateIT.java
index bde9b9d..09e51c5 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateIT.java
@@ -939,7 +939,26 @@ public class AggregateIT extends ParallelStatsDisabledIT {
 public void testCountNullInNonEncodedNonEmptyKeyValueCF() throws Exception 
{
 testCountNullInNonEmptyKeyValueCF(0);
 }
-
+
+@Test
+public void testNestedGroupedAggregationWithBigInt() throws Exception {
+Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+String tableName = generateUniqueName();
+try(Connection conn = DriverManager.getConnection(getUrl(), props);) {
+String createQuery="CREATE TABLE "+tableName+" (a BIGINT NOT 
NULL,c BIGINT NOT NULL CONSTRAINT PK PRIMARY KEY (a, c))";
+String updateQuery="UPSERT INTO "+tableName+"(a,c) 
VALUES(444, 555)";
+String query="SELECT a FROM (SELECT a, c FROM "+tableName+" GROUP 
BY a, c) GROUP BY a, c";
+conn.prepareStatement(createQuery).execute();
+conn.prepareStatement(updateQuery).execute();
+conn.commit();
+PreparedStatement statement = conn.prepareStatement(query);
+ResultSet rs = statement.executeQuery();
+assertTrue(rs.next());
+assertEquals(444L,rs.getLong(1));
+assertFalse(rs.next());
+}
+}
+
 private void testCountNullInNonEmptyKeyValueCF(int columnEncodedBytes) 
throws Exception {
 try (Connection conn = DriverManager.getConnection(getUrl())) {
 //Type is INT

http://git-wip-us.apache.org/repos/asf/phoenix/blob/bab06d68/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PLong.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PLong.java 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PLong.java
index 0402c6e..acd16c5 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PLong.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PLong.java
@@ -133,8 +133,9 @@ public class PLong extends PWholeNumber {
 public void coerceBytes(ImmutableBytesWritable ptr, Object object, 
PDataType actualType,
 Integer maxLength, Integer scale, SortOrder actualModifier, 
Integer desiredMaxLength, Integer desiredScale,
 SortOrder expectedModifier) {
+
 // Decrease size of TIMESTAMP to size of LONG and continue coerce
-if (ptr.getLength() > getByteSize()) {
+if (ptr.getLength() > getByteSize() && 
actualType.isCoercibleTo(PTimestamp.INSTANCE)) {
 ptr.set(ptr.get(), ptr.getOffset(), getByteSize());
 }
 super.coerceBytes(ptr, object, actualType, maxLength, scale, 
actualModifier, desiredMaxLength,



phoenix git commit: PHOENIX-4283 fix a coearceByte issue which causes nested group by big int incorrect

2017-10-16 Thread ewang
Repository: phoenix
Updated Branches:
  refs/heads/4.12-HBase-0.98 eb51d4023 -> a6b062b48


PHOENIX-4283 fix a coearceByte issue which causes nested group by big int 
incorrect

Signed-off-by: aertoria 


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

Branch: refs/heads/4.12-HBase-0.98
Commit: a6b062b48d71616319658b0044e3943125db86ec
Parents: eb51d40
Author: aertoria 
Authored: Sun Oct 15 18:36:44 2017 -0700
Committer: aertoria 
Committed: Mon Oct 16 11:17:33 2017 -0700

--
 .../org/apache/phoenix/end2end/AggregateIT.java | 21 +++-
 .../org/apache/phoenix/schema/types/PLong.java  |  3 ++-
 2 files changed, 22 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/a6b062b4/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateIT.java
index 67a468a..3d0e590 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateIT.java
@@ -936,7 +936,26 @@ public class AggregateIT extends ParallelStatsDisabledIT {
 public void testCountNullInNonEncodedNonEmptyKeyValueCF() throws Exception 
{
 testCountNullInNonEmptyKeyValueCF(0);
 }
-
+
+@Test
+public void testNestedGroupedAggregationWithBigInt() throws Exception {
+Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+String tableName = generateUniqueName();
+try(Connection conn = DriverManager.getConnection(getUrl(), props);) {
+String createQuery="CREATE TABLE "+tableName+" (a BIGINT NOT 
NULL,c BIGINT NOT NULL CONSTRAINT PK PRIMARY KEY (a, c))";
+String updateQuery="UPSERT INTO "+tableName+"(a,c) 
VALUES(444, 555)";
+String query="SELECT a FROM (SELECT a, c FROM "+tableName+" GROUP 
BY a, c) GROUP BY a, c";
+conn.prepareStatement(createQuery).execute();
+conn.prepareStatement(updateQuery).execute();
+conn.commit();
+PreparedStatement statement = conn.prepareStatement(query);
+ResultSet rs = statement.executeQuery();
+assertTrue(rs.next());
+assertEquals(444L,rs.getLong(1));
+assertFalse(rs.next());
+}
+}
+
 private void testCountNullInNonEmptyKeyValueCF(int columnEncodedBytes) 
throws Exception {
 try (Connection conn = DriverManager.getConnection(getUrl())) {
 //Type is INT

http://git-wip-us.apache.org/repos/asf/phoenix/blob/a6b062b4/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PLong.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PLong.java 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PLong.java
index 0402c6e..acd16c5 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PLong.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PLong.java
@@ -133,8 +133,9 @@ public class PLong extends PWholeNumber {
 public void coerceBytes(ImmutableBytesWritable ptr, Object object, 
PDataType actualType,
 Integer maxLength, Integer scale, SortOrder actualModifier, 
Integer desiredMaxLength, Integer desiredScale,
 SortOrder expectedModifier) {
+
 // Decrease size of TIMESTAMP to size of LONG and continue coerce
-if (ptr.getLength() > getByteSize()) {
+if (ptr.getLength() > getByteSize() && 
actualType.isCoercibleTo(PTimestamp.INSTANCE)) {
 ptr.set(ptr.get(), ptr.getOffset(), getByteSize());
 }
 super.coerceBytes(ptr, object, actualType, maxLength, scale, 
actualModifier, desiredMaxLength,



phoenix git commit: PHOENIX-4283 fix a coearceByte issue which causes nested group by big int incorrect

2017-10-16 Thread ewang
Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-0.98 fe8c738e4 -> a9d724216


PHOENIX-4283 fix a coearceByte issue which causes nested group by big int 
incorrect

Signed-off-by: aertoria 


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

Branch: refs/heads/4.x-HBase-0.98
Commit: a9d724216d2c3d3384bf10a28934abdd52550c6f
Parents: fe8c738
Author: aertoria 
Authored: Sun Oct 15 18:36:44 2017 -0700
Committer: aertoria 
Committed: Mon Oct 16 11:18:58 2017 -0700

--
 .../org/apache/phoenix/end2end/AggregateIT.java | 21 +++-
 .../org/apache/phoenix/schema/types/PLong.java  |  3 ++-
 2 files changed, 22 insertions(+), 2 deletions(-)
--


http://git-wip-us.apache.org/repos/asf/phoenix/blob/a9d72421/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateIT.java
--
diff --git 
a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateIT.java 
b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateIT.java
index 67a468a..3d0e590 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/AggregateIT.java
@@ -936,7 +936,26 @@ public class AggregateIT extends ParallelStatsDisabledIT {
 public void testCountNullInNonEncodedNonEmptyKeyValueCF() throws Exception 
{
 testCountNullInNonEmptyKeyValueCF(0);
 }
-
+
+@Test
+public void testNestedGroupedAggregationWithBigInt() throws Exception {
+Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
+String tableName = generateUniqueName();
+try(Connection conn = DriverManager.getConnection(getUrl(), props);) {
+String createQuery="CREATE TABLE "+tableName+" (a BIGINT NOT 
NULL,c BIGINT NOT NULL CONSTRAINT PK PRIMARY KEY (a, c))";
+String updateQuery="UPSERT INTO "+tableName+"(a,c) 
VALUES(444, 555)";
+String query="SELECT a FROM (SELECT a, c FROM "+tableName+" GROUP 
BY a, c) GROUP BY a, c";
+conn.prepareStatement(createQuery).execute();
+conn.prepareStatement(updateQuery).execute();
+conn.commit();
+PreparedStatement statement = conn.prepareStatement(query);
+ResultSet rs = statement.executeQuery();
+assertTrue(rs.next());
+assertEquals(444L,rs.getLong(1));
+assertFalse(rs.next());
+}
+}
+
 private void testCountNullInNonEmptyKeyValueCF(int columnEncodedBytes) 
throws Exception {
 try (Connection conn = DriverManager.getConnection(getUrl())) {
 //Type is INT

http://git-wip-us.apache.org/repos/asf/phoenix/blob/a9d72421/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PLong.java
--
diff --git 
a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PLong.java 
b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PLong.java
index 0402c6e..acd16c5 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PLong.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PLong.java
@@ -133,8 +133,9 @@ public class PLong extends PWholeNumber {
 public void coerceBytes(ImmutableBytesWritable ptr, Object object, 
PDataType actualType,
 Integer maxLength, Integer scale, SortOrder actualModifier, 
Integer desiredMaxLength, Integer desiredScale,
 SortOrder expectedModifier) {
+
 // Decrease size of TIMESTAMP to size of LONG and continue coerce
-if (ptr.getLength() > getByteSize()) {
+if (ptr.getLength() > getByteSize() && 
actualType.isCoercibleTo(PTimestamp.INSTANCE)) {
 ptr.set(ptr.get(), ptr.getOffset(), getByteSize());
 }
 super.coerceBytes(ptr, object, actualType, maxLength, scale, 
actualModifier, desiredMaxLength,