[
https://issues.apache.org/jira/browse/HIVE-11880?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15220033#comment-15220033
]
Aihua Xu commented on HIVE-11880:
---------------------------------
The actual issue seems to be that we are mixing the column alias and column
name together. HIVE-13235 also has that problem where I tried to separate
alias from the real column name.
There is a visibility scope in a query like {{select 3 as col1 from tbl1 where
col1 is not null;}} in which 2 col1 have different meaning, the first one is
just an alias and the second one is table column name. Same for the following
query. The filter o_custkey<10 can not push down to the table TS since it's not
the table column. Of course, for this particular case, o_custkey will be
replaced with the constant and then the constant expression can be pushed to TS.
The fix seems to be, a column should have internal name, column name and alias.
The operators like SEL could have all of them and based on the usage, we should
choose column name or alias. I'm trying to address in HIVE-13235, but seems
always missing some cases.
{noformat}
SELECT o_orderkey
FROM (
SELECT `o_orderkey` ,
`o_custkey`
FROM `orders`
UNION ALL
SELECT `o_orderkey`,
0L AS `o_custkey`
FROM `orders`) `oo`
WHERE o_custkey<10;
{noformat}
> filter bug of UNION ALL when hive.ppd.remove.duplicatefilters=true and
> filter condition is type incompatible column
> ---------------------------------------------------------------------------------------------------------------------
>
> Key: HIVE-11880
> URL: https://issues.apache.org/jira/browse/HIVE-11880
> Project: Hive
> Issue Type: Bug
> Components: Logical Optimizer
> Affects Versions: 1.2.1
> Reporter: WangMeng
> Assignee: WangMeng
> Attachments: HIVE-11880.01.patch, HIVE-11880.02.patch,
> HIVE-11880.03.patch, HIVE-11880.04.patch
>
>
> For UNION ALL , when an union operator is constant column (such as '0L',
> BIGINT Type) and its corresponding column has incompatible type (such as INT
> type).
> Query with filter condition on type incompatible column on this UNION ALL
> will cause IndexOutOfBoundsException.
> Such as TPC-H table "orders",in the following query:
> Type of 'orders'.'o_custkey' is INT normally, while the type of
> corresponding constant column "0" is BIGINT( `0L AS `o_custkey` ).
> This following query (with filter "type incompatible column 'o_custkey' ")
> will fail with java.lang.IndexOutOfBoundsException :
> {code}
> set hive.cbo.enable=false;
> set hive.ppd.remove.duplicatefilters=true;
> CREATE TABLE `orders`(
> `o_orderkey` int,
> `o_custkey` int,
> `o_orderstatus` string,
> `o_totalprice` double,
> `o_orderdate` string,
> `o_orderpriority` string,
> `o_clerk` string,
> `o_shippriority` int,
> `o_comment` string);
> SELECT o_orderkey
> FROM (
> SELECT `o_orderkey` ,
> `o_custkey`
> FROM `orders`
> UNION ALL
> SELECT `o_orderkey`,
> 0L AS `o_custkey`
> FROM `orders`) `oo`
> WHERE o_custkey<10;
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)