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

Jesus Camacho Rodriguez commented on HIVE-19191:
------------------------------------------------

[~ashutoshc], I updated the patch.

This patch fixes two issues observed while running tests with complex queries:
1) Assertion error described above. We were hitting this error because old 
formula to calculate the cost heuristically could generate an accumulated cost 
of a given subtree that was _less_ than the accumulated cost of its child.  The 
planner does not allow this. This was happening because when cost algorithm 
found a materialized view underneath a given operator, old formula would reduce 
the accumulated cost of the complete subtree rooted at that operator, instead 
of reducing the cost of the operator itself. That is precisely the change to 
fix the issue, fix consists on reducing the cost of the operators themselves 
instead of the subtree.
2) NPE when accessing subset best expression. Best expression for a given 
subset might not have been chosen yet when we are accessing the cost of the 
plan, hence we need to use this logic to use first _not null_ expression:
{code}
return getCost(Util.first(subset.getBest(), subset.getOriginal()), mq);
{code}
This is similar to other code paths in Calcite.

> Assertion error while running materialized view rewriting
> ---------------------------------------------------------
>
>                 Key: HIVE-19191
>                 URL: https://issues.apache.org/jira/browse/HIVE-19191
>             Project: Hive
>          Issue Type: Bug
>          Components: Materialized views
>    Affects Versions: 3.0.0
>            Reporter: Nita Dembla
>            Assignee: Jesus Camacho Rodriguez
>            Priority: Major
>         Attachments: HIVE-19191.01.patch, HIVE-19191.patch
>
>
> {code:sql}
> jdbc:hive2://localhost:10007/tpcds_bin_par> explain select 
> w_warehouse_name,avg(inv_quantity_on_hand)  from inventory ,warehouse where 
> inv_warehouse_sk = w_warehouse_sk group by w_warehouse_name;
> Error: Error running query: java.lang.AssertionError: rel 
> [rel#3663:HiveProject.HIVE.[](input=rel#3662:Subset#8.HIVE.[],$f0=$0,$f1=/($1,
>  $2))] has lower cost {1.248 rows, 1.248 cpu, 0.0 io} than best cost 
> {8.963453683875E8 rows, 7.967514387E8 cpu, 0.0 io} of subset 
> [rel#3664:Subset#9.HIVE.[]] (state=,code=0)
> {code}



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

Reply via email to