Skip to content
Merged
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
13 changes: 13 additions & 0 deletions src/optimizer/projection_push_down_optimizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <algorithm>

#include "binder/expression/lambda_expression.h"
#include "binder/expression_visitor.h"
#include "function/gds/gds_function_collection.h"
#include "function/gds/rec_joins.h"
Expand Down Expand Up @@ -334,6 +335,18 @@ void ProjectionPushDownOptimizer::collectExpressionsInUse(
}
return;
}
case ExpressionType::LAMBDA: {
// A LambdaExpression stores its body (functionExpr) separately from its
// expression children, so collectChildren() does not traverse into it.
// We need to mark expressions referenced inside the lambda body as in use,
// e.g. a path variable `p` referenced inside `any(x IN [...] WHERE p IS NOT NULL)`
// depends on the path's recursive-rel segments being materialized.
auto& lambdaExpression = expression->constCast<LambdaExpression>();
if (lambdaExpression.getFunctionExpr() != nullptr) {
collectExpressionsInUse(lambdaExpression.getFunctionExpr());
}
return;
}
default:
for (auto& child : ExpressionChildrenCollector::collectChildren(*expression)) {
collectExpressionsInUse(child);
Expand Down
Loading