julianhyde commented on a change in pull request #1896: 3877, 3892, 3814 and
3876
URL: https://github.com/apache/calcite/pull/1896#discussion_r403402724
##########
File path: core/src/main/java/org/apache/calcite/rel/core/Window.java
##########
@@ -246,26 +244,38 @@ public String toString() {
}
private String computeString() {
- final StringBuilder buf = new StringBuilder();
- buf.append("window(partition ");
- buf.append(keys);
- buf.append(" order by ");
- buf.append(orderKeys);
- buf.append(isRows ? " rows " : " range ");
- if (lowerBound != null) {
- if (upperBound != null) {
- buf.append("between ");
- buf.append(lowerBound);
- buf.append(" and ");
- buf.append(upperBound);
- } else {
- buf.append(lowerBound);
- }
- } else if (upperBound != null) {
+ final StringBuilder buf = new StringBuilder("window(");
+ final int i = buf.length();
+ if (!keys.isEmpty()) {
+ buf.append("partition ");
+ buf.append(keys);
+ }
+ if (!orderKeys.getFieldCollations().isEmpty()) {
+ buf.append(buf.length() == i ? "order by " : " order by ");
+ buf.append(orderKeys);
+ }
+ if (orderKeys.getFieldCollations().isEmpty()
+ && lowerBound.isUnbounded()
+ && lowerBound.isPreceding()
+ && upperBound.isUnbounded()
+ && upperBound.isFollowing()) {
+ // skip bracket if no ORDER BY, and if bracket is the default
+ } else if (!orderKeys.getFieldCollations().isEmpty()
+ && lowerBound.isUnbounded()
+ && lowerBound.isPreceding()
+ && upperBound.isCurrentRow()) {
+ // skip bracket if there is ORDER BY, and if bracket is the default
Review comment:
Good point. I've fixed in 75ee3ec79.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services