You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@spark.apache.org by "Dongjoon Hyun (JIRA)" <ji...@apache.org> on 2018/10/31 06:06:00 UTC

[jira] [Assigned] (SPARK-25833) Update migration guide for Hive view compatibility

     [ https://issues.apache.org/jira/browse/SPARK-25833?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Dongjoon Hyun reassigned SPARK-25833:
-------------------------------------

    Assignee: Chenxiao Mao

> Update migration guide for Hive view compatibility
> --------------------------------------------------
>
>                 Key: SPARK-25833
>                 URL: https://issues.apache.org/jira/browse/SPARK-25833
>             Project: Spark
>          Issue Type: Documentation
>          Components: SQL
>    Affects Versions: 2.3.2
>            Reporter: Chenxiao Mao
>            Assignee: Chenxiao Mao
>            Priority: Minor
>             Fix For: 3.0.0
>
>
> Views without column names created by Hive are not readable by Spark.
> A simple example to reproduce this issue.
>  create a view via Hive CLI:
> {code:sql}
> hive> CREATE VIEW v1 AS SELECT * FROM (SELECT 1) t1
> {code}
> query that view via Spark
> {code:sql}
> spark-sql> select * from v1;
> Error in query: cannot resolve '`t1._c0`' given input columns: [1]; line 1 pos 7;
> 'Project [*]
> +- 'SubqueryAlias v1, `default`.`v1`
>    +- 'Project ['t1._c0]
>       +- SubqueryAlias t1
>          +- Project [1 AS 1#41]
>             +- OneRowRelation$
> {code}
> Check the view definition:
> {code:sql}
> hive> desc extended v1;
> OK
> _c0                 	int
> ...
> viewOriginalText:SELECT * FROM (SELECT 1) t1, 
> viewExpandedText:SELECT `t1`.`_c0` FROM (SELECT 1) `t1`
> ...
> {code}
> _c0 in above view definition is automatically generated by Hive, which is not recognizable by Spark.
>  see [Hive LanguageManual|https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=30746446&navigatingVersions=true#LanguageManualDDL-CreateView] for more details:
> {quote}If no column names are supplied, the names of the view's columns will be derived automatically from the defining SELECT expression. (If the SELECT contains unaliased scalar expressions such as x+y, the resulting view column names will be generated in the form _C0, _C1, etc.)
> {quote}



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

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