Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix group by outputs. #4128

Merged
merged 4 commits into from
Apr 11, 2022
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/graph/validator/GroupByValidator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ Status GroupByValidator::validateImpl() {
NG_RETURN_IF_ERROR(validateYield(groupBySentence->yieldClause()));
NG_RETURN_IF_ERROR(groupClauseSemanticCheck());

for (auto* col : groupBySentence->yieldClause()->columns()) {
auto type = deduceExprType(col->expr());
outputs_.emplace_back(col->name(), std::move(type).value());
}

return Status::OK();
}

Expand Down Expand Up @@ -155,7 +160,6 @@ Status GroupByValidator::groupClauseSemanticCheck() {
for (auto i = 0u; i < groupItems_.size(); ++i) {
auto type = deduceExprType(groupItems_[i]);
NG_RETURN_IF_ERROR(type);
outputs_.emplace_back(aggOutputColNames_[i], std::move(type).value());
}
// check exprProps
if (!exprProps_.srcTagProps().empty() || !exprProps_.dstTagProps().empty()) {
Expand Down
15 changes: 15 additions & 0 deletions tests/tck/features/aggregate/Agg.feature
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,21 @@ Feature: Basic Aggregate and GroupBy
| sum |
| 6 |

Scenario: Reference the output of group by
When executing query:
"""
GO FROM "Tim Duncan" OVER * YIELD dst(edge) as dst, $$.player.age as age
| GROUP BY $-.dst YIELD (sum($-.age)+3) as age
| ORDER BY $-.age
"""
Then the result should be, in order:
| age |
| 3 |
| 34 |
| 36 |
| 75 |
| 85 |

Scenario: Error Check
When executing query:
"""
Expand Down