project_logical_operator.h 1.4 KB
Newer Older
羽飞's avatar
羽飞 已提交
1
/* Copyright (c) 2021 OceanBase and/or its affiliates. All rights reserved.
羽飞's avatar
羽飞 已提交
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
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 表示投影运算
 */
羽飞's avatar
羽飞 已提交
27 28
class ProjectLogicalOperator : public LogicalOperator 
{
羽飞's avatar
羽飞 已提交
29 30 31 32
public:
  ProjectLogicalOperator(const std::vector<Field> &fields);
  virtual ~ProjectLogicalOperator() = default;

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

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

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