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
Recursive CTE returns less rows when using aggregate subquery [CORE3698] #4046
Comments
Commented by: Sean Leyne (seanleyne) Looks similar to case Core-3683 |
Commented by: @dyemanov A complete test case (including data) would be appreciated. Or try this example with the latest FB 3.0 snapshot build and report back. |
Commented by: Israel Lopez (ilopez) I just added two files, one SQL Schema file, and two CTE queries that expose the problem. On FB 2.5.0 - I see the problem. I guess consider this issue fixed for 3.0. |
Modified by: Israel Lopez (ilopez)Attachment: testcte.sql [ 12076 ] Attachment: testqueries.sql [ 12077 ] |
Modified by: @pcisarstatus: Resolved [ 5 ] => Closed [ 6 ] |
Modified by: @pavel-zotovQA Status: No test |
Modified by: @pavel-zotovstatus: Closed [ 6 ] => Closed [ 6 ] QA Status: No test => Covered by another test(s) Test Details: See test for CORE3683 |
Submitted by: Israel Lopez (ilopez)
Duplicates CORE3683
Attachments:
testcte.sql
testqueries.sql
This returns 12 rows
with recursive b (id, src, bomid, stagebomid,nextqty)
as
(
select http://bomitem.id, 'a' as src, bom.num as bomid, bomitem.stagebomid, 0 as nextqty
from bom
join bomitem on http://bom.id = bomitem.bomid
join part on http://part.id = bomitem.partid
JOIN (SELECT http://part.ID,SUM(COALESCE(tag.qty,0)) as qty FROM PART LEFT JOIN TAG ON TAG.PARTID = http://PART.ID GROUP BY 1) AS QOH ON http://QOH.ID = http://PART.ID
where bom.num = 'H0083'
select * from b
This also returns only 12 rows
with recursive b (id, src, bomid, stagebomid,nextqty)
as
(
select http://bomitem.id, 'a' as src, bom.num as bomid, bomitem.stagebomid, 0 as nextqty
from bom
join bomitem on http://bom.id = bomitem.bomid
join part on http://part.id = bomitem.partid
JOIN (SELECT http://part.ID,SUM(0) as qty FROM PART GROUP BY 1) AS QOH ON http://QOH.ID = http://PART.ID
where bom.num = 'H0083'
select * from b
This returns the 15 rows I was looking for.
with recursive b (id, src, bomid, stagebomid,nextqty)
as
(
select http://bomitem.id, 'a' as src, bom.num as bomid, bomitem.stagebomid, 0 as nextqty
from bom
join bomitem on http://bom.id = bomitem.bomid
join part on http://part.id = bomitem.partid
JOIN (SELECT http://part.ID,0 as qty FROM PART) AS QOH ON http://QOH.ID = http://PART.ID
where bom.num = 'H0083'
select * from b
Maybe it is my misunderstandings of CTEs, but I imagine first query would work.
====== Test Details ======
See test for CORE3683
The text was updated successfully, but these errors were encountered: