提交 4195c470 authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Extract updateCollecting() from Aggregate.updateAggregate()

上级 ba63ffc6
......@@ -315,31 +315,11 @@ public class Aggregate extends Expression {
Value v = on == null ? null : on.getValue(session);
if (type == AggregateType.GROUP_CONCAT) {
if (v != ValueNull.INSTANCE) {
v = v.convertTo(Value.STRING);
if (orderByList != null) {
int size = orderByList.size();
Value[] array = new Value[1 + size];
array[0] = v;
for (int i = 0; i < size; i++) {
SelectOrderBy o = orderByList.get(i);
array[i + 1] = o.expression.getValue(session);
}
v = ValueArray.get(array);
}
v = updateCollecting(session, v.convertTo(Value.STRING));
}
}
if (type == AggregateType.ARRAY_AGG) {
} else if (type == AggregateType.ARRAY_AGG) {
if (v != ValueNull.INSTANCE) {
if (orderByList != null) {
int size = orderByList.size();
Value[] array = new Value[1 + size];
array[0] = v;
for (int i = 0; i < size; i++) {
SelectOrderBy o = orderByList.get(i);
array[i + 1] = o.expression.getValue(session);
}
v = ValueArray.get(array);
}
v = updateCollecting(session, v);
}
}
if (filterCondition != null) {
......@@ -350,6 +330,20 @@ public class Aggregate extends Expression {
data.add(session.getDatabase(), dataType, distinct, v);
}
private Value updateCollecting(Session session, Value v) {
if (orderByList != null) {
int size = orderByList.size();
Value[] array = new Value[1 + size];
array[0] = v;
for (int i = 0; i < size; i++) {
SelectOrderBy o = orderByList.get(i);
array[i + 1] = o.expression.getValue(session);
}
v = ValueArray.get(array);
}
return v;
}
@Override
public Value getValue(Session session) {
if (select.isQuickAggregateQuery()) {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论