You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@phoenix.apache.org by "Chinmay Kulkarni (Jira)" <ji...@apache.org> on 2020/07/21 00:32:00 UTC

[jira] [Comment Edited] (PHOENIX-6033) Unable to add back a parent column that was earlier dropped from a view

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

Chinmay Kulkarni edited comment on PHOENIX-6033 at 7/21/20, 12:31 AM:
----------------------------------------------------------------------

Not sure if this is by design, but discussions on PHOENIX-3534 indicate otherwise (reference, specifically this part:

*One corner case on this corner case is how we want to handle adding a column back to a view that has been dropped in the past (i.e. it's in the EXCLUDE_COLUMNS array). If the type, precision, and scale match the parent table, then we could allow it and just remove the column from the EXCLUDE_COLUMNS (and give an error otherwise).*

 Any idea if this was disallowed on purpose [~tdsilva]?
 FYI [~yanxinyi]


was (Author: ckulkarni):
Not sure if this is by design, but discussions on [PHOENIX-3534|https://issues.apache.org/jira/browse/PHOENIX-3534] indicate otherwise ([reference|https://issues.apache.org/jira/browse/PHOENIX-3534?focusedCommentId=15940904&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-15940904], specifically this part:
{noformat}
One corner case on this corner case is how we want to handle adding a column back to a view that has been dropped in the past (i.e. it's in the EXCLUDE_COLUMNS array). If the type, precision, and scale match the parent table, then we could allow it and just remove the column from the EXCLUDE_COLUMNS (and give an error otherwise).
{noformat}
Any idea if this was disallowed on purpose [~tdsilva]?
FYI [~yanxinyi]

> Unable to add back a parent column that was earlier dropped from a view
> -----------------------------------------------------------------------
>
>                 Key: PHOENIX-6033
>                 URL: https://issues.apache.org/jira/browse/PHOENIX-6033
>             Project: Phoenix
>          Issue Type: Bug
>    Affects Versions: 5.0.0, 4.15.0
>            Reporter: Chinmay Kulkarni
>            Priority: Major
>             Fix For: 5.1.0, 4.16.0
>
>
> In 4.14.3, we allowed adding a column (with the same name as a column inherited from the parent) back to a view, which was dropped in the past. In 4.x this is no longer allowed.
> Start 4.x server and run the following with a 4.x client:
> {code:sql}
> CREATE TABLE IF NOT EXISTS T (A INTEGER PRIMARY KEY, B INTEGER, C VARCHAR, D INTEGER);
> -- create view
> CREATE VIEW IF NOT EXISTS V (VA INTEGER, VB INTEGER) AS SELECT * FROM T WHERE B=200;
> UPSERT INTO V(A,B,C,D,VA,VB) VALUES (2, 200, 'def', -20, 91, 101);
> ALTER VIEW V DROP COLUMN C;
> SELECT * FROM V;
> +----+------+------+-----+------+
> | A  |  B   |  D   | VA  |  VB  |
> +----+------+------+-----+------+
> | 2  | 200  | -20  | 91  | 101  |
> +----+------+------+-----+------+
> ALTER VIEW C ADD C VARCHAR;
> -- The above add column step throws an error. It used to work before 4.15.
> {code}
> The stack trace for the error thrown is:
> {code:java}
> Error: ERROR 1012 (42M03): Table undefined. tableName=C (state=42M03,code=1012)
> org.apache.phoenix.schema.TableNotFoundException: ERROR 1012 (42M03): Table undefined. tableName=C
> 	at org.apache.phoenix.compile.FromCompiler$BaseColumnResolver.createTableRef(FromCompiler.java:777)
> 	at org.apache.phoenix.compile.FromCompiler$SingleTableColumnResolver.<init>(FromCompiler.java:442)
> 	at org.apache.phoenix.compile.FromCompiler$SingleTableColumnResolver.<init>(FromCompiler.java:434)
> 	at org.apache.phoenix.compile.FromCompiler$SingleTableColumnResolver.<init>(FromCompiler.java:425)
> 	at org.apache.phoenix.compile.FromCompiler.getResolver(FromCompiler.java:277)
> 	at org.apache.phoenix.schema.MetaDataClient.addColumn(MetaDataClient.java:3627)
> 	at org.apache.phoenix.jdbc.PhoenixStatement$ExecutableAddColumnStatement$1.execute(PhoenixStatement.java:1488)
> 	at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:415)
> 	at org.apache.phoenix.jdbc.PhoenixStatement$2.call(PhoenixStatement.java:397)
> 	at org.apache.phoenix.call.CallRunner.run(CallRunner.java:53)
> 	at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:396)
> 	at org.apache.phoenix.jdbc.PhoenixStatement.executeMutation(PhoenixStatement.java:384)
> 	at org.apache.phoenix.jdbc.PhoenixStatement.execute(PhoenixStatement.java:1886)
> 	at sqlline.Commands.execute(Commands.java:814)
> 	at sqlline.Commands.sql(Commands.java:754)
> 	at sqlline.SqlLine.dispatch(SqlLine.java:646)
> 	at sqlline.SqlLine.begin(SqlLine.java:510)
> 	at sqlline.SqlLine.start(SqlLine.java:233)
> 	at sqlline.SqlLine.main(SqlLine.java:175)
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)