Render windowing functions without arguments correctly.
Closes #1153 See #1019
This commit is contained in:
@@ -30,7 +30,6 @@ class SimpleFunctionVisitor extends TypedSingleConditionRenderSupport<SimpleFunc
|
||||
|
||||
private final StringBuilder part = new StringBuilder();
|
||||
private boolean needsComma = false;
|
||||
private String functionName;
|
||||
|
||||
SimpleFunctionVisitor(RenderContext context) {
|
||||
super(context);
|
||||
@@ -49,9 +48,6 @@ class SimpleFunctionVisitor extends TypedSingleConditionRenderSupport<SimpleFunc
|
||||
part.append(", ");
|
||||
}
|
||||
|
||||
if (part.length() == 0) {
|
||||
part.append(functionName).append("(");
|
||||
}
|
||||
part.append(consumeRenderedPart());
|
||||
needsComma = true;
|
||||
}
|
||||
@@ -66,7 +62,8 @@ class SimpleFunctionVisitor extends TypedSingleConditionRenderSupport<SimpleFunc
|
||||
@Override
|
||||
Delegation enterMatched(SimpleFunction segment) {
|
||||
|
||||
functionName = segment.getFunctionName();
|
||||
part.append(segment.getFunctionName()).append("(");
|
||||
|
||||
return super.enterMatched(segment);
|
||||
}
|
||||
|
||||
|
||||
@@ -663,5 +663,20 @@ class SelectRendererUnitTests {
|
||||
assertThat(rendered).isEqualTo(
|
||||
"SELECT MAX(employee.salary) OVER(PARTITION BY employee.department ORDER BY employee.age) AS MAX_SELECT FROM employee");
|
||||
}
|
||||
|
||||
@Test // GH-1153
|
||||
void renderAnalyticFunctionWithOutArgument() {
|
||||
|
||||
final Select select = StatementBuilder.select( //
|
||||
AnalyticFunction.create("ROW_NUMBER") //
|
||||
.partitionBy(department)) //
|
||||
.from(employee) //
|
||||
.build();
|
||||
|
||||
String rendered = SqlRenderer.toString(select);
|
||||
|
||||
assertThat(rendered).isEqualTo(
|
||||
"SELECT ROW_NUMBER() OVER(PARTITION BY employee.department) FROM employee");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user