Fix a type and missing branches in base walkers for ordered set aggregates

This commit is contained in:
Christian Beikov 2022-02-01 21:06:56 +01:00
parent 236ece769b
commit d5d1cf937c
7 changed files with 17 additions and 5 deletions

View File

@ -53,6 +53,7 @@ import org.hibernate.query.sqm.tree.expression.SqmLiteral;
import org.hibernate.query.sqm.tree.expression.SqmLiteralEntityType; import org.hibernate.query.sqm.tree.expression.SqmLiteralEntityType;
import org.hibernate.query.sqm.tree.expression.SqmModifiedSubQueryExpression; import org.hibernate.query.sqm.tree.expression.SqmModifiedSubQueryExpression;
import org.hibernate.query.sqm.tree.expression.SqmNamedParameter; import org.hibernate.query.sqm.tree.expression.SqmNamedParameter;
import org.hibernate.query.sqm.tree.expression.SqmOrderedSetAggregateFunction;
import org.hibernate.query.sqm.tree.expression.SqmOverflow; import org.hibernate.query.sqm.tree.expression.SqmOverflow;
import org.hibernate.query.sqm.tree.expression.SqmParameterizedEntityType; import org.hibernate.query.sqm.tree.expression.SqmParameterizedEntityType;
import org.hibernate.query.sqm.tree.expression.SqmPositionalParameter; import org.hibernate.query.sqm.tree.expression.SqmPositionalParameter;
@ -582,6 +583,9 @@ public abstract class BaseSemanticQueryWalker implements SemanticQueryWalker<Obj
if ( filter != null ) { if ( filter != null ) {
filter.accept( this ); filter.accept( this );
} }
if ( sqmFunction instanceof SqmOrderedSetAggregateFunction<?> ) {
visitOrderByClause( ( (SqmOrderedSetAggregateFunction<?>) sqmFunction ).getWithinGroup() );
}
} }
return sqmFunction; return sqmFunction;
} }

View File

@ -161,7 +161,7 @@ public interface SqlAstWalker {
void visitQueryLiteral(QueryLiteral<?> queryLiteral); void visitQueryLiteral(QueryLiteral<?> queryLiteral);
void acceptConvertedQueryLiteral(ConvertedQueryLiteral<?,?> convertedQueryLiteral); void visitConvertedQueryLiteral(ConvertedQueryLiteral<?,?> convertedQueryLiteral);
void visitUnaryOperationExpression(UnaryOperation unaryOperationExpression); void visitUnaryOperationExpression(UnaryOperation unaryOperationExpression);

View File

@ -4589,7 +4589,7 @@ public abstract class AbstractSqlAstTranslator<T extends JdbcOperation> implemen
} }
@Override @Override
public void acceptConvertedQueryLiteral(ConvertedQueryLiteral<?, ?> convertedQueryLiteral) { public void visitConvertedQueryLiteral(ConvertedQueryLiteral<?, ?> convertedQueryLiteral) {
visitLiteral( convertedQueryLiteral ); visitLiteral( convertedQueryLiteral );
} }

View File

@ -34,6 +34,7 @@ import org.hibernate.sql.ast.tree.expression.FunctionExpression;
import org.hibernate.sql.ast.tree.expression.JdbcLiteral; import org.hibernate.sql.ast.tree.expression.JdbcLiteral;
import org.hibernate.sql.ast.tree.expression.JdbcParameter; import org.hibernate.sql.ast.tree.expression.JdbcParameter;
import org.hibernate.sql.ast.tree.expression.ModifiedSubQueryExpression; import org.hibernate.sql.ast.tree.expression.ModifiedSubQueryExpression;
import org.hibernate.sql.ast.tree.expression.OrderedSetAggregateFunctionExpression;
import org.hibernate.sql.ast.tree.expression.Over; import org.hibernate.sql.ast.tree.expression.Over;
import org.hibernate.sql.ast.tree.expression.Overflow; import org.hibernate.sql.ast.tree.expression.Overflow;
import org.hibernate.sql.ast.tree.expression.QueryLiteral; import org.hibernate.sql.ast.tree.expression.QueryLiteral;
@ -106,6 +107,11 @@ public class AbstractSqlAstWalker implements SqlAstWalker {
if ( aggregateFunctionExpression.getFilter() != null ) { if ( aggregateFunctionExpression.getFilter() != null ) {
aggregateFunctionExpression.getFilter().accept( this ); aggregateFunctionExpression.getFilter().accept( this );
} }
if ( expression instanceof OrderedSetAggregateFunctionExpression ) {
for ( SortSpecification specification : ( (OrderedSetAggregateFunctionExpression) expression ).getWithinGroup() ) {
specification.accept( this );
}
}
} }
} }
} }
@ -480,7 +486,7 @@ public class AbstractSqlAstWalker implements SqlAstWalker {
} }
@Override @Override
public void acceptConvertedQueryLiteral(ConvertedQueryLiteral<?,?> convertedQueryLiteral) { public void visitConvertedQueryLiteral(ConvertedQueryLiteral<?,?> convertedQueryLiteral) {
} }
@Override @Override

View File

@ -219,7 +219,7 @@ public class ExpressionReplacementWalker implements SqlAstWalker {
} }
@Override @Override
public void acceptConvertedQueryLiteral(ConvertedQueryLiteral<?, ?> convertedQueryLiteral) { public void visitConvertedQueryLiteral(ConvertedQueryLiteral<?, ?> convertedQueryLiteral) {
doReplaceExpression( convertedQueryLiteral ); doReplaceExpression( convertedQueryLiteral );
} }

View File

@ -97,7 +97,7 @@ public class ConvertedQueryLiteral<D,R> implements Literal, DomainResultProducer
@Override @Override
public void accept(SqlAstWalker sqlTreeWalker) { public void accept(SqlAstWalker sqlTreeWalker) {
sqlTreeWalker.acceptConvertedQueryLiteral( this ); sqlTreeWalker.visitConvertedQueryLiteral( this );
} }
@Override @Override

View File

@ -6,6 +6,7 @@
*/ */
package org.hibernate.sql.ast.tree.expression; package org.hibernate.sql.ast.tree.expression;
import org.hibernate.Incubating;
import org.hibernate.query.sqm.sql.SqmToSqlAstConverter; import org.hibernate.query.sqm.sql.SqmToSqlAstConverter;
import org.hibernate.sql.ast.tree.cte.CteContainer; import org.hibernate.sql.ast.tree.cte.CteContainer;
import org.hibernate.sql.ast.tree.select.QuerySpec; import org.hibernate.sql.ast.tree.select.QuerySpec;
@ -13,6 +14,7 @@ import org.hibernate.sql.ast.tree.select.QuerySpec;
/** /**
* @author Christian Beikov * @author Christian Beikov
*/ */
@Incubating
public interface QueryTransformer { public interface QueryTransformer {
QuerySpec transform( QuerySpec transform(