feat(binder): support Having clause and more flexible OrderBy #651
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.
Signed-off-by: lokax [email protected]
Having clause
Support having clause and alias
Forbid to generate:
Since the above of
Agg
is not necessarily aProject
, a more general way to generate binding is needed.I also push
AggCall
Expression into bingding vector in theInputRefResolver
The search process:
Step 1. Find binding for y + 1 expression
Step 2. If not found: Find binding for y expression
Problems with aliases
Because the return type of child needs to be known when the
BinaryOp(i + 1)
expression is bound.AliasRewriter
will rewrite alias expressions when generating the logical planMore flexible OrderBy
If the expression of
OrderBy
does not exist in the select list, an expression copy will be added to the select list to generate the correct binding.Change: select list: [column(x)] -> [column(x), column(y)]
If the select list has changed:
Also add an new
Project
above theOrderBy
to produce the correct output: [column(x), column(y)] -> [column(x)]Now
OrderBy
can support sort using expressions