use of io.crate.expression.symbol.format.Style in project crate by crate.
the class WindowFunction method toString.
@Override
public String toString(Style style) {
var builder = new StringBuilder(super.toString(style));
if (ignoreNulls != null) {
if (ignoreNulls) {
builder.append(" IGNORE NULLS");
} else {
builder.append(" RESPECT NULLS");
}
}
builder.append(" OVER (");
var partitions = windowDefinition.partitions();
if (!partitions.isEmpty()) {
builder.append("PARTITION BY ");
builder.append(Lists2.joinOn(", ", partitions, x -> x.toString(style)));
}
var orderBy = windowDefinition.orderBy();
if (orderBy != null) {
if (!partitions.isEmpty()) {
builder.append(" ");
}
builder.append("ORDER BY ");
OrderBy.explainRepresentation(builder, orderBy.orderBySymbols(), orderBy.reverseFlags(), orderBy.nullsFirst(), x -> x.toString(style));
}
WindowFrameDefinition frameDefinition = windowDefinition.windowFrameDefinition();
if (frameDefinition != WindowDefinition.RANGE_UNBOUNDED_PRECEDING_CURRENT_ROW) {
builder.append(" ");
builder.append(frameDefinition.mode().name());
builder.append(" BETWEEN ");
appendFrameBound(builder, style, frameDefinition.start());
builder.append(" AND ");
appendFrameBound(builder, style, frameDefinition.end());
}
builder.append(")");
return builder.toString();
}
Aggregations