You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hive.apache.org by "Prasad Mujumdar (JIRA)" <ji...@apache.org> on 2013/12/03 19:38:36 UTC

[jira] [Commented] (HIVE-4742) A useless CAST makes Hive fail to create a VIEW based on an UNION

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

Prasad Mujumdar commented on HIVE-4742:
---------------------------------------

I guess its the same issue that is addressed by HIVE-4547

> A useless CAST makes Hive fail to create a VIEW based on an UNION
> -----------------------------------------------------------------
>
>                 Key: HIVE-4742
>                 URL: https://issues.apache.org/jira/browse/HIVE-4742
>             Project: Hive
>          Issue Type: Bug
>    Affects Versions: 0.11.0
>            Reporter: Nicolas Lalevée
>             Fix For: 0.12.0
>
>
> I create programmatically a script to create a view which is a union of all kind of event I have. To keep things simple, data are just blindly cast as STRING. It used to work with Hive 0.10, not anymore with 0.11.
> I tried to narrow down the simplest script. It seems that it only occurs if a least a view and an union is involved.
> Here is a failing script:
> {noformat}
> CREATE TABLE Event1 (d STRING, userid BIGINT, eventData1 STRING);
> CREATE TABLE Event2 (d STRING, userid BIGINT, eventData2 STRING);
> CREATE VIEW AllEventsTest
>   AS SELECT * FROM (
>     SELECT 'Event1' AS eventType, map('d', CAST(`d` AS STRING)) AS eventData FROM Event1
>     UNION ALL
>     SELECT 'Event2' AS eventType, map('d', CAST(`d` AS STRING)) AS eventData FROM Event2
> ) d;
> {noformat}
> There are warnings in the logs:
> {noformat}
> o.a.h.h.q.parse.TypeCheckProcFactory - Invalid type entry TOK_STRING=null
> o.a.h.h.q.parse.TypeCheckProcFactory - Invalid type entry TOK_STRING=null
> {noformat}
> And the error is:
> {noformat}
> FAILED: IllegalArgumentException replace op boundaries of <ReplaceOp@[@46,103:105='`d`',<26>,3:52]..[@46,103:105='`d`',<26>,3:52]:"`event1`.`d`"> overlap with previous <ReplaceOp@[@44,98:101='CAST',<48>,3:47]..[@51,116:116=')',<276>,3:65]:"`event1`.`d`">
> 10:52:51.024 [scoopMapredScheduler_Worker-9 ] [ERROR] org.apache.hadoop.hive.ql.Driver - FAILED: IllegalArgumentException replace op boundaries of <ReplaceOp@[@46,103:105='`d`',<26>,3:52]..[@46,103:105='`d`',<26>,3:52]:"`event1`.`d`"> overlap with previous <ReplaceOp@[@44,98:101='CAST',<48>,3:47]..[@51,116:116=')',<276>,3:65]:"`event1`.`d`">
> java.lang.IllegalArgumentException: replace op boundaries of <ReplaceOp@[@46,103:105='`d`',<26>,3:52]..[@46,103:105='`d`',<26>,3:52]:"`event1`.`d`"> overlap with previous <ReplaceOp@[@44,98:101='CAST',<48>,3:47]..[@51,116:116=')',<276>,3:65]:"`event1`.`d`">
>     at org.antlr.runtime.TokenRewriteStream.reduceToSingleOperationPerIndex(TokenRewriteStream.java:504)
>     at org.antlr.runtime.TokenRewriteStream.toString(TokenRewriteStream.java:374)
>     at org.antlr.runtime.TokenRewriteStream.toString(TokenRewriteStream.java:358)
>     at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.saveViewDefinition(SemanticAnalyzer.java:8781)
>     at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.analyzeInternal(SemanticAnalyzer.java:8689)
>     at org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:278)
>     at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:433)
>     at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:337)
>     at org.apache.hadoop.hive.ql.Driver.run(Driver.java:902)
>     at org.apache.hadoop.hive.service.HiveServer$HiveServerHandler.execute(HiveServer.java:198)
>     at org.apache.hadoop.hive.jdbc.HiveStatement.executeQuery(HiveStatement.java:192)
> {noformat}
> Here is a working script:
> {noformat}
> CREATE TABLE Event1 (d STRING, userid BIGINT, eventData1 STRING);
> CREATE TABLE Event2 (d STRING, userid BIGINT, eventData2 STRING);
> CREATE VIEW AllEventsTest
>   AS SELECT * FROM (
>     SELECT 'Event1' AS eventType, map('d', `d`, 'userid', CAST(`userid` AS STRING)) AS eventData FROM Event1
>     UNION ALL
>     SELECT 'Event2' AS eventType, map('d', `d`, 'userid', CAST(`userid` AS STRING)) AS eventData FROM Event2
> ) d;
> {noformat}



--
This message was sent by Atlassian JIRA
(v6.1#6144)