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 2014/10/20 08:41:10 UTC

[1/2] git commit: PHOENIX-1368 Persist link from VIEW back to its child VIEW

Repository: phoenix
Updated Branches:
  refs/heads/master b8f32aeaa -> 91004269a


PHOENIX-1368 Persist link from VIEW back to its child VIEW


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

Branch: refs/heads/master
Commit: 1ceaccef33f985900829685732da54268c65bcca
Parents: 571c594
Author: James Taylor <jt...@salesforce.com>
Authored: Sun Oct 19 23:46:39 2014 -0700
Committer: James Taylor <jt...@salesforce.com>
Committed: Sun Oct 19 23:46:39 2014 -0700

----------------------------------------------------------------------
 .../coprocessor/MetaDataEndpointImpl.java       |  2 --
 .../phoenix/jdbc/PhoenixDatabaseMetaData.java   |  4 ++++
 .../apache/phoenix/schema/MetaDataClient.java   | 22 ++++++++++++++++++++
 .../java/org/apache/phoenix/schema/PTable.java  |  6 +++++-
 4 files changed, 31 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/phoenix/blob/1ceaccef/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
index 111eff3..e690668 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/coprocessor/MetaDataEndpointImpl.java
@@ -595,8 +595,6 @@ public class MetaDataEndpointImpl extends MetaDataProtocol implements Coprocesso
                   addIndexToTable(tenantId, schemaName, famName, tableName, clientTimeStamp, indexes);
               } else if (linkType == LinkType.PHYSICAL_TABLE) {
                   physicalTables.add(famName);
-              } else {
-                  logger.warn("Unknown link type: " + colKv.getValueArray()[colKv.getValueOffset()] + " for " + SchemaUtil.getTableName(schemaName.getString(), tableName.getString()));
               }
           } else {
               addColumnToTable(results, colName, famName, colKeyValues, columns, saltBucketNum != null);

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1ceaccef/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDatabaseMetaData.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDatabaseMetaData.java b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDatabaseMetaData.java
index 54dfae3..a4976cb 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDatabaseMetaData.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/jdbc/PhoenixDatabaseMetaData.java
@@ -250,6 +250,10 @@ public class PhoenixDatabaseMetaData implements DatabaseMetaData, org.apache.pho
     public static final byte[] MAX_KEY_BYTES = Bytes.toBytes(MAX_KEY);
     public static final String LAST_STATS_UPDATE_TIME = "LAST_STATS_UPDATE_TIME";
     public static final byte[] LAST_STATS_UPDATE_TIME_BYTES = Bytes.toBytes(LAST_STATS_UPDATE_TIME);
+
+    public static final String PARENT_TENANT_ID = "PARENT_TENANT_ID";
+    public static final byte[] PARENT_TENANT_ID_BYTES = Bytes.toBytes(PARENT_TENANT_ID);
+        
     private final PhoenixConnection connection;
     private final ResultSet emptyResultSet;
 

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1ceaccef/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
index 924906e..1f26274 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/MetaDataClient.java
@@ -42,6 +42,7 @@ import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.LINK_TYPE;
 import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.MULTI_TENANT;
 import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.NULLABLE;
 import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.ORDINAL_POSITION;
+import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.PARENT_TENANT_ID;
 import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.PHYSICAL_NAME;
 import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.PK_NAME;
 import static org.apache.phoenix.jdbc.PhoenixDatabaseMetaData.REGION_NAME;
@@ -185,6 +186,15 @@ public class MetaDataClient {
             COLUMN_FAMILY + "," +
             LINK_TYPE +
             ") VALUES (?, ?, ?, ?, ?)";
+    private static final String CREATE_VIEW_LINK =
+            "UPSERT INTO " + SYSTEM_CATALOG_SCHEMA + ".\"" + SYSTEM_CATALOG_TABLE + "\"( " +
+            TENANT_ID + "," +
+            TABLE_SCHEM + "," +
+            TABLE_NAME + "," +
+            COLUMN_FAMILY + "," +
+            LINK_TYPE + "," +
+            PARENT_TENANT_ID + " " + PDataType.VARCHAR.getSqlTypeName() + // Dynamic column for now to prevent schema change
+            ") VALUES (?, ?, ?, ?, ?, ?)";
     private static final String INCREMENT_SEQ_NUM =
             "UPSERT INTO " + SYSTEM_CATALOG_SCHEMA + ".\"" + SYSTEM_CATALOG_TABLE + "\"( " + 
             TENANT_ID + "," +
@@ -1213,6 +1223,18 @@ public class MetaDataClient {
                     columns = newArrayListWithExpectedSize(allColumns.size() + colDefs.size());
                     columns.addAll(allColumns);
                     pkColumns = newLinkedHashSet(parent.getPKColumns());
+                    
+                    // Add row linking from view to its parent table
+                    // FIXME: not currently used, but see PHOENIX-1367
+                    // as fixing that will require it's usage.
+                    PreparedStatement linkStatement = connection.prepareStatement(CREATE_VIEW_LINK);
+                    linkStatement.setString(1, connection.getTenantId() == null ? null : connection.getTenantId().getString());
+                    linkStatement.setString(2, schemaName);
+                    linkStatement.setString(3, tableName);
+                    linkStatement.setString(4, parent.getName().getString());
+                    linkStatement.setByte(5, LinkType.PARENT_TABLE.getSerializedValue());
+                    linkStatement.setString(6, parent.getTenantId() == null ? null : parent.getTenantId().getString());
+                    linkStatement.execute();
                 }
             } else {
                 columns = newArrayListWithExpectedSize(colDefs.size());

http://git-wip-us.apache.org/repos/asf/phoenix/blob/1ceaccef/phoenix-core/src/main/java/org/apache/phoenix/schema/PTable.java
----------------------------------------------------------------------
diff --git a/phoenix-core/src/main/java/org/apache/phoenix/schema/PTable.java b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTable.java
index d59e9c0..35e7964 100644
--- a/phoenix-core/src/main/java/org/apache/phoenix/schema/PTable.java
+++ b/phoenix-core/src/main/java/org/apache/phoenix/schema/PTable.java
@@ -124,7 +124,11 @@ public interface PTable {
         /**
          * Link from a view to its physical table
          */
-        PHYSICAL_TABLE((byte)2);
+        PHYSICAL_TABLE((byte)2),
+        /**
+         * Link from a view to its parent table
+         */
+        PARENT_TABLE((byte)3);
 
         private final byte[] byteValue;
         private final byte serializedValue;


[2/2] git commit: Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/phoenix

Posted by ja...@apache.org.
Merge branch 'master' of https://git-wip-us.apache.org/repos/asf/phoenix


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

Branch: refs/heads/master
Commit: 91004269ad1f51f4fba86f08d22776e6141fe82f
Parents: 1ceacce b8f32ae
Author: James Taylor <jt...@salesforce.com>
Authored: Sun Oct 19 23:47:00 2014 -0700
Committer: James Taylor <jt...@salesforce.com>
Committed: Sun Oct 19 23:47:00 2014 -0700

----------------------------------------------------------------------
 bin/end2endTest.py                              | 16 +++++----
 bin/phoenix_utils.py                            | 34 +++++++++++++++++---
 bin/psql.py                                     |  2 +-
 bin/sqlline.py                                  |  2 +-
 .../phoenix/iterate/SpoolingResultIterator.java |  2 +-
 5 files changed, 42 insertions(+), 14 deletions(-)
----------------------------------------------------------------------