#pragma once
#include "logical_operator.h"
namespace lbug {
namespace planner {
class LogicalUnion : public LogicalOperator {
public:
LogicalUnion(binder::expression_vector expressions,
const std::vector<std::shared_ptr<LogicalOperator>>& children)
: LogicalOperator{LogicalOperatorType::UNION_ALL, children},
expressionsToUnion{std::move(expressions)} {}
void setChildProjections(std::vector<binder::expression_vector> projections) {
childProjections = std::move(projections);
}
f_group_pos_set getGroupsPosToFlatten(uint32_t childIdx);
void computeFactorizedSchema() override;
void computeFlatSchema() override;
std::string getExpressionsForPrinting() const override { return std::string{}; }
binder::expression_vector getExpressionsToUnion() const { return expressionsToUnion; }
const std::vector<binder::expression_vector>& getChildProjections() const {
return childProjections;
}
Schema* getSchemaBeforeUnion(uint32_t idx) const { return children[idx]->getSchema(); }
std::unique_ptr<LogicalOperator> copy() override;
private:
bool requireFlatExpression(uint32_t expressionIdx);
private:
binder::expression_vector expressionsToUnion;
std::vector<binder::expression_vector> childProjections;
};
} }