You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@hive.apache.org by "ASF GitHub Bot (Jira)" <ji...@apache.org> on 2021/06/07 17:59:00 UTC

[jira] [Updated] (HIVE-25209) SELECT query with SUM function producing unexpected result

     [ https://issues.apache.org/jira/browse/HIVE-25209?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

ASF GitHub Bot updated HIVE-25209:
----------------------------------
    Labels: pull-request-available  (was: )

> SELECT query with SUM function producing unexpected result
> ----------------------------------------------------------
>
>                 Key: HIVE-25209
>                 URL: https://issues.apache.org/jira/browse/HIVE-25209
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Soumyakanti Das
>            Assignee: Soumyakanti Das
>            Priority: Major
>              Labels: pull-request-available
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> Hive: SELECT query with SUM function producing unexpected result
> Problem Statement:
> {noformat}
> SELECT SUM(1) FROM t1;
> ---- result: 0
> SELECT SUM(agg0) FROM (
>     SELECT SUM(1) as agg0 FROM t1 WHERE t1.c0 UNION ALL 
>     SELECT SUM(1) as agg0 FROM t1 WHERE NOT (t1.c0) UNION ALL 
>     SELECT SUM(1) as agg0 FROM t1 WHERE (t1.c0) IS NULL
>     ) as asdf;
> ---- result: null {noformat}
> Steps to reproduce:
> {noformat}
> DROP DATABASE IF EXISTS db5 CASCADE;
> CREATE DATABASE db5;
> use db5;
> CREATE TABLE IF NOT EXISTS t1(c0 boolean, c1 boolean);
> SELECT SUM(1) FROM t1;
> -- result: 0
> SELECT SUM(agg0) FROM (
>     SELECT SUM(1) as agg0 FROM t1 WHERE t1.c0 UNION ALL 
>     SELECT SUM(1) as agg0 FROM t1 WHERE NOT (t1.c0) UNION ALL 
>     SELECT SUM(1) as agg0 FROM t1 WHERE (t1.c0) IS NULL
>     ) as asdf;
> -- result: null {noformat}
> Observations:
> SELECT SUM(1) as agg0 FROM t1 WHERE t1.c0 = t1.c1; – will result in null
> Similarity with postgres, 
>  both the queries result in null
> Similarity with Impala,
>  both the queries result in null



--
This message was sent by Atlassian Jira
(v8.3.4#803005)