You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by ja...@apache.org on 2018/05/09 20:24:33 UTC

[1/7] phoenix git commit: PHOENIX-4623 Inconsistent physical view index name

Repository: phoenix
Updated Branches:
  refs/heads/4.x-HBase-1.1 6f52b737d -> 79838c0d5


PHOENIX-4623 Inconsistent physical view index name


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

Branch: refs/heads/4.x-HBase-1.1
Commit: d17dc04601767c5265ce2e7436fed270fa7aba72
Parents: 04797bf
Author: James Taylor <jt...@salesforce.com>
Authored: Tue May 8 16:29:41 2018 -0700
Committer: James Taylor <jt...@salesforce.com>
Committed: Wed May 9 13:22:36 2018 -0700

----------------------------------------------------------------------
 .../org/apache/phoenix/end2end/BaseViewIT.java    |  7 +++----
 .../java/org/apache/phoenix/end2end/ViewIT.java   |  2 +-
 .../phoenix/schema/stats/StatsCollectorIT.java    |  3 +--
 .../org/apache/phoenix/util/MetaDataUtil.java     | 18 +++++-------------
 .../java/org/apache/phoenix/util/UpgradeUtil.java |  2 +-
 5 files changed, 11 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/d17dc046/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java
index 478b234..5728a20 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/BaseViewIT.java
@@ -46,7 +46,6 @@ import org.apache.phoenix.util.MetaDataUtil;
 import org.apache.phoenix.util.QueryUtil;
 import org.apache.phoenix.util.ScanUtil;
 import org.apache.phoenix.util.SchemaUtil;
-import org.apache.phoenix.util.TestUtil;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
 import org.junit.runners.Parameterized.Parameters;
@@ -66,7 +65,7 @@ public abstract class BaseViewIT extends ParallelStatsEnabledIT {
 		if (transactional) {
 			optionBuilder.append(" TRANSACTIONAL=true ");
 		}
-		this.schemaName = TestUtil.DEFAULT_SCHEMA_NAME;
+		this.schemaName = "S_" + generateUniqueName();
 		this.tableDDLOptions = optionBuilder.toString();
 		this.tableName = "T_" + generateUniqueName();
         this.fullTableName = SchemaUtil.getTableName(schemaName, tableName);
@@ -166,7 +165,7 @@ public abstract class BaseViewIT extends ParallelStatsEnabledIT {
         ResultSet rs;
         Connection conn = DriverManager.getConnection(getUrl());
         String viewIndexName1 = "I_" + generateUniqueName();
-        String viewIndexPhysicalName = MetaDataUtil.getViewIndexName(schemaName, tableName);
+        String viewIndexPhysicalName = MetaDataUtil.getViewIndexPhysicalName(fullTableName);
         if (localIndex) {
             conn.createStatement().execute("CREATE LOCAL INDEX " + viewIndexName1 + " on " + viewName + "(k3)");
         } else {
@@ -231,7 +230,7 @@ public abstract class BaseViewIT extends ParallelStatsEnabledIT {
         rs = conn.createStatement().executeQuery("EXPLAIN " + query);
         String physicalTableName;
         if (localIndex) {
-            physicalTableName = tableName;
+            physicalTableName = fullTableName;
             assertEquals("CLIENT PARALLEL "+ (saltBuckets == null ? 1 : saltBuckets)  +"-WAY RANGE SCAN OVER " + fullTableName +" [" + (2) + ",'foo']\n"
                     + "    SERVER FILTER BY FIRST KEY ONLY\n"
                     + "CLIENT MERGE SORT",QueryUtil.getExplainPlan(rs));

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d17dc046/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
index 279bbd7..34292ba 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/ViewIT.java
@@ -69,7 +69,7 @@ public class ViewIT extends BaseViewIT {
         String ddl = "CREATE TABLE " + fullTableName + " (k INTEGER NOT NULL PRIMARY KEY, v1 DATE) "+ tableDDLOptions;
         conn.createStatement().execute(ddl);
         String fullParentViewName = "V_" + generateUniqueName();
-        ddl = "CREATE VIEW " + fullParentViewName + " (v2 VARCHAR) AS SELECT * FROM " + tableName + " WHERE k > 5";
+        ddl = "CREATE VIEW " + fullParentViewName + " (v2 VARCHAR) AS SELECT * FROM " + fullTableName + " WHERE k > 5";
         conn.createStatement().execute(ddl);
         try {
             conn.createStatement().execute("UPSERT INTO " + fullParentViewName + " VALUES(1)");

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d17dc046/phoenix-core/src/it/java/org/apache/phoenix/schema/stats/StatsCollectorIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/schema/stats/StatsCollectorIT.java b/phoenix-core/src/it/java/org/apache/phoenix/schema/stats/StatsCollectorIT.java
index c424f45..09d28f8 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/schema/stats/StatsCollectorIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/schema/stats/StatsCollectorIT.java
@@ -48,7 +48,6 @@ import org.apache.hadoop.hbase.client.ResultScanner;
 import org.apache.hadoop.hbase.client.Scan;
 import org.apache.hadoop.hbase.coprocessor.RegionCoprocessorEnvironment;
 import org.apache.hadoop.hbase.util.Bytes;
-import org.apache.phoenix.coprocessor.MetaDataRegionObserver;
 import org.apache.phoenix.coprocessor.UngroupedAggregateRegionObserver;
 import org.apache.phoenix.end2end.BaseUniqueNamesOwnClusterIT;
 import org.apache.phoenix.jdbc.PhoenixConnection;
@@ -785,7 +784,7 @@ public abstract class StatsCollectorIT extends BaseUniqueNamesOwnClusterIT {
             String viewIndex = "VI_" + generateUniqueName();
             ddl = "CREATE INDEX " + viewIndex + " ON " + view + " (b)";
             conn.createStatement().execute(ddl);
-            String viewIndexTableName = MetaDataUtil.getViewIndexTableName(baseTable);
+            String viewIndexTableName = MetaDataUtil.getViewIndexPhysicalName(baseTable);
             statsCollector = getDefaultStatsCollectorForTable(viewIndexTableName);
             statsCollector.init();
             assertEquals(defaultGuidePostWidth, statsCollector.getGuidePostDepth());

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d17dc046/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
index 5e8e3bc..dd2923b 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/MetaDataUtil.java
@@ -345,23 +345,15 @@ public class MetaDataUtil {
         return getIndexPhysicalName(physicalTableName, VIEW_INDEX_TABLE_PREFIX);
     }
 
-    public static String getViewIndexTableName(String tableName) {
-        return VIEW_INDEX_TABLE_PREFIX + tableName;
-    }
-
-    public static String getViewIndexSchemaName(String schemaName) {
-        return schemaName;
-    }
-    
-    public static String getViewIndexName(String schemaName, String tableName) {
-        return SchemaUtil.getTableName(getViewIndexSchemaName(schemaName), getViewIndexTableName(tableName));
+    public static String getViewIndexPhysicalName(String physicalTableName) {
+        return getIndexPhysicalName(physicalTableName, VIEW_INDEX_TABLE_PREFIX);
     }
 
-    public static byte[] getIndexPhysicalName(byte[] physicalTableName, String indexPrefix) {
-        return getIndexPhysicalName(Bytes.toString(physicalTableName), indexPrefix).getBytes();
+    private static byte[] getIndexPhysicalName(byte[] physicalTableName, String indexPrefix) {
+        return Bytes.toBytes(getIndexPhysicalName(Bytes.toString(physicalTableName), indexPrefix));
     }
 
-    public static String getIndexPhysicalName(String physicalTableName, String indexPrefix) {
+    private static String getIndexPhysicalName(String physicalTableName, String indexPrefix) {
         if (physicalTableName.contains(QueryConstants.NAMESPACE_SEPARATOR)) {
             String schemaName = SchemaUtil.getSchemaNameFromFullName(physicalTableName,
                     QueryConstants.NAMESPACE_SEPARATOR);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/d17dc046/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
index 63f2183..b127408 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/UpgradeUtil.java
@@ -600,7 +600,7 @@ public class UpgradeUtil {
                             viewPTable = PhoenixRuntime.getTable(globalConnection, fullViewName);
                             globalConnection.createStatement().execute(String.format(disableIndexDDL, indexName, fullViewName));
                         }
-                        String indexPhysicalTableName = MetaDataUtil.getViewIndexTableName(viewPTable.getPhysicalName().getString());
+                        String indexPhysicalTableName = MetaDataUtil.getViewIndexPhysicalName(viewPTable.getPhysicalName().getString());
                         if (physicalTables.add(indexPhysicalTableName)) {
                             final TableName tableName = TableName.valueOf(indexPhysicalTableName);
                             if(admin.tableExists(tableName)) {


[3/7] phoenix git commit: PHOENIX-4732 Improve config defaults for async secondary index MR jobs

Posted by ja...@apache.org.
PHOENIX-4732 Improve config defaults for async secondary index MR jobs


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

Branch: refs/heads/4.x-HBase-1.1
Commit: bf52114b05e2391c4855fe21e39f2369f8a403f1
Parents: 6f52b73
Author: James Taylor <jt...@salesforce.com>
Authored: Tue May 8 15:26:44 2018 -0700
Committer: James Taylor <jt...@salesforce.com>
Committed: Wed May 9 13:22:36 2018 -0700

----------------------------------------------------------------------
 .../index/automation/PhoenixMRJobSubmitter.java | 48 ++++++++++++++++++--
 .../apache/phoenix/util/PhoenixMRJobUtil.java   | 18 +++-----
 2 files changed, 52 insertions(+), 14 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/bf52114b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/automation/PhoenixMRJobSubmitter.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/automation/PhoenixMRJobSubmitter.java b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/automation/PhoenixMRJobSubmitter.java
index 9c447e8..d86802a 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/automation/PhoenixMRJobSubmitter.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/mapreduce/index/automation/PhoenixMRJobSubmitter.java
@@ -45,6 +45,7 @@ import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hbase.HBaseConfiguration;
 import org.apache.hadoop.hbase.HConstants;
 import org.apache.hadoop.hbase.zookeeper.ZooKeeperWatcher;
+import org.apache.hadoop.mapreduce.MRJobConfig;
 import org.apache.hadoop.security.UserGroupInformation;
 import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
 import org.apache.phoenix.mapreduce.index.IndexTool;
@@ -53,8 +54,8 @@ import org.apache.phoenix.schema.PTable.IndexType;
 import org.apache.phoenix.schema.PTableType;
 import org.apache.phoenix.schema.types.PDate;
 import org.apache.phoenix.util.PhoenixMRJobUtil;
-import org.apache.phoenix.util.UpgradeUtil;
 import org.apache.phoenix.util.PhoenixMRJobUtil.MR_SCHEDULER_TYPE;
+import org.apache.phoenix.util.UpgradeUtil;
 import org.apache.phoenix.util.ZKBasedMasterElectionUtil;
 import org.codehaus.jettison.json.JSONArray;
 import org.codehaus.jettison.json.JSONObject;
@@ -69,8 +70,28 @@ public class PhoenixMRJobSubmitter {
     // Lock to elect a master node that submits the Phoenix Secondary Index MR Jobs
     private static final String PHOENIX_LOCKS_PARENT =
             "/phoenix/automated-mr-index-build-leader-election";
+    public static final String PHOENIX_MR_CLIENT_SCANNER_TIMEOUT_PERIOD =
+            "phoenix.mr.client.scanner.timeout.period";
+    public static final String PHOENIX_MR_RPC_TIMEOUT =
+            "phoenix.mr.rpc.timeout";
+    public static final String PHOENIX_MR_TASK_TIMEOUT =
+            "phoenix.mr.task.timeout";
+    public static final String PHOENIX_MR_CLIENT_RETRIES_NUMBER =
+            "phoenix.mr.client.retries.number";
+    public static final String PHOENIX_MR_CLIENT_PAUSE =
+            "phoenix.mr.client.retries.number";
+    public static final String PHOENIX_MR_ZK_RECOVERY_RETRY =
+            "phoenix.mr.zk.recovery.retry";
     private static final String AUTO_INDEX_BUILD_LOCK_NAME = "ActiveStandbyElectorLock";
-
+    private static final int DEFAULT_TIMEOUT_IN_MILLIS = 600000;
+    public static final int DEFAULT_MR_CLIENT_SCANNER_TIMEOUT_PERIOD = DEFAULT_TIMEOUT_IN_MILLIS;
+    public static final int DEFAULT_MR_RPC_TIMEOUT = DEFAULT_TIMEOUT_IN_MILLIS;
+    public static final int DEFAULT_MR_TASK_TIMEOUT = DEFAULT_TIMEOUT_IN_MILLIS;
+    // Reduced HBase/Zookeeper Client Retries
+    public static final int DEFAULT_MR_CLIENT_RETRIES_NUMBER = 10;
+    public static final int DEFAULT_MR_CLIENT_PAUSE = 1000;
+    public static final int DEFAULT_MR_ZK_RECOVERY_RETRY = 1;
+    
     public static final String CANDIDATE_INDEX_INFO_QUERY = "SELECT "
             + PhoenixDatabaseMetaData.INDEX_TYPE + ","
             + PhoenixDatabaseMetaData.DATA_TABLE_NAME + ", "
@@ -103,7 +124,28 @@ public class PhoenixMRJobSubmitter {
         }
         this.conf = conf;
 
-        PhoenixMRJobUtil.updateTimeoutsToFailFast(conf);
+        // Have Phoenix specific properties for defaults to enable potential override
+        conf.setLong(HConstants.HBASE_CLIENT_SCANNER_TIMEOUT_PERIOD, 
+                conf.getLong(PHOENIX_MR_CLIENT_SCANNER_TIMEOUT_PERIOD,
+                        DEFAULT_MR_CLIENT_SCANNER_TIMEOUT_PERIOD));
+        conf.setLong(HConstants.HBASE_RPC_TIMEOUT_KEY, 
+                conf.getLong(PHOENIX_MR_RPC_TIMEOUT,
+                        DEFAULT_MR_RPC_TIMEOUT));
+        conf.setLong(MRJobConfig.TASK_TIMEOUT, 
+                conf.getLong(PHOENIX_MR_TASK_TIMEOUT,
+                        DEFAULT_MR_TASK_TIMEOUT));
+
+        // Reduced HBase Client Retries
+        conf.setInt(HConstants.HBASE_CLIENT_RETRIES_NUMBER, 
+                conf.getInt(PHOENIX_MR_CLIENT_RETRIES_NUMBER,
+                        DEFAULT_MR_CLIENT_RETRIES_NUMBER));
+        conf.setInt(HConstants.HBASE_CLIENT_PAUSE, 
+                conf.getInt(PHOENIX_MR_CLIENT_PAUSE,
+                        DEFAULT_MR_CLIENT_PAUSE));
+        conf.setInt("zookeeper.recovery.retry", 
+                conf.getInt(PHOENIX_MR_ZK_RECOVERY_RETRY,
+                        DEFAULT_MR_ZK_RECOVERY_RETRY));
+        
         String schedulerType =
                 conf.get(PhoenixMRJobUtil.PHOENIX_MR_SCHEDULER_TYPE_NAME,
                     MR_SCHEDULER_TYPE.NONE.toString());

http://git-wip-us.apache.org/repos/asf/phoenix/blob/bf52114b/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixMRJobUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixMRJobUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixMRJobUtil.java
index f12d49d..13eae98 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixMRJobUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/PhoenixMRJobUtil.java
@@ -52,19 +52,17 @@ public class PhoenixMRJobUtil {
     private static final String ACTIVE_STANDBY_ELECTOR_LOCK = "ActiveStandbyElectorLock";
     private static final String RM_APPS_GET_ENDPOINT = "/ws/v1/cluster/apps";
 
-    // Reduced HBase Client Retries
-    private static final int CLIENT_RETRIES_NUMBER = 2;
-    private static final long CLIENT_PAUSE_TIME = 1000;
-    private static final int ZOOKEEPER_RECOVERY_RETRY_COUNT = 1;
-
     public static final String PHOENIX_INDEX_MR_QUEUE_NAME_PROPERTY =
             "phoenix.index.mr.scheduler.capacity.queuename";
     public static final String PHOENIX_INDEX_MR_MAP_MEMORY_PROPERTY =
             "phoenix.index.mr.scheduler.capacity.mapMemoryMB";
+    public static final String PHOENIX_MR_CONCURRENT_MAP_LIMIT_PROPERTY =
+    		"phoenix.mr.concurrent.map.limit";
 
     // Default MR Capacity Scheduler Configurations for Phoenix MR Index Build
     // Jobs
     public static final String DEFAULT_QUEUE_NAME = "default";
+    public static final int DEFAULT_MR_CONCURRENT_MAP_LIMIT = 20;
     public static final int DEFAULT_MAP_MEMROY_MB = 5120;
     public static final String XMX_OPT = "-Xmx";
 
@@ -208,12 +206,6 @@ public class PhoenixMRJobUtil {
         return rmPort;
     }
 
-    public static void updateTimeoutsToFailFast(Configuration conf) {
-        conf.set("hbase.client.retries.number", String.valueOf(CLIENT_RETRIES_NUMBER));
-        conf.set("zookeeper.recovery.retry", String.valueOf(ZOOKEEPER_RECOVERY_RETRY_COUNT));
-        conf.set("hbase.client.pause", String.valueOf(CLIENT_PAUSE_TIME));
-    }
-
     /**
      * This method set the configuration values for Capacity scheduler.
      * @param conf - Configuration to which Capacity Queue information to be added
@@ -221,6 +213,10 @@ public class PhoenixMRJobUtil {
     public static void updateCapacityQueueInfo(Configuration conf) {
         conf.set(MRJobConfig.QUEUE_NAME,
             conf.get(PHOENIX_INDEX_MR_QUEUE_NAME_PROPERTY, DEFAULT_QUEUE_NAME));
+
+        conf.setInt(MRJobConfig.JOB_RUNNING_MAP_LIMIT,
+                conf.getInt(PHOENIX_MR_CONCURRENT_MAP_LIMIT_PROPERTY, DEFAULT_MR_CONCURRENT_MAP_LIMIT));
+
         int mapMemoryMB = conf.getInt(PHOENIX_INDEX_MR_MAP_MEMORY_PROPERTY, DEFAULT_MAP_MEMROY_MB);
 
         conf.setInt(MRJobConfig.MAP_MEMORY_MB, mapMemoryMB);


[5/7] phoenix git commit: PHOENIX-3270 Remove @Ignore tag for TransactionIT.testNonTxToTxTableFailure()

Posted by ja...@apache.org.
PHOENIX-3270 Remove @Ignore tag for TransactionIT.testNonTxToTxTableFailure()


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

Branch: refs/heads/4.x-HBase-1.1
Commit: 018ebfc2b1cad73140dbdb25f6c6faa0ec6e6e5f
Parents: a3d1c94
Author: James Taylor <jt...@salesforce.com>
Authored: Thu May 3 09:52:57 2018 -0700
Committer: James Taylor <jt...@salesforce.com>
Committed: Wed May 9 13:22:36 2018 -0700

----------------------------------------------------------------------
 .../it/java/org/apache/phoenix/tx/ParameterizedTransactionIT.java  | 2 --
 1 file changed, 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/018ebfc2/phoenix-core/src/it/java/org/apache/phoenix/tx/ParameterizedTransactionIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/tx/ParameterizedTransactionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/tx/ParameterizedTransactionIT.java
index 580f055..ec1cf3a 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/tx/ParameterizedTransactionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/tx/ParameterizedTransactionIT.java
@@ -57,7 +57,6 @@ import org.apache.phoenix.transaction.PhoenixTransactionContext;
 import org.apache.phoenix.util.ByteUtil;
 import org.apache.phoenix.util.PropertiesUtil;
 import org.apache.phoenix.util.TestUtil;
-import org.junit.Ignore;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.junit.runners.Parameterized;
@@ -323,7 +322,6 @@ public class ParameterizedTransactionIT extends ParallelStatsDisabledIT {
         assertFalse(rs.next());
     }
     
-    @Ignore
     @Test
     public void testNonTxToTxTableFailure() throws Exception {
         String nonTxTableName = generateUniqueName();


[4/7] phoenix git commit: PHOENIX-4727 Parameterize transaction tests with TRANSACTION_PROVIDER

Posted by ja...@apache.org.
PHOENIX-4727 Parameterize transaction tests with TRANSACTION_PROVIDER


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

Branch: refs/heads/4.x-HBase-1.1
Commit: 04797bffe1c0c28cfb0a0c942422ccfa244ae411
Parents: 018ebfc
Author: James Taylor <jt...@salesforce.com>
Authored: Mon May 7 18:23:03 2018 -0700
Committer: James Taylor <jt...@salesforce.com>
Committed: Wed May 9 13:22:36 2018 -0700

----------------------------------------------------------------------
 .../phoenix/end2end/index/MutableIndexIT.java   | 21 +++---
 .../org/apache/phoenix/tx/TransactionIT.java    | 75 +++++++++++++++-----
 .../java/org/apache/phoenix/util/TestUtil.java  |  6 +-
 3 files changed, 74 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/04797bff/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java
index 2e1d2ee..8e2df30 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/index/MutableIndexIT.java
@@ -78,11 +78,11 @@ public class MutableIndexIT extends ParallelStatsDisabledIT {
     protected final boolean localIndex;
     private final String tableDDLOptions;
 	
-    public MutableIndexIT(boolean localIndex, boolean transactional, boolean columnEncoded) {
+    public MutableIndexIT(Boolean localIndex, String txProvider, Boolean columnEncoded) {
 		this.localIndex = localIndex;
 		StringBuilder optionBuilder = new StringBuilder();
-		if (transactional) {
-			optionBuilder.append("TRANSACTIONAL=true");
+		if (txProvider != null) {
+			optionBuilder.append("TRANSACTIONAL=true," + PhoenixDatabaseMetaData.TRANSACTION_PROVIDER + "='" + txProvider + "'");
 		}
 		if (!columnEncoded) {
             if (optionBuilder.length()!=0)
@@ -104,12 +104,15 @@ public class MutableIndexIT extends ParallelStatsDisabledIT {
     }
     
 	@Parameters(name="MutableIndexIT_localIndex={0},transactional={1},columnEncoded={2}") // name is used by failsafe as file name in reports
-    public static Collection<Boolean[]> data() {
-        return Arrays.asList(new Boolean[][] { 
-                { false, false, false }, { false, false, true },
-                { false, true, false }, { false, true, true },
-                { true, false, false }, { true, false, true },
-                { true, true, false }, { true, true, true } });
+    public static Collection<Object[]> data() {
+        return Arrays.asList(new Object[][] { 
+                { false, null, false }, { false, null, true },
+                { false, "TEPHRA", false }, { false, "TEPHRA", true },
+                //{ false, "OMID", false }, { false, "OMID", true },
+                { true, null, false }, { true, null, true },
+                { true, "TEPHRA", false }, { true, "TEPHRA", true },
+                //{ true, "OMID", false }, { true, "OMID", true },
+                });
     }
     
     @Test

http://git-wip-us.apache.org/repos/asf/phoenix/blob/04797bff/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java b/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java
index f1344e0..c0ec6b8 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/tx/TransactionIT.java
@@ -32,6 +32,8 @@ import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.sql.Statement;
+import java.util.Arrays;
+import java.util.Collection;
 import java.util.Properties;
 
 import org.apache.hadoop.hbase.HColumnDescriptor;
@@ -43,6 +45,7 @@ import org.apache.phoenix.jdbc.PhoenixConnection;
 import org.apache.phoenix.jdbc.PhoenixDatabaseMetaData;
 import org.apache.phoenix.query.QueryConstants;
 import org.apache.phoenix.query.QueryServicesOptions;
+import org.apache.phoenix.schema.PTable;
 import org.apache.phoenix.schema.PTableKey;
 import org.apache.phoenix.transaction.PhoenixTransactionContext;
 import org.apache.phoenix.transaction.TransactionFactory;
@@ -52,16 +55,33 @@ import org.apache.phoenix.util.PropertiesUtil;
 import org.apache.phoenix.util.StringUtil;
 import org.apache.phoenix.util.TestUtil;
 import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Parameterized;
+import org.junit.runners.Parameterized.Parameters;
 
+@RunWith(Parameterized.class)
 public class TransactionIT  extends ParallelStatsDisabledIT {
+    private final String txProvider;
+    private final String tableDDLOptions;
+    
+    public TransactionIT(String provider) {
+        txProvider = provider;
+        tableDDLOptions = PhoenixDatabaseMetaData.TRANSACTION_PROVIDER + "='" + provider + "'";
+    }
 
+    @Parameters(name="TransactionIT_provider={0}") // name is used by failsafe as file name in reports
+    public static Collection<String[]> data() {
+        return Arrays.asList(new String[][] {     
+                 {"TEPHRA"/*,"OMID"*/}});
+    }
+    
     @Test
     public void testQueryWithSCN() throws Exception {
         String tableName = generateUniqueName();
         Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES);
         try (Connection conn = DriverManager.getConnection(getUrl(), props);) {
             conn.createStatement().execute(
-                    "CREATE TABLE " + tableName + " (k VARCHAR NOT NULL PRIMARY KEY, v1 VARCHAR) TRANSACTIONAL=true");
+                    "CREATE TABLE " + tableName + " (k VARCHAR NOT NULL PRIMARY KEY, v1 VARCHAR) TRANSACTIONAL=true," + tableDDLOptions);
         }
         props.put(PhoenixRuntime.CURRENT_SCN_ATTRIB, Long.toString(EnvironmentEdgeManager.currentTimeMillis()));
         try (Connection conn = DriverManager.getConnection(getUrl(), props);) {
@@ -85,7 +105,7 @@ public class TransactionIT  extends ParallelStatsDisabledIT {
         Statement stmt = conn.createStatement();
         stmt.execute("CREATE TABLE " + tableName + "(k VARCHAR PRIMARY KEY, v1 VARCHAR, v2 VARCHAR)");
         stmt.execute("DROP TABLE " + tableName);
-        stmt.execute("CREATE TABLE " + tableName + "(k VARCHAR PRIMARY KEY, v1 VARCHAR, v2 VARCHAR) TRANSACTIONAL=true");
+        stmt.execute("CREATE TABLE " + tableName + "(k VARCHAR PRIMARY KEY, v1 VARCHAR, v2 VARCHAR) TRANSACTIONAL=true," + tableDDLOptions);
         stmt.execute("CREATE INDEX " + tableName + "_IDX ON " + tableName + " (v1) INCLUDE(v2)");
         assertTrue(conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null, tableName)).isTransactional());
         assertTrue(conn.unwrap(PhoenixConnection.class).getTable(new PTableKey(null,  tableName + "_IDX")).isTransactional());
@@ -99,7 +119,7 @@ public class TransactionIT  extends ParallelStatsDisabledIT {
             conn.setAutoCommit(false);
             Statement stmt = conn.createStatement();
             try {
-                stmt.execute("CREATE TABLE " + tableName + "(k VARCHAR, v VARCHAR, d DATE NOT NULL, CONSTRAINT PK PRIMARY KEY(k,d ROW_TIMESTAMP)) TRANSACTIONAL=true");
+                stmt.execute("CREATE TABLE " + tableName + "(k VARCHAR, v VARCHAR, d DATE NOT NULL, CONSTRAINT PK PRIMARY KEY(k,d ROW_TIMESTAMP)) TRANSACTIONAL=true," + tableDDLOptions);
                 fail();
             }
             catch(SQLException e) {
@@ -123,7 +143,7 @@ public class TransactionIT  extends ParallelStatsDisabledIT {
             String transactTableName = generateUniqueName();
             Statement stmt = conn.createStatement();
             stmt.execute("CREATE TABLE " + transactTableName + " (k VARCHAR PRIMARY KEY, v1 VARCHAR, v2 VARCHAR) " +
-                "TRANSACTIONAL=true");
+                "TRANSACTIONAL=true," + tableDDLOptions);
             conn.commit();
 
             DatabaseMetaData dbmd = conn.getMetaData();
@@ -131,7 +151,11 @@ public class TransactionIT  extends ParallelStatsDisabledIT {
             assertTrue(rs.next());
             assertEquals("Transactional table was not marked as transactional in JDBC API.",
                 "true", rs.getString(PhoenixDatabaseMetaData.TRANSACTIONAL));
-            assertEquals(TransactionFactory.Provider.TEPHRA.name(), rs.getString(PhoenixDatabaseMetaData.TRANSACTION_PROVIDER));
+            assertEquals(txProvider, rs.getString(PhoenixDatabaseMetaData.TRANSACTION_PROVIDER));
+            
+            // Ensure round-trip-ability of TRANSACTION_PROVIDER
+            PTable table = PhoenixRuntime.getTableNoCache(conn, transactTableName);
+            assertEquals(txProvider, table.getTransactionProvider().name());
 
             String nonTransactTableName = generateUniqueName();
             Statement stmt2 = conn.createStatement();
@@ -159,7 +183,7 @@ public class TransactionIT  extends ParallelStatsDisabledIT {
         // TODO: we should support having a transactional table defined for a connectionless connection
         try (Connection conn = DriverManager.getConnection(getUrl())) {
             String transactTableName = generateUniqueName();
-            conn.createStatement().execute("CREATE TABLE " + transactTableName + " (k integer not null primary key, v bigint) TRANSACTIONAL=true");
+            conn.createStatement().execute("CREATE TABLE " + transactTableName + " (k integer not null primary key, v bigint) TRANSACTIONAL=true," + tableDDLOptions);
             conn.createStatement().execute("UPSERT INTO " + transactTableName + " VALUES(0,0) ON DUPLICATE KEY UPDATE v = v + 1");
             fail();
         } catch (SQLException e) {
@@ -170,13 +194,28 @@ public class TransactionIT  extends ParallelStatsDisabledIT {
     @Test
     public void testProperties() throws Exception {
         String nonTxTableName = generateUniqueName();
+        String txTableName = generateUniqueName();
+        String idx1 = generateUniqueName();
+        String idx2 = generateUniqueName();
 
         Connection conn = DriverManager.getConnection(getUrl());
         conn.createStatement().execute("CREATE TABLE " + nonTxTableName + "1(k INTEGER PRIMARY KEY, a.v VARCHAR, b.v VARCHAR, c.v VARCHAR) TTL=1000");
-        conn.createStatement().execute("CREATE INDEX idx1 ON " + nonTxTableName + "1(a.v, b.v) TTL=1000");
-        conn.createStatement().execute("CREATE INDEX idx2 ON " + nonTxTableName + "1(c.v) INCLUDE (a.v, b.v) TTL=1000");
+        conn.createStatement().execute("CREATE INDEX " + idx1 + " ON " + nonTxTableName + "1(a.v, b.v) TTL=1000");
+        conn.createStatement().execute("CREATE INDEX " + idx2 + " ON " + nonTxTableName + "1(c.v) INCLUDE (a.v, b.v) TTL=1000");
 
-        conn.createStatement().execute("ALTER TABLE " + nonTxTableName + "1 SET TRANSACTIONAL=true");
+        try {
+            conn.createStatement().execute("ALTER TABLE " + nonTxTableName + "1 SET TRANSACTIONAL=true," + tableDDLOptions);
+            if (TransactionFactory.Provider.OMID.name().equals(txProvider)) {
+                fail("Omid shouldn't allow converting a non transactional table to be transactional");
+            }
+        } catch (SQLException e) { // Should fail for Omid, but not Tephra
+            if (TransactionFactory.Provider.TEPHRA.name().equals(txProvider)) {
+                throw e;
+            }
+            assertEquals(SQLExceptionCode.CANNOT_ALTER_TABLE_FROM_NON_TXN_TO_TXNL.getErrorCode(), e.getErrorCode());
+            // FIXME: should verify Omid table properties too, but the checks below won't be valid for Omid
+            return;
+        }
 
         HTableDescriptor desc = conn.unwrap(PhoenixConnection.class).getQueryServices().getTableDescriptor(Bytes.toBytes(nonTxTableName + "1"));
         for (HColumnDescriptor colDesc : desc.getFamilies()) {
@@ -186,7 +225,7 @@ public class TransactionIT  extends ParallelStatsDisabledIT {
             assertEquals(1000, Integer.parseInt(propertyTTL));
         }
 
-        desc = conn.unwrap(PhoenixConnection.class).getQueryServices().getTableDescriptor(Bytes.toBytes("IDX1"));
+        desc = conn.unwrap(PhoenixConnection.class).getQueryServices().getTableDescriptor(Bytes.toBytes(idx1));
         for (HColumnDescriptor colDesc : desc.getFamilies()) {
             assertEquals(QueryServicesOptions.DEFAULT_MAX_VERSIONS_TRANSACTIONAL, colDesc.getMaxVersions());
             assertEquals(1000, colDesc.getTimeToLive());
@@ -194,7 +233,7 @@ public class TransactionIT  extends ParallelStatsDisabledIT {
             assertEquals(1000, Integer.parseInt(propertyTTL));
         }
         
-        desc = conn.unwrap(PhoenixConnection.class).getQueryServices().getTableDescriptor(Bytes.toBytes("IDX2"));
+        desc = conn.unwrap(PhoenixConnection.class).getQueryServices().getTableDescriptor(Bytes.toBytes(idx2));
         for (HColumnDescriptor colDesc : desc.getFamilies()) {
             assertEquals(QueryServicesOptions.DEFAULT_MAX_VERSIONS_TRANSACTIONAL, colDesc.getMaxVersions());
             assertEquals(1000, colDesc.getTimeToLive());
@@ -220,7 +259,7 @@ public class TransactionIT  extends ParallelStatsDisabledIT {
         }
 
         conn.createStatement().execute("CREATE TABLE " + nonTxTableName + "3(k INTEGER PRIMARY KEY, a.v VARCHAR, b.v VARCHAR, c.v VARCHAR)");
-        conn.createStatement().execute("ALTER TABLE " + nonTxTableName + "3 SET TRANSACTIONAL=true, b.VERSIONS=10, c.VERSIONS=20");
+        conn.createStatement().execute("ALTER TABLE " + nonTxTableName + "3 SET TRANSACTIONAL=true, b.VERSIONS=10, c.VERSIONS=20," + tableDDLOptions);
         desc = conn.unwrap(PhoenixConnection.class).getQueryServices().getTableDescriptor(Bytes.toBytes( nonTxTableName + "3"));
         assertEquals(QueryServicesOptions.DEFAULT_MAX_VERSIONS_TRANSACTIONAL, desc.getFamily(Bytes.toBytes("A")).getMaxVersions());
         assertEquals(10, desc.getFamily(Bytes.toBytes("B")).getMaxVersions());
@@ -228,21 +267,21 @@ public class TransactionIT  extends ParallelStatsDisabledIT {
 
         conn.createStatement().execute("CREATE TABLE " + nonTxTableName + "4(k INTEGER PRIMARY KEY, a.v VARCHAR, b.v VARCHAR, c.v VARCHAR)");
         try {
-            conn.createStatement().execute("ALTER TABLE " + nonTxTableName + "4 SET TRANSACTIONAL=true, VERSIONS=1");
+            conn.createStatement().execute("ALTER TABLE " + nonTxTableName + "4 SET TRANSACTIONAL=true, VERSIONS=1," + tableDDLOptions);
             fail();
         } catch (SQLException e) {
             assertEquals(SQLExceptionCode.TX_MAX_VERSIONS_MUST_BE_GREATER_THAN_ONE.getErrorCode(), e.getErrorCode());
         }
 
         try {
-            conn.createStatement().execute("ALTER TABLE " + nonTxTableName + "4 SET TRANSACTIONAL=true, b.VERSIONS=1");
+            conn.createStatement().execute("ALTER TABLE " + nonTxTableName + "4 SET TRANSACTIONAL=true, b.VERSIONS=1," + tableDDLOptions);
             fail();
         } catch (SQLException e) {
             assertEquals(SQLExceptionCode.TX_MAX_VERSIONS_MUST_BE_GREATER_THAN_ONE.getErrorCode(), e.getErrorCode());
         }
         
-        conn.createStatement().execute("CREATE TABLE TX_TABLE1(k INTEGER PRIMARY KEY, v VARCHAR) TTL=1000, TRANSACTIONAL=true");
-        desc = conn.unwrap(PhoenixConnection.class).getQueryServices().getTableDescriptor(Bytes.toBytes("TX_TABLE1"));
+        conn.createStatement().execute("CREATE TABLE " + txTableName + "(k INTEGER PRIMARY KEY, v VARCHAR) TTL=1000, TRANSACTIONAL=true," + tableDDLOptions);
+        desc = conn.unwrap(PhoenixConnection.class).getQueryServices().getTableDescriptor(Bytes.toBytes(txTableName));
         for (HColumnDescriptor colDesc : desc.getFamilies()) {
             assertEquals(QueryServicesOptions.DEFAULT_MAX_VERSIONS_TRANSACTIONAL, colDesc.getMaxVersions());
             assertEquals(HColumnDescriptor.DEFAULT_TTL, colDesc.getTimeToLive());
@@ -257,7 +296,7 @@ public class TransactionIT  extends ParallelStatsDisabledIT {
         String fullTableName = INDEX_DATA_SCHEMA + QueryConstants.NAME_SEPARATOR + transTableName;
         try (Connection conn1 = DriverManager.getConnection(getUrl()); 
                 Connection conn2 = DriverManager.getConnection(getUrl())) {
-            TestUtil.createTransactionalTable(conn1, fullTableName);
+            TestUtil.createTransactionalTable(conn1, fullTableName, tableDDLOptions);
             conn1.setAutoCommit(false);
             conn2.setAutoCommit(false);
             String selectSql = "SELECT * FROM "+fullTableName;
@@ -296,7 +335,7 @@ public class TransactionIT  extends ParallelStatsDisabledIT {
         conn.setAutoCommit(false);
         try {
             Statement stmt = conn.createStatement();
-            stmt.execute("CREATE TABLE " + fullTableName + "(k VARCHAR PRIMARY KEY, v1 VARCHAR, v2 VARCHAR) TRANSACTIONAL=true");
+            stmt.execute("CREATE TABLE " + fullTableName + "(k VARCHAR PRIMARY KEY, v1 VARCHAR, v2 VARCHAR) TRANSACTIONAL=true," + tableDDLOptions);
             stmt.executeUpdate("upsert into " + fullTableName + " values('x', 'a', 'a')");
             conn.commit();
             

http://git-wip-us.apache.org/repos/asf/phoenix/blob/04797bff/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java b/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
index 341fbec..6920772 100644
--- a/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
+++ b/phoenix-core/src/test/java/org/apache/phoenix/util/TestUtil.java
@@ -830,7 +830,11 @@ public class TestUtil {
     }
 
     public static void createTransactionalTable(Connection conn, String tableName) throws SQLException {
-        conn.createStatement().execute("create table " + tableName + TestUtil.TEST_TABLE_SCHEMA + "TRANSACTIONAL=true");
+        createTransactionalTable(conn, tableName, "");
+    }
+
+    public static void createTransactionalTable(Connection conn, String tableName, String extraProps) throws SQLException {
+        conn.createStatement().execute("create table " + tableName + TestUtil.TEST_TABLE_SCHEMA + "TRANSACTIONAL=true" + (extraProps.length() == 0 ? "" : ("," + extraProps)));
     }
 
     public static void dumpTable(HTableInterface table) throws IOException {


[2/7] phoenix git commit: PHOENIX-3856 StatementContext class constructor not honouring supplied scan object (Sukumar Maddineni)

Posted by ja...@apache.org.
PHOENIX-3856 StatementContext class constructor not honouring supplied scan object (Sukumar Maddineni)


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

Branch: refs/heads/4.x-HBase-1.1
Commit: a3d1c9462da35a2206faf36e39913de81e52bd4e
Parents: bf52114
Author: James Taylor <jt...@salesforce.com>
Authored: Thu May 3 09:32:57 2018 -0700
Committer: James Taylor <jt...@salesforce.com>
Committed: Wed May 9 13:22:36 2018 -0700

----------------------------------------------------------------------
 .../src/main/java/org/apache/phoenix/compile/StatementContext.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/a3d1c946/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java b/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java
index c105046..3e5c8f2 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/compile/StatementContext.java
@@ -98,7 +98,7 @@ public class StatementContext {
     }
 
     public StatementContext(PhoenixStatement statement, Scan scan) {
-        this(statement, FromCompiler.EMPTY_TABLE_RESOLVER, new Scan(), new SequenceManager(statement));
+        this(statement, FromCompiler.EMPTY_TABLE_RESOLVER, scan, new SequenceManager(statement));
     }
 
     public StatementContext(PhoenixStatement statement, ColumnResolver resolver) {


[7/7] phoenix git commit: PHOENIX-4646 The data exceeds the max capacity for the data type error for valid scenarios (Sergey Soldatov)

Posted by ja...@apache.org.
PHOENIX-4646 The data exceeds the max capacity for the data type error for valid scenarios (Sergey Soldatov)


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

Branch: refs/heads/4.x-HBase-1.1
Commit: 79838c0d5faec70d1c65789b311d8b08cd08c5d2
Parents: 6b5130d
Author: James Taylor <jt...@salesforce.com>
Authored: Wed May 9 13:12:26 2018 -0700
Committer: James Taylor <jt...@salesforce.com>
Committed: Wed May 9 13:23:13 2018 -0700

----------------------------------------------------------------------
 .../apache/phoenix/end2end/UpsertSelectIT.java   | 19 +++++++++++++++++++
 .../apache/phoenix/schema/types/PVarchar.java    | 10 ++++++----
 2 files changed, 25 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/79838c0d/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java
index 99cbe47..5db1fdd 100644
--- a/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java
+++ b/phoenix-core/src/it/java/org/apache/phoenix/end2end/UpsertSelectIT.java
@@ -1488,6 +1488,25 @@ public class UpsertSelectIT extends ParallelStatsDisabledIT {
         }
     }
 
+    @Test // See https://issues.apache.org/jira/browse/PHOENIX-4646
+    public void testLengthLimitedVarchar() throws Exception {
+        String tableName1 = generateUniqueName();
+        String tableName2 = generateUniqueName();
+        try (Connection conn = DriverManager.getConnection(getUrl())) {
+            conn.setAutoCommit(true);
+            conn.createStatement().execute("create table " + tableName1 + "(name varchar(160) primary key, id varchar(120), address varchar(160))"); 
+            conn.createStatement().execute("create table " + tableName2 + "(name varchar(160) primary key, id varchar(10), address  varchar(10))");
+            conn.createStatement().execute("upsert into " + tableName1 + " values('test','test','test')");
+            conn.createStatement().execute("upsert into " + tableName2 + " select * from " + tableName1);
+            ResultSet rs = conn.createStatement().executeQuery("select * from " + tableName2);
+            assertTrue(rs.next());
+            assertEquals("test", rs.getString(1));
+            assertEquals("test", rs.getString(2));
+            assertEquals("test", rs.getString(2));
+            assertFalse(rs.next());
+        }
+    }
+    
     private static Connection getTenantConnection(String tenantId) throws Exception {
         Properties props = PropertiesUtil.deepCopy(TestUtil.TEST_PROPERTIES);
         props.setProperty(TENANT_ID_ATTRIB, tenantId);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/79838c0d/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PVarchar.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PVarchar.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PVarchar.java
index fb5a045..a99925c 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PVarchar.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/types/PVarchar.java
@@ -102,15 +102,17 @@ public class PVarchar extends PDataType<String> {
             SortOrder sortOrder, Integer maxLength, Integer scale,
             Integer desiredMaxLength, Integer desiredScale) {
         if (ptr.getLength() != 0 && desiredMaxLength != null) {
-            if (maxLength == null) {
+            if (maxLength == null || maxLength > desiredMaxLength) {
                 if (value != null) { // Use value if provided
                     maxLength = value.toString().length();
                 } else {
-                    coerceBytes(ptr, value, srcType, maxLength, scale, sortOrder, desiredMaxLength, desiredScale, sortOrder, true);
-                    maxLength = StringUtil.calculateUTF8Length(ptr.get(), ptr.getOffset(), ptr.getLength(), sortOrder);
+                    coerceBytes(ptr, value, srcType, maxLength, scale, sortOrder, desiredMaxLength,
+                        desiredScale, sortOrder, true);
+                    maxLength = StringUtil
+                        .calculateUTF8Length(ptr.get(), ptr.getOffset(), ptr.getLength(), sortOrder);
                 }
+                return maxLength <= desiredMaxLength;
             }
-            return maxLength <= desiredMaxLength;
         }
         return true;
     }


[6/7] phoenix git commit: PHOENIX-4678 ndexScrutinyTool generates malformed query due to incorrect table name(s) (Josh Elser)

Posted by ja...@apache.org.
PHOENIX-4678 ndexScrutinyTool generates malformed query due to incorrect table name(s) (Josh Elser)


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

Branch: refs/heads/4.x-HBase-1.1
Commit: 6b5130d29f5605509ffad07a7c9d8c0e406a527b
Parents: d17dc04
Author: James Taylor <jt...@salesforce.com>
Authored: Wed May 9 12:50:22 2018 -0700
Committer: James Taylor <jt...@salesforce.com>
Committed: Wed May 9 13:23:13 2018 -0700

----------------------------------------------------------------------
 phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/6b5130d2/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java b/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java
index a73467a..153b377 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/util/SchemaUtil.java
@@ -1103,7 +1103,7 @@ public class SchemaUtil {
      * @return the byte representation of the HTable
      */
     public static String getQualifiedTableName(String schemaName, String tableName) {
-        if (schemaName != null) {
+        if (schemaName != null && !schemaName.isEmpty()) {
             return String.format("%s.%s", normalizeIdentifier(schemaName),
                     normalizeIdentifier(tableName));
         } else {