PHOENIX-3078. Hive storage handler does not work if phoenix.table.name contains 
the schema name

Signed-off-by: Sergey Soldatov <s...@apache.org>


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

Branch: refs/heads/4.x-HBase-1.0
Commit: c70fa534d0b688e55291c3bf4a800ea9ddbb0b65
Parents: 314a011
Author: Youngwoo Kim <yw...@apache.org>
Authored: Sun Jul 17 17:45:15 2016 +0900
Committer: Sergey Soldatov <s...@apache.org>
Committed: Fri Jul 22 00:09:41 2016 -0700

----------------------------------------------------------------------
 .../src/main/java/org/apache/phoenix/hive/PhoenixMetaHook.java | 2 +-
 .../main/java/org/apache/phoenix/hive/util/PhoenixUtil.java    | 6 ++++--
 2 files changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/c70fa534/phoenix-hive/src/main/java/org/apache/phoenix/hive/PhoenixMetaHook.java
----------------------------------------------------------------------
diff --git 
a/phoenix-hive/src/main/java/org/apache/phoenix/hive/PhoenixMetaHook.java 
b/phoenix-hive/src/main/java/org/apache/phoenix/hive/PhoenixMetaHook.java
index d920517..ae3675f 100644
--- a/phoenix-hive/src/main/java/org/apache/phoenix/hive/PhoenixMetaHook.java
+++ b/phoenix-hive/src/main/java/org/apache/phoenix/hive/PhoenixMetaHook.java
@@ -139,7 +139,7 @@ public class PhoenixMetaHook implements HiveMetaHook {
                 ddl.append("  ").append(columnName).append(" 
").append(columnType).append(",\n");
             }
         }
-        ddl.append("  ").append("constraint pk_").append(tableName).append(" 
primary key(")
+        ddl.append("  ").append("constraint 
pk_").append(PhoenixUtil.getTableSchema(tableName.toUpperCase())[1]).append(" 
primary key(")
                 .append(realRowKeys.deleteCharAt(realRowKeys.length() - 
1)).append(")\n)\n");
 
         String tableOptions = 
tableParameterMap.get(PhoenixStorageHandlerConstants

http://git-wip-us.apache.org/repos/asf/phoenix/blob/c70fa534/phoenix-hive/src/main/java/org/apache/phoenix/hive/util/PhoenixUtil.java
----------------------------------------------------------------------
diff --git 
a/phoenix-hive/src/main/java/org/apache/phoenix/hive/util/PhoenixUtil.java 
b/phoenix-hive/src/main/java/org/apache/phoenix/hive/util/PhoenixUtil.java
index 5f9b0ba..9dcb3ef 100644
--- a/phoenix-hive/src/main/java/org/apache/phoenix/hive/util/PhoenixUtil.java
+++ b/phoenix-hive/src/main/java/org/apache/phoenix/hive/util/PhoenixUtil.java
@@ -71,7 +71,8 @@ public class PhoenixUtil {
         boolean exist = false;
         DatabaseMetaData dbMeta = conn.getMetaData();
 
-        try (ResultSet rs = dbMeta.getTables(null, null, 
tableName.toUpperCase(), null)) {
+        String[] schemaInfo = getTableSchema(tableName.toUpperCase());
+        try (ResultSet rs = dbMeta.getTables(null, schemaInfo[0], 
schemaInfo[1], null)) {
             exist = rs.next();
 
             if (LOG.isDebugEnabled()) {
@@ -91,7 +92,8 @@ public class PhoenixUtil {
         Map<Short, String> primaryKeyColumnInfoMap = Maps.newHashMap();
         DatabaseMetaData dbMeta = conn.getMetaData();
 
-        try (ResultSet rs = dbMeta.getPrimaryKeys(null, null, 
tableName.toUpperCase())) {
+        String[] schemaInfo = getTableSchema(tableName.toUpperCase());
+        try (ResultSet rs = dbMeta.getPrimaryKeys(null, schemaInfo[0], 
schemaInfo[1])) {
             while (rs.next()) {
                 primaryKeyColumnInfoMap.put(rs.getShort("KEY_SEQ"), 
rs.getString("COLUMN_NAME"));
             }

Reply via email to