kasakrisz opened a new pull request, #4277:
URL: https://github.com/apache/hive/pull/4277
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines:
https://cwiki.apache.org/confluence/display/Hive/HowToContribute
2. Ensure that you have created an issue on the Hive project JIRA:
https://issues.apache.org/jira/projects/HIVE/summary
3. Ensure you have added or run the appropriate tests for your PR:
4. If the PR is unfinished, add '[WIP]' in your PR title, e.g.,
'[WIP]HIVE-XXXXX: Your PR title ...'.
5. Be sure to keep the PR description updated to reflect all changes.
6. Please write your PR title to summarize what this PR proposes.
7. If possible, provide a concise example to reproduce the issue for a
faster review.
-->
### What changes were proposed in this pull request?
When transforming the logical plan of a materialized view insert-overwrite
rebuild to incremental rebuild wrap the case expression which aggregates the
values coming from the actual state of the view and the delta into a cast.
```
HiveProject(a=[$5], _o__c1=[CAST(CASE(IS NULL($1), $6, +($6,
$1))):DECIMAL(17, 2)], _o__c2=[CASE(IS NULL($2), $7, +($7, $2))],
_o__c3=[CAST(/(CAST(CASE(IS NULL($1), $6, +($6, $1))):DECIMAL(17, 2), CASE(IS
NULL($2), $7, +($7, $2)))):DECIMAL(11, 6)], _o__c4=[CASE(IS NULL($3), $8, +($8,
$3))])
HiveFilter(condition=[OR(AND($4, OR(AND(IS NULL($3), =($8, 0)),
AND(=(+($8, $3), 0), IS NOT NULL($3)))), AND(IS NULL($4), OR(AND(IS NULL($3),
>($8, 0)), AND(>(+($8, $3), 0), IS NOT NULL($3)))), AND($4, OR(AND(IS NULL($3),
>($8, 0)), AND(>(+($8, $3), 0), IS NOT NULL($3)))))])
HiveJoin(condition=[IS NOT DISTINCT FROM($0, $5)], joinType=[right],
algorithm=[none], cost=[not available])
HiveProject(a=[$0], _c1=[$1], _c2=[$2], _c4=[$4], $f4=[true])
HiveTableScan(table=[[default, mat1]], table:alias=[default.mat1])
HiveProject(a=[$0], $f1=[$1], $f2=[$2], $f3=[$3])
HiveAggregate(group=[{0}], agg#0=[SUM($1)], agg#1=[SUM($2)],
agg#2=[SUM($3)])
HiveProject(a=[$0], $f3=[CASE(OR($2, $5), *(-1, $1), $1)],
$f4=[CASE(OR($2, $5), *(-1, CASE(IS NULL($1), 0, 1)), CASE(IS NULL($1), 0,
1))], $f5=[CASE(OR($2, $5), -1, 1)])
HiveJoin(condition=[AND(=($0, $4), OR($3, $6))],
joinType=[inner], algorithm=[none], cost=[not available])
HiveProject(a=[$0], b=[$1], ROW__IS__DELETED=[$6], <=[<(3,
$5.writeid)])
HiveFilter(condition=[IS NOT NULL($0)])
HiveTableScan(table=[[default, t1]], table:alias=[t1])
HiveProject(a=[$0], ROW__IS__DELETED=[$5], <=[<(3,
$4.writeid)])
HiveFilter(condition=[IS NOT NULL($0)])
HiveTableScan(table=[[default, t2]], table:alias=[t2])
```
In the top project of the plan when aggregating decimal column an cast id
added.
```
CAST(CASE(IS NULL($1), $6, +($6, $1))):DECIMAL(17, 2)
```
### Why are the changes needed?
When and operation like addition has decimal operands the result type may
have a different decimal type.
```
Decimal(17,2) + Decimal(17,2) -> Decimal(18,2)
```
However Calcite rules expect the original and transformed row same row
schema to be equal.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
```
mvn test -Dtest.output.overwrite -Dtest=TestMiniLlapLocalCliDriver
-Dqfile=materialized_view_create_rewrite_6.q -pl itests/qtest -Pitests
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]