kasakrisz opened a new pull request, #4745: URL: https://github.com/apache/hive/pull/4745
<!-- 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? Set nullability to of `sum` aggregate function return type based on the parameter type. ### Why are the changes needed? Materialized view rewrite algorithm compares all aggregate function return types in a candidate MV and the query plan about to replace. Nullability is also checked. Currently if `sum` aggregate function is explicitly defined in a query (or MV definition) the return type is nullable however if it is introduced by [HiveAggregateReduceFunctionsRule](https://github.com/apache/hive/blob/f5d4bf89fb37458a3818d5d5c612b29defb1daa5/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/HiveAggregateReduceFunctionsRule.java#L326C19-L354) the return type is always not null due to Hive customization of [HiveTypeSystemImpl.deriveSumType](https://github.com/apache/hive/blob/f5d4bf89fb37458a3818d5d5c612b29defb1daa5/ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/HiveTypeSystemImpl.java#L174-L187) The original Calcite version of this function can not be used because it would always increase the precision of decimal return types to maximum and it would also decrease the scale in some cases. Example: the scale would be reduced to 10 in the first column in the following example https://github.com/apache/hive/blob/f5d4bf89fb37458a3818d5d5c612b29defb1daa5/ql/src/test/results/clientpositive/llap/decimal_precision.q.out#L603 ### Does this PR introduce _any_ user-facing change? No, but some query's plan may changes. ### Is the change a dependency upgrade? No. ### How was this patch tested? ``` mvn test -Dtest.output.overwrite -DskipSparkTests -Dtest=TestMiniLlapLocalCliDriver -Dqfile=materialized_view_create_rewrite_11.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: gitbox-unsubscr...@hive.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: gitbox-unsubscr...@hive.apache.org For additional commands, e-mail: gitbox-h...@hive.apache.org