-
Notifications
You must be signed in to change notification settings - Fork 28
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
Changeset values should honor comparators #238
Changeset values should honor comparators #238
Conversation
…mining what fields have changed
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.
Excellent catch! Only minor changes requested.
.filter(_.nonEmpty) | ||
.map(columns => | ||
concat( | ||
columns | ||
.map(c => when(left(backticks(c)) <=> right(backticks(c)), array()).otherwise(array(lit(c)))): _* | ||
.map(entry => when(entry._2.equiv(left(backticks(entry._1)), right(backticks(entry._1))), array()).otherwise(array(lit(entry._1)))): _* |
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.
I'd prefer naming the tuple elements, rather than using _1
and _2
:
.map(entry => when(entry._2.equiv(left(backticks(entry._1)), right(backticks(entry._1))), array()).otherwise(array(lit(entry._1)))): _* | |
.map { case (c, cmp) => | |
when(cmp.equiv(left(backticks(c)), right(backticks(c))), array()).otherwise(array(lit(c))) | |
}: _* |
val rs = left.diff(right, changesetOptions, "id") | ||
assert(rs.where($"diff" === "C").count() == 1, "Only id=3 should differ with the numeric comparator applied") | ||
val differingRow: Row = rs.where($"diff" === "C").head | ||
assert(differingRow.getList(1).size() == 1, "Only floatVal differs after considering the comparators so the changeset should be size 1") |
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.
Rather than testing for the size, can we test for the actual list content here?
Snapshot CI issues to be fixed in #1103. |
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.
LGTM!
Thanks for raising and fixing this! |
Please run |
This has been released. |
What type of PR is this?
This is an improvement PR with the goal of adjusting change column behavior so that it honors comparators when determining what fields have "changed".
What this PR does / why we need it:
If fields A and B differ from left to right for row1 then the changeset column produces an array [A, B] for row1.
If you then configure a comparator to equate the values in A, the changset column still produces an array [A, B] instead of the expected array [B]
Acceptance criteria / Notes for the reviewer
This PR alters the behavior and adds a test to verify it.