[
https://issues.apache.org/jira/browse/HIVE-30122?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Denys Kuzmenko updated HIVE-30122:
----------------------------------
Description:
{code:java}
┌────────────────────────────────────┬─────────────────────────────┬──────────────────────────────────┐
│ Query on a table with a unique key │ Default result │
Correct │
├────────────────────────────────────┼─────────────────────────────┼──────────────────────────────────┤
│ k, sum(x), count(x), count(*) │ 1,2,2,2 / 2,1,1,1 /
3,3,3,3 │ 1,20,2,2 / 2,20,1,1 / 3,NULL,0,3 │
├────────────────────────────────────┼─────────────────────────────┼──────────────────────────────────┤
│ k, y, sum(y) │ 1→2 / 2→1 / 3→3 │ 1→200 /
2→200 / 3→900 │
├────────────────────────────────────┼─────────────────────────────┼──────────────────────────────────┤
│ min(x) / max(x) │ fails to compile │ correct
values │
└────────────────────────────────────┴─────────────────────────────┴──────────────────────────────────┘
{code}
- SUM and COUNT(col) over a column from the unique side silently return the
other side's row count.
- No constraint is needed: uniqueness from a derived GROUP BY triggers it too.
- Reachable by default since HIVE-24084 (2020), which turned the unique path
on.
- Where: CalcitePlanner:2295 registers the rule whenever AGGR_JOIN_TRANSPOSE
|| AGGR_JOIN_TRANSPOSE_UNIQUE.
was:
{code:java}
┌────────────────────────────────────┬─────────────────────────────┬──────────────────────────────────┐
Query on a table with a unique key │ Default result
│ Correct │
├────────────────────────────────────┼─────────────────────────────┼──────────────────────────────────┤
│ k, sum(x), count(x), count(*) │ 1,2,2,2 / 2,1,1,1 /
3,3,3,3 │ 1,20,2,2 / 2,20,1,1 / 3,NULL,0,3 │
├────────────────────────────────────┼─────────────────────────────┼──────────────────────────────────┤
│ k, y, sum(y) │ 1→2 / 2→1 / 3→3 │ 1→200 /
2→200 / 3→900 │
├────────────────────────────────────┼─────────────────────────────┼──────────────────────────────────┤
│ min(x) / max(x) │ fails to compile │ correct
values │
└────────────────────────────────────┴─────────────────────────────┴──────────────────────────────────┘
{code}
- SUM and COUNT(col) over a column from the unique side silently return the
other side's row count.
- No constraint is needed: uniqueness from a derived GROUP BY triggers it too.
- Reachable by default since HIVE-24084 (2020), which turned the unique path
on.
- Where: CalcitePlanner:2295 registers the rule whenever AGGR_JOIN_TRANSPOSE
|| AGGR_JOIN_TRANSPOSE_UNIQUE.
> CBO: HiveAggregateJoinTransposeRule drops aggregate arguments from a unique
> join side, returning wrong results
> --------------------------------------------------------------------------------------------------------------
>
> Key: HIVE-30122
> URL: https://issues.apache.org/jira/browse/HIVE-30122
> Project: Hive
> Issue Type: Bug
> Reporter: Denys Kuzmenko
> Priority: Major
>
> {code:java}
> ┌────────────────────────────────────┬─────────────────────────────┬──────────────────────────────────┐
>
> │ Query on a table with a unique key │ Default result │
> Correct │
> ├────────────────────────────────────┼─────────────────────────────┼──────────────────────────────────┤
> │ k, sum(x), count(x), count(*) │ 1,2,2,2 / 2,1,1,1 /
> 3,3,3,3 │ 1,20,2,2 / 2,20,1,1 / 3,NULL,0,3 │
> ├────────────────────────────────────┼─────────────────────────────┼──────────────────────────────────┤
>
>
> │ k, y, sum(y) │ 1→2 / 2→1 / 3→3 │ 1→200
> / 2→200 / 3→900 │
>
>
> ├────────────────────────────────────┼─────────────────────────────┼──────────────────────────────────┤
>
>
> │ min(x) / max(x) │ fails to compile │
> correct values │
>
>
> └────────────────────────────────────┴─────────────────────────────┴──────────────────────────────────┘
> {code}
> - SUM and COUNT(col) over a column from the unique side silently return the
> other side's row count.
> - No constraint is needed: uniqueness from a derived GROUP BY triggers it
> too.
> - Reachable by default since HIVE-24084 (2020), which turned the unique path
> on.
> - Where: CalcitePlanner:2295 registers the rule whenever AGGR_JOIN_TRANSPOSE
> || AGGR_JOIN_TRANSPOSE_UNIQUE.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)