为了更快的定位您的问题,请提供以下信息,谢谢
【详述】问题详细描述 case when 中 when 成立 结果走了 else语句
【背景】做过哪些操作?
【业务影响】 相关功能无法使用
【是否存算分离】 是
【StarRocks版本】例如:3.2.3
【集群规模】例如:3fe(1 follower+2observer)+3be(fe与be混部)
【机器信息】CPU虚拟核/内存/网卡,例如:16C/64G/万兆
【联系方式】为了在解决问题过程中能及时联系到您获取一些日志信息,请补充下您的联系方式,例如:,谢谢
【附件】
- fe.log/beINFO/相应截图
- 慢查询:
- Profile信息
- 并行度:show variables like ‘%parallel_fragment_exec_instance_num%’;
- pipeline是否开启:show variables like ‘%pipeline%’;
- be节点cpu和内存使用率截图
- 查询报错:
- query_dump,怎么获取query_dump文件
- be crash
- be.out
- 外表查询报错
- be.out和fe.warn.log
create table common_sub_expression(sjnyr datetime);
insert into common_sub_expression values('2018-01-01 00:00:00');
insert into common_sub_expression values('2018-01-02 00:00:00');
insert into common_sub_expression values('2018-01-03 00:00:00');
insert into common_sub_expression values('2018-01-04 00:00:00');
insert into common_sub_expression values('2018-01-04 00:00:00');
insert into common_sub_expression values('2018-01-05 00:00:00');
insert into common_sub_expression values('2018-01-05 00:00:00');
insert into common_sub_expression values('2018-01-06 00:00:00');
insert into common_sub_expression values('2018-01-06 00:00:00');
select case when cast(_time_dynamic_sjnyr_qOk_Vdc as date) is not null
then cast(`_time_dynamic_sjnyr_qOk_Vdc` AS DATE)
ELSE STR_TO_JODATIME(`_time_dynamic_sjnyr_qOk_Vdc`, 'yyyy-MM') END AS `_time_dynamic_sjnyr_qOk_Vdc`
FROM (SELECT CAST(CAST(DATE_FORMAT(CAST(CAST(CAST(`sjnyr` AS DATETIME) AS DATE) AS DATETIME),
'%Y-%m-%d') AS DATE) AS VARCHAR) AS `_time_dynamic_sjnyr_qOk_Vdc`
FROM common_sub_expression AS `t2`) as t2
GROUP BY _time_dynamic_sjnyr_qOk_Vdc;
-- 正常结果应该是
select cast(_time_dynamic_sjnyr_qOk_Vdc as date)
FROM (SELECT CAST(CAST(DATE_FORMAT(CAST(CAST(CAST(`sjnyr` AS DATETIME) AS DATE) AS DATETIME),
'%Y-%m-%d') AS DATE) AS VARCHAR) AS `_time_dynamic_sjnyr_qOk_Vdc`
FROM common_sub_expression AS `t2`) as t2
GROUP BY _time_dynamic_sjnyr_qOk_Vdc;
错误结果:
正确结果: