[MCOL-3343] Window Functions don't work with arithmetic operators or other functions Created: 2019-05-30 Updated: 2019-10-28 Resolved: 2019-07-05 |
|
| Status: | Closed |
| Project: | MariaDB ColumnStore |
| Component/s: | ExeMgr |
| Affects Version/s: | 1.1.5, 1.2.3 |
| Fix Version/s: | 1.2.5 |
| Type: | Task | Priority: | Major |
| Reporter: | David Hall (Inactive) | Assignee: | Daniel Lee (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||
| Sprint: | 2019-05, 2019-06 | ||||||||||||||||
| Description |
|
Discovered during QA: create table tb1 (d1 decimal(7,2), i1 int)engine=columnstore; select (sum(d1)*100.0) div sum(sum(d1)) over (partition by i1) from tb1 group by i1; This results in a random output in 1.2, and a 0 output in 1.1. The answer is 100 as can be seen when using innodb:
---------------------------------------------------------
--------------------------------------------------------- Using the divide operator '/' instead of the div function may result in a different set of random numbers. |
| Comments |
| Comment by David Hall (Inactive) [ 2019-05-31 ] | ||||||||||||||||
|
It appears that if one side of an arithmetic operator (or function like DIV) is an aggregate and the other is a Window Function, then somehow it gets the operator twice as a sub function of each side. When each is executed, the other side isn't available. Whichever gets done last is the final result. ExeMgr spins up threads for each, so in the following query: select count The count Somehow, the setup code is acting as if the '/' is inside of each function, rather than the root of the tree. This does not happen if we do aggregate <op> aggregate. Only if one side is a Window Function. | ||||||||||||||||
| Comment by David Hall (Inactive) [ 2019-06-14 ] | ||||||||||||||||
|
The title of this MCOL says incorrect in a specific case. That is incorrect. It's a much more general case involving more than one cause. After fixing the original compaint of agg/win, I thought to play around with more complex arithmetic formula involving window and aggregate functions and got a crash. Simplifying it down, it turns out something simple doesn't work:
--------------------
--------------------
-----
----- However, fixing this little problem may or may not cause this to work:
--------------------------------
-------------------------------- | ||||||||||||||||
| Comment by David Hall (Inactive) [ 2019-06-20 ] | ||||||||||||||||
|
Test case PR #121 For QA: The bug is manifest any time a Window Function is used with another function or arithmetic operator. See the regression tests in working_tpch1_compareLogOnly/windowFunctions/ | ||||||||||||||||
| Comment by David Hall (Inactive) [ 2019-06-20 ] | ||||||||||||||||
|
Once this bug is closed, then | ||||||||||||||||
| Comment by Daniel Lee (Inactive) [ 2019-07-05 ] | ||||||||||||||||
|
Build verified: 1.2.5-1 nightly erver commit: Verified test case in the ticket. |