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

[Bug] case when expr with abs function return null #9419

Closed
2 of 3 tasks
morningman opened this issue May 6, 2022 · 0 comments · Fixed by #9493
Closed
2 of 3 tasks

[Bug] case when expr with abs function return null #9419

morningman opened this issue May 6, 2022 · 0 comments · Fixed by #9493

Comments

@morningman
Copy link
Contributor

Search before asking

  • I had searched in the issues and found no similar issues.

Version

master

What's Wrong?

CREATE TABLE IF NOT EXISTS test.dws_scan_qrcode_user_ts
(
    dt DATE NOT NULL COMMENT "消费日期",
    hour_time INT NOT NULL COMMENT "小时",
    merchant_id INT NOT NULL COMMENT "商户id",
    channel_id char(5) NOT NULL COMMENT "渠道编码",
    station_type char(5) NULL COMMENT "站点类型",
    station_name varchar(55) NULL COMMENT "站点名",
   `source` char(5) NULL COMMENT "来源",
    passenger_flow BIGINT SUM DEFAULT '1' COMMENT "客流量",
    user_id bitmap BITMAP_UNION COMMENT "用户id集合",
    price BIGINT SUM COMMENT "金额",
    discount BIGINT SUM COMMENT "折扣后金额"
)
AGGREGATE KEY(dt,hour_time, merchant_id,channel_id,station_type,station_name,`source`)
DISTRIBUTED BY HASH(dt,hour_time,merchant_id,channel_id) BUCKETS 1
PROPERTIES("replication_num" = "1");


INSERT INTO `dws_scan_qrcode_user_ts` (`dt`, `hour_time`, `merchant_id`, `channel_id`, `station_type`, `station_name`, `source`, `passenger_flow`, `user_id`, `price`, `discount`) VALUES ('2019-01-01', 1, 45010002, '01', '00', 'xx站', '', 1, to_bitmap(0), 300, 300);
INSERT INTO `dws_scan_qrcode_user_ts` (`dt`, `hour_time`, `merchant_id`, `channel_id`, `station_type`, `station_name`, `source`, `passenger_flow`, `user_id`, `price`, `discount`) VALUES ('2019-01-01', 1, 45010002, '01', '00', 'xxx站', '', 3, to_bitmap(0), 400, 400);
INSERT INTO `dws_scan_qrcode_user_ts` (`dt`, `hour_time`, `merchant_id`, `channel_id`, `station_type`, `station_name`, `source`, `passenger_flow`, `user_id`, `price`, `discount`) VALUES ('2019-01-01', 2, 45010002, '00', '01', 'xx站', 'CHL', 1, to_bitmap(0), NULL, 23);
INSERT INTO `dws_scan_qrcode_user_ts` (`dt`, `hour_time`, `merchant_id`, `channel_id`, `station_type`, `station_name`, `source`, `passenger_flow`, `user_id`, `price`, `discount`) VALUES ('2019-01-01', 3, 45010002, '00', '00', 'xx站', 'CHL', 1, to_bitmap(0), NULL, NULL);
INSERT INTO `dws_scan_qrcode_user_ts` (`dt`, `hour_time`, `merchant_id`, `channel_id`, `station_type`, `station_name`, `source`, `passenger_flow`, `user_id`, `price`, `discount`) VALUES ('2019-01-01', 3, 45010002, '01', '00', 'xxxx站', '', 4, to_bitmap(0), 60, 60);
INSERT INTO `dws_scan_qrcode_user_ts` (`dt`, `hour_time`, `merchant_id`, `channel_id`, `station_type`, `station_name`, `source`, `passenger_flow`, `user_id`, `price`, `discount`) VALUES ('2019-01-01', 3, 45010002, '01', '00', 'xxxx站', '', 2, to_bitmap(0), 200, 200);
INSERT INTO `dws_scan_qrcode_user_ts` (`dt`, `hour_time`, `merchant_id`, `channel_id`, `station_type`, `station_name`, `source`, `passenger_flow`, `user_id`, `price`, `discount`) VALUES ('2019-01-01', 4, 45010002, '01', '00', 'xxxx站', '', 5, to_bitmap(0), 1000, 1000);
INSERT INTO `dws_scan_qrcode_user_ts` (`dt`, `hour_time`, `merchant_id`, `channel_id`, `station_type`, `station_name`, `source`, `passenger_flow`, `user_id`, `price`, `discount`) VALUES ('2019-01-01', 4, 45010002, '01', '00', 'xxx站', '', 1, to_bitmap(0), 20, 20);


select
  hour_time as date_hour,
  station_type,
  CASE WHEN station_type = '00' THEN sum(passenger_flow)
  ELSE -ABS(sum(passenger_flow))
  end passenger_flow
from
  test.dws_scan_qrcode_user_ts
where
  dt = '2019-01-01'
  and merchant_id in (45010002, 45010003)
  and channel_id = '00'
group by 
  hour_time,
    station_type;

passenger_flow should not be null.
Turn on vec, the result is right.

What You Expected?

return right result

How to Reproduce?

No response

Anything Else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

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

Successfully merging a pull request may close this issue.

1 participant