Skip to content

Commit

Permalink
HHH-16402 Fix default window frame mode to be RANGE instead of ROWS
Browse files Browse the repository at this point in the history
  • Loading branch information
beikov committed Mar 30, 2023
1 parent f3076c5 commit d75c817
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
Expand Up @@ -4732,7 +4732,7 @@ private SqmExpression<?> applyOverClause(HqlParser.OverClauseContext ctx, SqmFun
}
}
else {
mode = FrameMode.ROWS;
mode = FrameMode.RANGE;
startKind = FrameKind.UNBOUNDED_PRECEDING;
startExpression = null;
endKind = FrameKind.CURRENT_ROW;
Expand Down
Expand Up @@ -28,6 +28,7 @@
import static org.hibernate.query.sqm.FrameExclusion.NO_OTHERS;
import static org.hibernate.query.sqm.FrameKind.CURRENT_ROW;
import static org.hibernate.query.sqm.FrameKind.UNBOUNDED_PRECEDING;
import static org.hibernate.query.sqm.FrameMode.RANGE;
import static org.hibernate.query.sqm.FrameMode.ROWS;

/**
Expand All @@ -49,7 +50,7 @@ public SqmWindow(NodeBuilder nodeBuilder) {
nodeBuilder,
new ArrayList<>(),
new ArrayList<>(),
ROWS,
RANGE,
UNBOUNDED_PRECEDING,
null,
CURRENT_ROW,
Expand Down Expand Up @@ -221,7 +222,7 @@ public void appendHqlString(StringBuilder sb) {
orderList.get( i ).appendHqlString( sb );
}
}
if ( mode == ROWS && startKind == UNBOUNDED_PRECEDING && endKind == CURRENT_ROW && exclusion == NO_OTHERS ) {
if ( mode == RANGE && startKind == UNBOUNDED_PRECEDING && endKind == CURRENT_ROW && exclusion == NO_OTHERS ) {
// This is the default, so we don't need to render anything
}
else {
Expand Down
Expand Up @@ -4766,7 +4766,7 @@ protected final void visitOverClause(
visitOverClause(
partitionExpressions,
sortSpecifications,
FrameMode.ROWS,
FrameMode.RANGE,
FrameKind.UNBOUNDED_PRECEDING,
null,
FrameKind.CURRENT_ROW,
Expand All @@ -4793,7 +4793,7 @@ protected void visitOverClause(
if ( !orderedSetAggregate ) {
renderOrderBy( !partitionExpressions.isEmpty(), sortSpecifications );
}
if ( mode == FrameMode.ROWS && startKind == FrameKind.UNBOUNDED_PRECEDING && endKind == FrameKind.CURRENT_ROW && exclusion == FrameExclusion.NO_OTHERS ) {
if ( mode == FrameMode.RANGE && startKind == FrameKind.UNBOUNDED_PRECEDING && endKind == FrameKind.CURRENT_ROW && exclusion == FrameExclusion.NO_OTHERS ) {
// This is the default, so we don't need to render anything
}
else {
Expand Down
Expand Up @@ -43,7 +43,7 @@ public Over(
this.expression = expression;
this.partitions = partitions;
this.orderList = orderList;
this.mode = FrameMode.ROWS;
this.mode = FrameMode.RANGE;
this.startKind = FrameKind.UNBOUNDED_PRECEDING;
this.startExpression = null;
this.endKind = FrameKind.CURRENT_ROW;
Expand Down

0 comments on commit d75c817

Please sign in to comment.