mutable
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
QueryGraph2SQL.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <functional>
4#include <mutable/IR/CNF.hpp>
6
7
8namespace m {
9
10struct QueryGraph;
11
13struct QueryGraph2SQL : private ast::ConstASTExprVisitor
14{
15 private:
16 std::ostream &out_;
18 bool after_grouping_ = false;
19
20 public:
21 QueryGraph2SQL(std::ostream &out) : out_(out) { }
22 private:
23 QueryGraph2SQL(std::ostream &out, const QueryGraph *graph) : out_(out), graph_(graph) { }
24 QueryGraph2SQL(std::ostream &out, const QueryGraph *graph, bool after_grouping)
25 : out_(out), graph_(graph), after_grouping_(after_grouping) { }
26
27 public:
29 void translate(const QueryGraph&);
30 void operator()(const QueryGraph &graph) { translate(graph); }
31
32 private:
35 void insert_projection(const ast::Expr*);
38 void translate_projection(std::pair<std::reference_wrapper<const ast::Expr>, ThreadSafePooledOptionalString>);
39
42
44
45 using ConstASTExprVisitor::operator();
46#define DECLARE(CLASS) void operator()(Const<CLASS>&) override;
48#undef DECLARE
49
50 void operator()(const cnf::Predicate&);
51 void operator()(const cnf::Clause&);
52 void operator()(const cnf::CNF&);
53};
54
55}
#define M_AST_EXPR_LIST(X)
Definition: AST.hpp:427
#define DECLARE(CLASS)
‍mutable namespace
Definition: Backend.hpp:10
ThreadSafeStringPool::proxy_optional_type ThreadSafePooledOptionalString
Definition: Pool.hpp:465
A data type representing a pooled (or internalized) object.
Definition: Pool.hpp:168
Translates a query graph in SQL.
QueryGraph2SQL(std::ostream &out, const QueryGraph *graph, bool after_grouping)
bool references_group_by(ast::Designator::target_type)
Checks whether the given target references an expression contained in the group_by clause.
void insert_projection(const ast::Expr *)
Inserts a projection for the given Expr which is computed by a grouping operator.
void translate_projection(std::pair< std::reference_wrapper< const ast::Expr >, ThreadSafePooledOptionalString >)
Translates a projection for the given pair of Expr and alias.
void translate(const QueryGraph &)
Translates the given QueryGraph into SQL.
void operator()(const QueryGraph &graph)
static ThreadSafePooledString make_unique_alias()
QueryGraph2SQL(std::ostream &out, const QueryGraph *graph)
QueryGraph2SQL(std::ostream &out)
bool after_grouping_
the graph to translate
std::ostream & out_
the output stream to write to
const QueryGraph * graph_
The query graph represents all data sources and joins in a graph structure.
Definition: QueryGraph.hpp:172
std::variant< std::monostate, const Expr *, const Attribute * > target_type
Definition: AST.hpp:137
An expression.
Definition: AST.hpp:39