use of com.blazebit.persistence.parser.expression.FunctionExpression in project blaze-persistence by Blazebit.
the class SizeTransformationVisitor method onModifier.
@Override
protected void onModifier(ExpressionModifier parentModifier) {
PathExpression sizeArg = (PathExpression) ((FunctionExpression) parentModifier.get()).getExpressions().get(0);
parentModifier.set(getSizeExpression(parentModifier, sizeArg));
sizeArg.accept(this);
}
use of com.blazebit.persistence.parser.expression.FunctionExpression in project blaze-persistence by Blazebit.
the class SimpleQueryGenerator method visit.
@Override
public void visit(FunctionExpression expression) {
if (expression.getRealArgument() != null) {
expression.getRealArgument().accept(this);
return;
}
BooleanLiteralRenderingContext oldBooleanLiteralRenderingContext = setBooleanLiteralRenderingContext(BooleanLiteralRenderingContext.PLAIN);
ParameterRenderingMode oldParameterRenderingMode = setParameterRenderingMode(ParameterRenderingMode.PLACEHOLDER);
List<Expression> expressions = expression.getExpressions();
int size = expressions.size();
boolean hasExpressions = size != 0;
String functionName = expression.getFunctionName();
WindowDefinition windowDefinition = expression.getWindowDefinition();
if (expression instanceof AggregateExpression && windowDefinition != null && windowDefinition.isFilterOnly()) {
sb.append(functionName, "window_".length(), functionName.length());
} else {
sb.append(functionName);
}
// @formatter:off
if (!"CURRENT_TIME".equalsIgnoreCase(functionName) && !"CURRENT_DATE".equalsIgnoreCase(functionName) && !"CURRENT_TIMESTAMP".equalsIgnoreCase(functionName)) {
// @formatter:on
sb.append('(');
if (expression instanceof AggregateExpression) {
AggregateExpression aggregateExpression = (AggregateExpression) expression;
if (aggregateExpression.isDistinct()) {
sb.append("DISTINCT ");
}
if (!hasExpressions && "COUNT".equalsIgnoreCase(aggregateExpression.getFunctionName())) {
sb.append('*');
}
}
if (hasExpressions) {
expressions.get(0).accept(this);
for (int i = 1; i < size; i++) {
sb.append(",");
expressions.get(i).accept(this);
}
}
sb.append(')');
List<OrderByItem> withinGroup = expression.getWithinGroup();
if (withinGroup != null && !withinGroup.isEmpty()) {
sb.append(" WITHIN GROUP (");
for (int i = 0; i < withinGroup.size(); i++) {
visit(withinGroup.get(i));
sb.append(", ");
}
sb.setLength(sb.length() - 1);
sb.setCharAt(sb.length() - 1, ')');
}
visitWindowDefinition(windowDefinition);
}
setBooleanLiteralRenderingContext(oldBooleanLiteralRenderingContext);
setParameterRenderingMode(oldParameterRenderingMode);
}
use of com.blazebit.persistence.parser.expression.FunctionExpression in project blaze-persistence by Blazebit.
the class AbstractCommonQueryBuilder method groupByCube.
public BuilderType groupByCube(String... expressions) {
prepareForModification(ClauseType.GROUP_BY);
verifyBuilderEnded();
groupByManager.groupBy(new FunctionExpression(CubeFunction.FUNCTION_NAME, groupByExpressions(expressions)));
return (BuilderType) this;
}
use of com.blazebit.persistence.parser.expression.FunctionExpression in project blaze-persistence by Blazebit.
the class AbstractCommonQueryBuilder method groupByRollup.
public BuilderType groupByRollup(String[]... expressions) {
prepareForModification(ClauseType.GROUP_BY);
verifyBuilderEnded();
groupByManager.groupBy(new FunctionExpression(RollupFunction.FUNCTION_NAME, groupByGroupingSet(expressions)));
return (BuilderType) this;
}
use of com.blazebit.persistence.parser.expression.FunctionExpression in project blaze-persistence by Blazebit.
the class AbstractCommonQueryBuilder method groupByCube.
public BuilderType groupByCube(String[]... expressions) {
prepareForModification(ClauseType.GROUP_BY);
verifyBuilderEnded();
groupByManager.groupBy(new FunctionExpression(CubeFunction.FUNCTION_NAME, groupByGroupingSet(expressions)));
return (BuilderType) this;
}
Aggregations