project_logical_operator.h 1.4 KB
Newer Older
羽飞's avatar
羽飞 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
/* Copyright (c) 2021 Xie Meiyi(xiemeiyi@hust.edu.cn) and OceanBase and/or its affiliates. All rights reserved.
miniob is licensed under Mulan PSL v2.
You can use this software according to the terms and conditions of the Mulan PSL v2.
You may obtain a copy of Mulan PSL v2 at:
         http://license.coscl.org.cn/MulanPSL2
THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
See the Mulan PSL v2 for more details. */

//
// Created by WangYunlai on 2022/12/08.
//

#pragma once

#include <vector>
#include <memory>

#include "sql/operator/logical_operator.h"
#include "sql/expr/expression.h"
#include "storage/common/field.h"

/**
 * project 表示投影运算
 */
L
Longda Feng 已提交
27
class ProjectLogicalOperator : public LogicalOperator {
羽飞's avatar
羽飞 已提交
28 29 30 31
public:
  ProjectLogicalOperator(const std::vector<Field> &fields);
  virtual ~ProjectLogicalOperator() = default;

L
Longda Feng 已提交
32 33 34 35 36 37 38 39 40
  LogicalOperatorType type() const override
  {
    return LogicalOperatorType::PROJECTION;
  }

  const std::vector<Field> &fields() const
  {
    return fields_;
  }
羽飞's avatar
羽飞 已提交
41 42 43 44 45 46 47 48

private:
  //! 投影映射的字段名称
  //! 并不是所有的select都会查看表字段,也可能是常量数字、字符串,
  //! 或者是执行某个函数。所以这里应该是表达式Expression。
  //! 不过现在简单处理,就使用字段来描述
  std::vector<Field> fields_;
};