phoenix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Samarth Jain (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (PHOENIX-978) Allow views to extend base table's PK (only if last PK column is fixed length)
Date Fri, 10 Jul 2015 22:42:05 GMT

    [ https://issues.apache.org/jira/browse/PHOENIX-978?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14623012#comment-14623012
] 

Samarth Jain commented on PHOENIX-978:
--------------------------------------

[~tdsilva] and I went through the code offline. Below were the changes we came up with:

In MetadataClient, we probably don't need to check if the number of PK columns is < 1
{code}
+    private boolean isLastPKVariableLength(PTable table) {
+        List<PColumn> pkColumns = table.getPKColumns();
+        if (pkColumns.size() < 1) {
+            return false;
+        } else {
+            return !pkColumns.get(pkColumns.size()-1).getDataType().isFixedWidth();
+        }
+    }
{code} 

When adding a PK column to the base table, we should validate that the sort order of the pk
column in the view is the same. 

The upgrade code currently checks column width/scale to see if the view has diverged from
the base table. We should be consistent and do the same check while adding column to the base
table. You would probably need to to tweak your tests to reflect the same.
It would be great to have tests around the above two scenarios.

There are a few other tests that can be added:
1) Disallow creating a view with a custom PK if the base table's last PK column is variable
length. The current test is doing this at the alter table add column. We should do the same
for create view too.

2) In testAddExistingViewPkColumnToBaseTableWithViews
- Add tests that add new PK column to the base table that is variable width. Currently it
is testing adding an existing column in the view.
- For verifying values, it would be better to do a getString(column name). 

3) Tests for the scenario below:
view1 (pkcol1, pkcol2), view2 (pkcol1, pkcol2)
alter table basetable add pkcol1 primary key, pkcol2 primary key -> should work
alter table basetable add pkcol2 primary key, pkcol1 primary key -> should fail





> Allow views to extend base table's PK (only if last PK column is fixed length)
> ------------------------------------------------------------------------------
>
>                 Key: PHOENIX-978
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-978
>             Project: Phoenix
>          Issue Type: Sub-task
>    Affects Versions: 3.0.0, 4.0.0
>            Reporter: Eli Levine
>            Assignee: Eli Levine
>             Fix For: 5.0.0, 4.5.0
>
>         Attachments: PHOENIX-978.diff, PHOENIX-978.patch
>
>
> CREATE VIEW syntax currently disallows PK constraint to be defined.  As a result views
and tenant-specific tables created using CREATE VIEW automatically inherit their base table's
PK with no way to extend it.
> Base tables should be allowed to be created with a minimum of PK columns to support views,
and views to extend PKs as desired.  This would allow a single base table to support a heterogeneous
set of views on top of it.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message