-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Query: Simplify aliases for complex projection if being used in order by clause #6703
Comments
Another expression to alias is |
This is a necessity for the case of coalesce when it is inside a subquery because we need to copy order by on outer query but the columns for coalesce are not projected out hence generates invalid query like this.
|
@anpete @maumar - I was looking this in my current work. For complex expressions, we are able to alias the projection and use it in order by but for subquery it is failing because we generate different select expression (essentially the table aliases are different) because our subquerymodelvisitor will run twice on same qm. Thoughts where we should optimize this? |
@anpete @maumar - For all cases except subquery, alias-ing of ordering should be working. As explained above, to alias select expression in order by we need that subqueryExpression referencing same QM generating same SelectExpression. Do we want to keep this issue open now? Or merge into the larger issue? |
@smitpatel this got closed automatically when you pushed the commit, that might explain why no one answered 😄 Should it be reopened? Otherwise closed as fixed? |
We do alias complex projections appearing in projection & order by both and refer to the alias in order by clause. |
For query like this
We generate Sql like this
We can just alias the subquery in projection and use alias in order by clause as enhancement.
For model and more info see #6257
The text was updated successfully, but these errors were encountered: