Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-deterministic NPE with sum/case/when query #14911

Open
dang-stripe opened this issue Jan 23, 2025 · 0 comments
Open

Non-deterministic NPE with sum/case/when query #14911

dang-stripe opened this issue Jan 23, 2025 · 0 comments

Comments

@dang-stripe
Copy link
Contributor

dang-stripe commented Jan 23, 2025

We're getting non-deterministic NPEs on a null-enabled query that looks like this. We're using Pinot 1.2.

set enableNullHandling = true;
select m_id,
  sum(
    case
      when outcome = 'success' then 1
      else 0
    end
  ) as success,
  sum(
    case
      when outcome = 'failed' then 1
      else 0
    end
  ) as failed,
  sum(
    case
      when outcome = 'invalid' then 1
      else 0
    end
  ) as invalid,
from example_table 
where
  some_filter_condition = 'value'
group by 1
order by (success + failed + invalid) desc

Unfortunately, there's no stacktrace in the failure.

[2025-01-21 22:50:01.843739] ERROR [BaseCombineOperator] [pqw-92:90] Caught exception while processing query: QueryContext{_tableName='example_table_REALTIME', _subquery=null, _selectExpressions=[m_id, sum(case(equals(outcome,'success'),'1','0')), sum(case(equals(outcome,'failed'),'1','0')), sum(case(equals(outcome,'invalid'),'1','0'))], _distinct=false, _aliasList=[null, success, failed, invalid], _filter=(some_filter_condition = 'value'), _groupByExpressions=[m_id], _havingFilter=null, _orderByExpressions=null, _limit=10, _offset=0, _queryOptions={enableNullHandling=true}, _expressionOverrideHints={}, _explain=false} [2025-01-21 22:50:01.843748] java.lang.NullPointerException: null

Switching it to use COUNT(*) FILTER instead of sum/case/when works reliably.

COUNT(*) FILTER (WHERE outcome = 'success') as success,
COUNT(*) FILTER (WHERE outcome = 'failed') as failed,
COUNT(*) FILTER (WHERE outcome = 'invalid') as invalid,

I've also confirmed there's no null values for the outcome field.

cc @Jackie-Jiang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant