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
Fix join subquery+map+distinct and sortBy+distinct #1462
Conversation
5c1210a
to
ef387a2
Compare
ef387a2
to
3c0c3c7
Compare
@@ -100,6 +106,15 @@ object ApplyMap { | |||
val t2 = BetaReduction(d, c -> Property(t, "_2")) | |||
Some(Map(Join(tpe, a, b, iA, c, onr), t, Tuple(List(t1, t2)))) | |||
|
|||
// a.*join(b.map(c => d).distinct).on((iA, iB) => on) | |||
// a.*join(b.distinct).on((iA, c) => on[iB := d]).map(t => (t._1, d[c := t._2])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This transformation doesn't seem valid. In b.map(c => d).distinct
, it'll return distinct mapped values, in b.distinct
it'll return distinct records considering all columns
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. I took this out.
3c0c3c7
to
2952d47
Compare
quill-sql/src/main/scala/io/getquill/context/sql/norm/ExpandDistinct.scala
Show resolved
Hide resolved
3a1365d
to
63669e8
Compare
8a6400c
to
7aff8fe
Compare
7aff8fe
to
0237f83
Compare
The merged implementation also fixed #1463. |
Fixes #1446, #1447 and #1472 as well as #1463.
@fwbrasil I would appreciate it if you could review AST transformation changes. This one seems to be a very simple solution. Am I missing anything?
Alternatively, maybe every single case of
DetachableMap
inApplyMap
should have a variant withDistinct(DetachableMap(...))
?Problem
Join+Distinct+Map fails:
Results in:
Solution
To fix #1446 add the following clause to
ApplyMap
:The following is then returned:
Same thing with #1447, add the following to
ApplyMap
:Then you will get:
README.md
if applicable[WIP]
to the pull request title if it's work in progresssbt scalariformFormat test:scalariformFormat
to make sure that the source files are formatted@getquill/maintainers