You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hive.apache.org by "Adam Kramer (JIRA)" <ji...@apache.org> on 2009/11/16 21:18:39 UTC

[jira] Commented: (HIVE-285) UNION ALL does not allow different types in the same column

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

Adam Kramer commented on HIVE-285:
----------------------------------

I am the guy asking for type conversion.

I think that the right thing to do in all cases with a UNION ALL command is to convert mismatched types to STRING.

The main argument for this is that the output of a UNION ALL is never actually used for anything--it must be wrapped in a SELECT statement which will then make use of the columns. If the SELECT statement selects the UNIONed item as a string (say, for output to local directory or the terminal) everything is converted to string anyway--or if not, it's used in a way that would cause one or both of the original column types to be converted in some way...and conversion to STRING and back does not lose information.

Certainly, data should stay in the appropriate type if possible, though. 

> UNION ALL does not allow different types in the same column
> -----------------------------------------------------------
>
>                 Key: HIVE-285
>                 URL: https://issues.apache.org/jira/browse/HIVE-285
>             Project: Hadoop Hive
>          Issue Type: Bug
>          Components: Query Processor
>    Affects Versions: 0.2.0, 0.3.0
>            Reporter: Zheng Shao
>            Assignee: Raghotham Murthy
>             Fix For: 0.3.0
>
>         Attachments: hive-285.1.patch, hive-285.2.patch
>
>
> {code}
> explain INSERT OVERWRITE TABLE t
>     SELECT s.r, s.c, sum(s.v) FROM
>     (
>       SELECT a.r AS r, a.c AS c, a.v AS v FROM t1 a
>       UNION ALL
>       SELECT b.r AS r, b.c AS c, 0 + b.v AS v FROM t2 b
>     ) s
>     GROUP BY s.r, s.c;
> {code}
> Both a and b have 3 string columns: r, c, and v.
> It compiled successfully but failed during runtime.
> "Explain" shows that the plan for the 2 union-all operands have different output types that are converged to STRING, but there is no UDFToString inserted for "0 + b.v AS v" and as a result, SerDe was failing because it expects a String but is passed a Double.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.