xy720 opened a new issue #4645:
URL: https://github.com/apache/incubator-doris/issues/4645
**Describe the bug**
If there are different scalar types in case-when-then-else with group by
clause, an error will report.
For example, there is a 9 columns table named test_tbl:
```
+----------------------+-------------+------+-------+---------------------+---------+
| Field | Type | Null | Key | Default |
Extra |
+----------------------+-------------+------+-------+---------------------+---------+
| event_day | INT | No | true | NULL |
|
| event_hour | TINYINT | No | true | 0 |
|
| event_minute | TINYINT | No | true | 0 |
|
| event_time | DATETIME | No | true | 1970-01-01 00:00:00 |
|
| search_page | VARCHAR(30) | No | true | |
|
| search_source | TINYINT | No | true | 0 |
|
| soft_version | VARCHAR(30) | No | true | |
|
| not_arrived_category | VARCHAR(30) | No | true | |
|
| pv | FLOAT | No | false | 0 |
REPLACE |
+----------------------+-------------+------+-------+---------------------+---------+
```
The following sql will report an analysis error.
```
SELECT
a.event_day,
a.search_page,
GROUP_CONCAT(a.search_source) AS search_source,
a.soft_version,
sum(b.pv) AS daoda_pv,
sum(b.new_pv) AS new_daoda_pv,
sum(a.pv) AS total_pv,
sum(b.pv) / sum(a.pv) * 100 AS arrived_rate,
sum(b.new_pv) / sum(a.pv) * 100 AS new_arrived_rate
FROM
(
SELECT
event_day,
case when '' = '' then 'all' else '' end as search_page,
case when "('1','2','5')" = '' then 'all' else search_source end as
search_source,
case when '' = '' then 'all' else '' end as soft_version,
SUM(pv) AS pv
FROM baiduapp_strategy_performance_search_ios_arrive
WHERE event_day BETWEEN 20200908 and 20200914
AND 1=1
AND search_source in ('1','2','5')
AND 1=1
AND soft_version >= '11.23.0.0'
GROUP BY event_day,search_page,search_source,soft_version
ORDER BY search_source
) a
LEFT JOIN
(
SELECT
event_day,
case when '' = '' then 'all' else '' end as search_page,
case when "('1','2','5')" = '' then 'all' else search_source end as
search_source,
case when '' = '' then 'all' else '' end as soft_version,
SUM(if(not_arrived_category = '', pv, 0)) AS pv,
SUM(pv) AS new_pv
FROM baiduapp_strategy_performance_search_ios_arrive
WHERE event_day BETWEEN 20200908 and 20200914
AND 1=1
AND search_source in ('1','2','5')
AND 1=1
AND not_arrived_category in ('', 'stay_too_short')
AND soft_version >= '11.23.0.0'
GROUP BY event_day,search_page,search_source,soft_version
ORDER BY search_source
) b ON a.event_day = b.event_day
AND a.search_page = b.search_page
AND a.search_source = b.search_source
AND a.soft_version = b.soft_version
GROUP BY
a.event_day,
a.search_page,
a.soft_version
ORDER BY event_day DESC
limit 0, 5000
```
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]