You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues-all@impala.apache.org by "ASF subversion and git services (JIRA)" <ji...@apache.org> on 2019/03/25 22:29:00 UTC

[jira] [Commented] (IMPALA-7216) Invalid SQL generated by toSql functions in CreateViewStmt & AlterViewStmt

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

ASF subversion and git services commented on IMPALA-7216:
---------------------------------------------------------

Commit 77bdd9c1278844f88a972c53ce38b898f18bfe8e in impala's branch refs/heads/2.x from poojanilangekar
[ https://gitbox.apache.org/repos/asf?p=impala.git;h=77bdd9c ]

IMPALA-7216: Fix SQL generated by CreateViewStmt & AlterViewStmt

The toSql functions in CreateViewStmt and AlterViewStmt generated
invalid SQL by appending types to column definitions. This change
appends just the column names to fix it.

Testing: Added tests to ToSqlTest to verify it.

Change-Id: Ie2a834d4d8d11ba18262d2828f4829c80ed05190
Reviewed-on: http://gerrit.cloudera.org:8080/10886
Reviewed-by: Bikramjeet Vig <bi...@cloudera.com>
Tested-by: Impala Public Jenkins <im...@cloudera.com>


> Invalid SQL generated by toSql functions in CreateViewStmt & AlterViewStmt
> --------------------------------------------------------------------------
>
>                 Key: IMPALA-7216
>                 URL: https://issues.apache.org/jira/browse/IMPALA-7216
>             Project: IMPALA
>          Issue Type: Bug
>            Reporter: Pooja Nilangekar
>            Assignee: Pooja Nilangekar
>            Priority: Major
>
> The toSql functions in CreateViewStmt and AlterViewStmt generate SQL by appending types to the column definitions. This is invalid because view definitions should not specify the type of a column. The column type should be inherited from the source table. 
>  
> Example query to reproduce:
> {code:java}
> create view foo (a, b) as select int_col, bigint_col from functional.alltypes;
> {code}
> The SQL generated by the toSql() function:
> {code:java}
> CREATE VIEW foo(a INT, b BIGINT) AS SELECT int_col, bigint_col FROM functional.alltypes
> {code}
> Executing the query generated by toSql():
> {code:java}
> [localhost:21000] default> CREATE VIEW foo(a INT, b BIGINT) AS SELECT int_col, bigint_col FROM functional.alltypes;
> Query: CREATE VIEW foo(a INT, b BIGINT) AS SELECT int_col, bigint_col FROM functional.alltypes
> ERROR: AnalysisException: Syntax error in line 1:
> CREATE VIEW foo(a INT, b BIGINT) AS SELECT int...
>                   ^
> Encountered: INTEGER
> Expected: COMMENT, COMMA
> CAUSED BY: Exception: Syntax error
> {code}
> In other databases like MySQL and PostgreSQL, the view definition statements can't explicitly set the column types. The type of a column in a view should always be inherited from the source table.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-all-unsubscribe@impala.apache.org
For additional commands, e-mail: issues-all-help@impala.apache.org