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 issue1527(pruning properties) #5106

Merged
merged 6 commits into from
Dec 27, 2022
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion src/graph/visitor/PropertyTrackerVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,8 @@ void PropertyTrackerVisitor::visit(AggregateExpression *expr) {
std::transform(funName.begin(), funName.end(), funName.begin(), ::tolower);
if (funName == "count") {
auto kind = expr->arg()->kind();
if (kind == Expression::Kind::kConstant) {
if (kind == Expression::Kind::kVarProperty || kind == Expression::Kind::kConstant ||
kind == Expression::Kind::kInputProperty) {
jievince marked this conversation as resolved.
Show resolved Hide resolved
return;
}
}
Expand Down
11 changes: 5 additions & 6 deletions src/graph/visitor/PrunePropertiesVisitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,6 @@ void PrunePropertiesVisitor::visitCurrent(Aggregate *node) {
}
}
for (auto *groupItem : node->groupItems()) {
if (groupItem->kind() == Expression::Kind::kVarProperty ||
groupItem->kind() == Expression::Kind::kInputProperty ||
groupItem->kind() == Expression::Kind::kConstant) {
continue;
}
status_ = extractPropsFromExpr(groupItem);
if (!status_.ok()) {
return;
Expand Down Expand Up @@ -446,7 +441,11 @@ void PrunePropertiesVisitor::visit(Unwind *node) {

void PrunePropertiesVisitor::visitCurrent(Unwind *node) {
const auto &alias = node->alias();
if (propsUsed_.hasAlias(alias)) {
auto expr = node->unwindExpr();
auto kind = expr->kind();
// unwind e.start_year as a
if (propsUsed_.hasAlias(alias) ||
(kind != Expression::Kind::kVarProperty && kind != Expression::Kind::kInputProperty)) {
status_ = extractPropsFromExpr(node->unwindExpr());
if (!status_.ok()) {
return;
Expand Down
15 changes: 11 additions & 4 deletions tests/common/plan_differ.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,15 +189,22 @@ def _is_subdict_nested(self, expect, resp):

def _try_convert_json(j):
try:
return json.loads(j)
res = json.loads(j)
if isinstance(res, list):
for m in res:
if isinstance(m, dict):
if 'tagId' in m:
m.pop('tagId')
if 'type' in m:
m.pop('type')
return res
except:
return j

extracted_resp_dict = {}
if len(key_list) == 1:

for k in resp:
extracted_resp_dict[k] = _try_convert_json(resp[k])
for k in resp:
extracted_resp_dict[k] = _try_convert_json(resp[k])
else:
extracted_resp_dict = self._convert_jsonStr_to_dict(resp, key_list)

Expand Down
2 changes: 0 additions & 2 deletions tests/tck/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -473,7 +473,6 @@ def executing_query(
exec_query(request, ngql, exec_ctx, sess)
sess.release()


@when(parse("profiling query:\n{query}"))
def profiling_query(query, exec_ctx, request):
ngql = "PROFILE {" + combine_query(query) + "}"
Expand Down Expand Up @@ -826,7 +825,6 @@ def drop_used_space(exec_ctx):
session = exec_ctx.get('current_session')
response(session, stmt)


@then(parse("the execution plan should be:\n{plan}"))
def check_plan(request, plan, exec_ctx):
ngql = exec_ctx["ngql"]
Expand Down
Loading