OmniSciDB  a5dc49c757
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SerializeToSql.h
Go to the documentation of this file.
1 /*
2  * Copyright 2022 HEAVY.AI, Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include "Catalog/Catalog.h"
20 #include "RelAlgExecutionUnit.h"
21 #include "ScalarExprVisitor.h"
22 
23 class ScalarExprToSql : public ScalarExprVisitor<std::string> {
24  public:
25  ScalarExprToSql(const RelAlgExecutionUnit* ra_exe_unit);
26 
27  std::string visitVar(const Analyzer::Var*) const override;
28 
29  std::string visitColumnVar(const Analyzer::ColumnVar* col_var) const override;
30 
31  std::string visitConstant(const Analyzer::Constant* constant) const override;
32 
33  std::string visitUOper(const Analyzer::UOper* uoper) const override;
34 
35  std::string visitBinOper(const Analyzer::BinOper* bin_oper) const override;
36 
37  std::string visitInValues(const Analyzer::InValues* in_values) const override;
38 
39  std::string visitLikeExpr(const Analyzer::LikeExpr* like) const override;
40 
41  std::string visitCaseExpr(const Analyzer::CaseExpr* case_) const override;
42 
43  std::string visitFunctionOper(const Analyzer::FunctionOper* func_oper) const override;
44 
45  std::string visitWindowFunction(
46  const Analyzer::WindowFunction* window_func) const override;
47 
48  std::string visitAggExpr(const Analyzer::AggExpr* agg) const override;
49 
50  template <typename List>
51  std::vector<std::string> visitList(const List& expressions) const;
52 
53  protected:
54  std::string aggregateResult(const std::string& aggregate,
55  const std::string& next_result) const override {
56  throw std::runtime_error("Expression not supported yet");
57  }
58 
59  std::string defaultResult() const override {
60  throw std::runtime_error("Expression not supported yet");
61  }
62 
63  private:
64  static std::string binOpTypeToString(const SQLOps op_type);
65 
67 };
68 
69 std::string serialize_table_ref(const int table_id,
70  const Catalog_Namespace::Catalog* catalog);
71 
72 std::string serialize_column_ref(const int table_id,
73  const int column_id,
74  const Catalog_Namespace::Catalog* catalog);
75 
77  std::string query;
78  std::string from_table;
79 };
80 
std::string visitColumnVar(const Analyzer::ColumnVar *col_var) const override
class for a per-database catalog. also includes metadata for the current database and the current use...
Definition: Catalog.h:143
SQLOps
Definition: sqldefs.h:31
std::string visitWindowFunction(const Analyzer::WindowFunction *window_func) const override
ScalarExprToSql(const RelAlgExecutionUnit *ra_exe_unit)
std::string visitBinOper(const Analyzer::BinOper *bin_oper) const override
std::vector< std::string > visitList(const List &expressions) const
std::string visitConstant(const Analyzer::Constant *constant) const override
std::string serialize_column_ref(const int table_id, const int column_id, const Catalog_Namespace::Catalog *catalog)
std::string visitAggExpr(const Analyzer::AggExpr *agg) const override
This file contains the class specification and related data structures for Catalog.
std::string defaultResult() const override
std::string visitCaseExpr(const Analyzer::CaseExpr *case_) const override
std::string aggregateResult(const std::string &aggregate, const std::string &next_result) const override
std::string visitVar(const Analyzer::Var *) const override
std::string visitLikeExpr(const Analyzer::LikeExpr *like) const override
static std::string binOpTypeToString(const SQLOps op_type)
ExecutionUnitSql serialize_to_sql(const RelAlgExecutionUnit *ra_exe_unit)
const RelAlgExecutionUnit * ra_exe_unit_
std::string from_table
std::string visitFunctionOper(const Analyzer::FunctionOper *func_oper) const override
std::string visitUOper(const Analyzer::UOper *uoper) const override
std::string query
Execution unit for relational algebra. It&#39;s a low-level description of any relational algebra operati...
std::string visitInValues(const Analyzer::InValues *in_values) const override
std::string serialize_table_ref(const int table_id, const Catalog_Namespace::Catalog *catalog)