[MDEV-32907] spider incorrectly translates sum() query to a column Created: 2023-11-29 Updated: 2023-12-18 |
|
| Status: | Confirmed |
| Project: | MariaDB Server |
| Component/s: | Embedded Server, Storage Engine - Spider |
| Affects Version/s: | 10.4, 10.5, 10.6, 10.11, 11.0, 11.1, 11.2, 11.3, 11.4 |
| Fix Version/s: | 10.4, 10.5, 10.6, 10.11, 11.0, 11.1, 11.2, 11.3 |
| Type: | Bug | Priority: | Major |
| Reporter: | Iacovos Botsaris | Assignee: | Yuchen Pei |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | spider, spider-gbh | ||
| Issue Links: |
|
||||||||
| Description |
|
Hello, These are the spider configuration options I have in place:
The problem I have encountered, is related with combining the IFNULL() function with the SUM() function. A simple example is the following:
Whereas, while using COALESCE ,on the spider, this works as expected:
Essentially, the spider tries to find a column 'SUM(target_2)' instead of evaluating the function. Here is the create table statement on the Spider:
And here is the create table statement on the dataNode:
Of course, when I run the query directly against the dataNode, it executes successfully:
If removing SUM(), or IFNULL(), the query executes; the error occurs in the combination of both, whatever the query. IFNULL(SUM...) fails in all queries. Thank you |
| Comments |
| Comment by Yuchen Pei [ 2023-11-30 ] | ||||||||||||||||||||||||||||||
|
Hi, thanks for reporting. I could reproduce it in a simple case in
However, sum(nvl(c, 0)) works, have you tried to swap NVL with SUM in | ||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-11-30 ] | ||||||||||||||||||||||||||||||
|
I could reproduce it at 10.5 387b92df97e70680641ad0bcaed83b44373f13c5. select sum(t0.`c`) `sum(c)`,(ifnull(`sum(c)` , 0)) `nvl(sum(c), 0)` from `test`.`t2` t0 | ||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-11-30 ] | ||||||||||||||||||||||||||||||
|
However, when trying to build in 10.4
| ||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2023-11-30 ] | ||||||||||||||||||||||||||||||
|
Confirmed, all versions 10.4+ dbg+opt | ||||||||||||||||||||||||||||||
| Comment by Iacovos Botsaris [ 2023-11-30 ] | ||||||||||||||||||||||||||||||
|
Hello Yuchen Pei, thank you for the prompt response. | ||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-11-30 ] | ||||||||||||||||||||||||||||||
|
> Nevertheless, if I were to rewrite all queries, I would opt for COALESCE. May I ask why? | ||||||||||||||||||||||||||||||
| Comment by Iacovos Botsaris [ 2023-12-02 ] | ||||||||||||||||||||||||||||||
|
Hello, | ||||||||||||||||||||||||||||||
| Comment by Yuchen Pei [ 2023-12-14 ] | ||||||||||||||||||||||||||||||
|
I did some further analysis. The problem is that at exec stage, when
However, at optimizer stage, when the spider group by handler is
So, this is an example of MDEV-32273. |