-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1930 from kuzudb/unnest-subquery
Unnest arbitrary subquery
- Loading branch information
Showing
45 changed files
with
670 additions
and
171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
|
||
#include "logical_operator_visitor.h" | ||
#include "planner/logical_plan/logical_plan.h" | ||
|
||
namespace kuzu { | ||
namespace optimizer { | ||
|
||
class CorrelatedSubqueryUnnestSolver : public LogicalOperatorVisitor { | ||
public: | ||
CorrelatedSubqueryUnnestSolver(planner::LogicalOperator* accumulateOp) | ||
: accumulateOp{accumulateOp} {} | ||
void solve(planner::LogicalOperator* root_); | ||
|
||
private: | ||
void visitOperator(planner::LogicalOperator* op); | ||
void visitExpressionsScan(planner::LogicalOperator* op) final; | ||
|
||
inline bool isAccHashJoin(planner::LogicalOperator* op) const { | ||
return op->getOperatorType() == planner::LogicalOperatorType::HASH_JOIN && | ||
op->getChild(0)->getOperatorType() == planner::LogicalOperatorType::ACCUMULATE; | ||
} | ||
void solveAccHashJoin(planner::LogicalOperator* op) const; | ||
|
||
private: | ||
planner::LogicalOperator* accumulateOp; | ||
}; | ||
|
||
} // namespace optimizer | ||
} // namespace kuzu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/include/planner/logical_plan/scan/logical_expressions_scan.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#pragma once | ||
|
||
#include "planner/logical_plan/logical_operator.h" | ||
|
||
namespace kuzu { | ||
namespace planner { | ||
|
||
// LogicalExpressionsScan scans from an outer factorize table | ||
class LogicalExpressionsScan : public LogicalOperator { | ||
public: | ||
LogicalExpressionsScan(binder::expression_vector expressions) | ||
: LogicalOperator{LogicalOperatorType::EXPRESSIONS_SCAN}, expressions{ | ||
std::move(expressions)} {} | ||
|
||
inline void computeFactorizedSchema() final { computeSchema(); } | ||
inline void computeFlatSchema() final { computeSchema(); } | ||
|
||
inline std::string getExpressionsForPrinting() const final { | ||
return binder::ExpressionUtil::toString(expressions); | ||
} | ||
|
||
inline binder::expression_vector getExpressions() const { return expressions; } | ||
inline void setOuterAccumulate(LogicalOperator* op) { outerAccumulate = op; } | ||
inline LogicalOperator* getOuterAccumulate() const { return outerAccumulate; } | ||
|
||
inline std::unique_ptr<LogicalOperator> copy() final { | ||
return std::make_unique<LogicalExpressionsScan>(expressions); | ||
} | ||
|
||
private: | ||
void computeSchema(); | ||
|
||
private: | ||
binder::expression_vector expressions; | ||
LogicalOperator* outerAccumulate; | ||
}; | ||
|
||
} // namespace planner | ||
} // namespace kuzu |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.