You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@hive.apache.org by GitBox <gi...@apache.org> on 2021/12/14 10:47:37 UTC

[GitHub] [hive] kasakrisz opened a new pull request #2872: HIVE-25805: Wrong result when rebuilding MV with count(col) incrementally

kasakrisz opened a new pull request #2872:
URL: https://github.com/apache/hive/pull/2872


   <!--
   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 generating incremental rebuild plan for MVs having aggregate and delete operations in any source tables check if the view definition contains any `count` aggregate function which has argument. If it has add expression to check if that argument is `null` or not. 
   
   ### Why are the changes needed?
   Records with `null` values should not be counted in the final aggregation.
   
   ### Does this PR introduce _any_ user-facing change?
   Yes. This patch fixes a data correctness issue.
   
   ### How was this patch tested?
   ```
   mvn test -Dtest.output.overwrite -DskipSparkTests -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: gitbox-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] kasakrisz merged pull request #2872: HIVE-25805: Wrong result when rebuilding MV with count(col) incrementally

Posted by GitBox <gi...@apache.org>.
kasakrisz merged pull request #2872:
URL: https://github.com/apache/hive/pull/2872


   


-- 
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-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org


[GitHub] [hive] kgyrtkirk commented on a change in pull request #2872: HIVE-25805: Wrong result when rebuilding MV with count(col) incrementally

Posted by GitBox <gi...@apache.org>.
kgyrtkirk commented on a change in pull request #2872:
URL: https://github.com/apache/hive/pull/2872#discussion_r769317236



##########
File path: ql/src/java/org/apache/hadoop/hive/ql/optimizer/calcite/rules/views/HiveAggregateInsertDeleteIncrementalRewritingRule.java
##########
@@ -139,7 +139,14 @@ protected IncrementalComputePlanWithDeletedRows createJoinRightInput(RelOptRuleC
       switch (aggregateCall.getAggregation().getKind()) {
         case COUNT:
           aggFunction = SqlStdOperatorTable.SUM;
-          argument = relBuilder.literal(1);
+
+          // count(*)
+          if (aggregateCall.getArgList().isEmpty()) {
+            argument = relBuilder.literal(1);
+          } else {
+            // count(<column_name>)
+            argument = genArgumentForCountColumn(relBuilder, rexBuilder, aggInput, aggregateCall);

Review comment:
       notes: I think you could access `rexBuilder` from `relBuilder`
   
   I think you could also push the encolsing `if` into this function; or inline the whole function - but right now you have some "count argument" related logic here and there too




-- 
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-unsubscribe@hive.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: gitbox-unsubscribe@hive.apache.org
For additional commands, e-mail: gitbox-help@hive.apache.org