Repository navigation
Generate $setWindowFields and $year - #4598
Open
evanchooly wants to merge 1 commit into
Open
evanchooly wants to merge 1 commit into
evanchooly wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #4597. Self-reviewed only.
What this solves
Every
$setWindowFieldsexample was a gap ("stage $setWindowFields has no binding"), though Morphia'sSetWindowFieldsbuilder writes them all. For example:is
setWindowFields().partitionBy(year("$released")).sortBy(ascending("released")).output(output("cumulativeRuntimeForYear").operator(sum("$runtime")).window().documents("unbounded", "current")).All six documented examples now generate (497 → 503). They query the
moviessample dataset, which the tests don't load, so only their serialization is checked.Integration: 515 tests under Critter, then reflection, 0 failures. Audits suite: 446 tests, 0 failures, 4 skipped. No committed case changed.
How
$setWindowFieldsbinds as a named stage with no arguments.partitionBy,sortByandoutputare its options.output'sSetWindowFields.Output[]parameter gets a type-driven conversion, asSort[]already has. Each output field becomesoutput(name).operator(op), plus.window().documents(l, u)or.window().range(l, u[, unit]), where the unit is aTimeUnitconstant.window;SetWindowFieldsCodec's order);$year: bindsyear(Object), which four of the examples partition by.$setWindowFieldsjoins the named-argument operators in both rule ports.A generator gap fixed along the way
One-item argument arrays were emitted bare with no declared rule. For example,
{$year: ["$released"]}becameyear("$released"), which writes{$year: "$released"}. Now:SINGLE_ARGUMENT_ARRAYwhen that rule lists the operator.$yearis added to the list in both ports. For any other one-argument operator, it's a gap.{$sum: ["$a"]}), becausesum("$a")writes the argument bare. The exceptions arearrayandconcatArrays, which always write an array.The candidate check showed neither guard removes a committed case.
Decisions for review
Output/Windowcalls (output,operator,window,documents,range) are named inCaseGenerator, not indsl-bindings.json, the waySort's directions are. Binding verification doesn't check them, but integration's compile does.Review
Codex ran three local rounds: round 1 found the one-argument array case, round 2 the varargs one, and round 3 was clean. Each fix has a regression case in
GeneratorTest. The design doc and the progress log are updated.