HHH-16402 Fix default window frame mode to be RANGE instead of ROWS

This commit is contained in:
Christian Beikov 2023-03-30 13:35:31 +02:00
parent f3076c51b9
commit d75c817fd9
4 changed files with 7 additions and 6 deletions

View File

@ -4732,7 +4732,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
}
}
else {
mode = FrameMode.ROWS;
mode = FrameMode.RANGE;
startKind = FrameKind.UNBOUNDED_PRECEDING;
startExpression = null;
endKind = FrameKind.CURRENT_ROW;

View File

@ -28,6 +28,7 @@ import jakarta.persistence.criteria.Order;
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;
/**
@ -49,7 +50,7 @@ public class SqmWindow extends AbstractSqmNode implements JpaWindow, SqmVisitabl
nodeBuilder,
new ArrayList<>(),
new ArrayList<>(),
ROWS,
RANGE,
UNBOUNDED_PRECEDING,
null,
CURRENT_ROW,
@ -221,7 +222,7 @@ public class SqmWindow extends AbstractSqmNode implements JpaWindow, SqmVisitabl
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 {

View File

@ -4766,7 +4766,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
visitOverClause(
partitionExpressions,
sortSpecifications,
FrameMode.ROWS,
FrameMode.RANGE,
FrameKind.UNBOUNDED_PRECEDING,
null,
FrameKind.CURRENT_ROW,
@ -4793,7 +4793,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
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 {

View File

@ -43,7 +43,7 @@ public class Over<T> implements Expression, DomainResultProducer<T> {
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;