Disallow ORDER BY literal in window functions#15485
Conversation
rongrong
left a comment
There was a problem hiding this comment.
While I agree with this change in principle, since this is backward incompatible, we should add a session property that's by default not enabled for the next release, add a warning to say that this feature is not what you think it is, and will be removed in future releases. And then maybe a few release later we would switch the default behavior. Then removing the session property.
I agree we should have a way to disable it but I think default should be fail as the fix is trivial or they can just turn on the session property. |
Overall any unannounced behavior change will never be associated with good user experience. But if you insist the default is fail, at least make it clear in error message how to fix / disable it. And make sure when we deploy it, the default is changed in our internal configuration, unless you already made sure that all affected pipelines are fixed beforehand. |
083900e to
970f365
Compare
|
So added a session param which by default allows this. And so it's a performance warning when enabled, error when not enabled. |
970f365 to
2e5b7f1
Compare
There was a problem hiding this comment.
Do you want to call it ordinals or literals? Just pick one! :P
There was a problem hiding this comment.
Oh yeah - I think literals is more appropriate as that's what we are doing. Fixed.
9a5c791 to
11d2e53
Compare
rongrong
left a comment
There was a problem hiding this comment.
Some more nits. Also I think the release note is also not accurate, please revise. Thanks!
There was a problem hiding this comment.
We normally use toImmutableList() rather than Collectors.toList()
We normally format this as
orderBy.getSortItems().stream()
.filter(...)
.collect(toImmutableList())
You can use
List<SortItem> constSortItems = window.getOrderBy()
.ifPresent(orderBy -> orderBy.getSortItems()....)
.orElse(ImmutableList.of());
There was a problem hiding this comment.
Well we already set the context in the first clause. Anyway I fixed it and also removed the unnecessary information.
There was a problem hiding this comment.
I think the description is not accurate.
1972f2f to
9ed1981
Compare
…e a misunderstood feature.
9ed1981 to
4f7d7ae
Compare
Disallow ORDER BY literal in Window functions as this is currently treated differently for int literals compared to ORDER BY in SELECT where it's treated it as an ordinal.
Test plan - (Please fill in how you tested your changes)
Test included.