-
Notifications
You must be signed in to change notification settings - Fork 84
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
Joining dj.U
with aggregation result leads to incorrect result
#449
Comments
The short term work around for this issue is to wrap the result of aggregation with dj.U('max_val') * dj.relational_operand.Subquery.create(rel.aggr(rel2, max_val='max(vals)')) which is obviously very cumbersome and undesirable. |
Possibly related to #386 |
Actually since it would be best to avoid sub query when possible to avoid speed issues, we might want to allow |
Yes, as long as it operates correctly from the user's perspective. |
I'll follow up with a detail, but currently, query like the following seems to lead to incorrect query result:
This is caused by the fact that joining with
dj.U('max_val')
simply appends the attributemax_val
into the heading's primary keys, and when the other operand is an instance ofGroupBy
, then adding this attribute into the primary key attributes ofGroupBy
results in change in the aggregation target. To deal with this case, theGroupBy
must be wrapped in subquery first.The text was updated successfully, but these errors were encountered: