提交 c574f36b authored 作者: Evgenij Ryazanov's avatar Evgenij Ryazanov

Add execution-time check for invalid grouped window queries

上级 eb22d7ff
......@@ -113,6 +113,8 @@ public class Select extends Query {
private boolean isPrepared, checkInit;
private boolean sortUsingIndex;
private boolean isGroupWindowStage2;
public Select(Session session) {
super(session);
}
......@@ -383,7 +385,12 @@ public class Select extends Query {
updateAgg(columnCount, true);
}
groupData.done();
try {
isGroupWindowStage2 = true;
processGroupResult(columnCount, result, offset, quickOffset);
} finally {
isGroupWindowStage2 = false;
}
} finally {
groupData.reset();
}
......@@ -1462,6 +1469,16 @@ public class Select extends Query {
return isWindowQuery;
}
/**
* Checks if window stage of group window query is performed. If true,
* column resolver may not be used.
*
* @return true if window stage of group window query is performed
*/
public boolean isGroupWindowStage2() {
return isGroupWindowStage2;
}
@Override
public void addGlobalCondition(Parameter param, int columnId,
int comparisonType) {
......
......@@ -184,6 +184,9 @@ public class ExpressionColumn extends Expression {
if (v != null) {
return v;
}
if (select.isGroupWindowStage2()) {
throw DbException.get(ErrorCode.MUST_GROUP_BY_COLUMN_1, getSQL());
}
}
}
Value value = columnResolver.getValue(column);
......
......@@ -158,5 +158,8 @@ SELECT ARRAY_AGG(ARRAY_AGG(ID ORDER BY ID)) OVER (PARTITION BY NAME), NAME FROM
> ((4, 5, 6)) c
> rows: 2
SELECT ARRAY_AGG(ID) OVER() FROM TEST GROUP BY NAME;
> exception MUST_GROUP_BY_COLUMN_1
DROP TABLE TEST;
> ok
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论