[ 
https://issues.apache.org/jira/browse/HIVE-25805?focusedWorklogId=696408&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-696408
 ]

ASF GitHub Bot logged work on HIVE-25805:
-----------------------------------------

                Author: ASF GitHub Bot
            Created on: 15/Dec/21 07:22
            Start Date: 15/Dec/21 07:22
    Worklog Time Spent: 10m 
      Work Description: 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-unsubscr...@hive.apache.org

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


Issue Time Tracking
-------------------

    Worklog Id:     (was: 696408)
    Time Spent: 20m  (was: 10m)

> Wrong result when rebuilding MV with count(col) incrementally
> -------------------------------------------------------------
>
>                 Key: HIVE-25805
>                 URL: https://issues.apache.org/jira/browse/HIVE-25805
>             Project: Hive
>          Issue Type: Bug
>          Components: CBO, Materialized views
>            Reporter: Krisztian Kasa
>            Assignee: Krisztian Kasa
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> {code:java}
> create table t1(a char(15), b int) stored as orc TBLPROPERTIES 
> ('transactional'='true');
> insert into t1(a, b) values ('old', 1);
> create materialized view mat1 stored as orc TBLPROPERTIES 
> ('transactional'='true') as
> select t1.a, count(t1.b), count(*) from t1 group by t1.a;
> delete from t1 where b = 1;
> insert into t1(a,b) values
> ('new', null);
> alter materialized view mat1 rebuild;
> select * from mat1;
> {code}
> returns
> {code:java}
> new                   1       1
> {code}
> but, should be
> {code:java}
> new                   0       1
> {code}



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to