-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathParseJoinedTableReference.hpp
130 lines (110 loc) · 3.71 KB
/
ParseJoinedTableReference.hpp
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
/**
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
**/
#ifndef QUICKSTEP_PARSER_PARSE_JOINED_TABLE_REFERENCE_HPP_
#define QUICKSTEP_PARSER_PARSE_JOINED_TABLE_REFERENCE_HPP_
#include <memory>
#include <string>
#include <vector>
#include "parser/ParsePredicate.hpp"
#include "parser/ParseTableReference.hpp"
#include "utility/Macros.hpp"
namespace quickstep {
class ParseTreeNode;
/** \addtogroup Parser
* @{
*/
/**
* @brief Parsed representation of a joined table.
*/
class ParseJoinedTableReference : public ParseTableReference {
public:
enum class JoinType {
kInnerJoin = 0,
kLeftOuterJoin,
kRightOuterJoin,
kFullOuterJoin
};
/**
* @brief Constructor.
*
* @param line_number The line number of the token "JOIN" in the SQL statement.
* @param column_number The column number of the token "JOIN" in the SQL statement.
* @param join_type The join type.
* @param left_table The left-hand side table.
* @param right_table The right-hand side table.
* @param join_predicate The join predicate.
*/
ParseJoinedTableReference(const int line_number,
const int column_number,
const JoinType join_type,
ParseTableReference *left_table,
ParseTableReference *right_table,
ParsePredicate *join_predicate)
: ParseTableReference(line_number, column_number),
join_type_(join_type),
left_table_(left_table),
right_table_(right_table),
join_predicate_(join_predicate) {
}
TableReferenceType getTableReferenceType() const override {
return kJoinedTableReference;
}
std::string getName() const override { return "JoinedTable"; }
/**
* @return The join type.
*/
JoinType join_type() const {
return join_type_;
}
/**
* @return The left-side table.
*/
const ParseTableReference* left_table() const {
return left_table_.get();
}
/**
* @return The right-side table.
*/
const ParseTableReference* right_table() const {
return right_table_.get();
}
/**
* @return The join predicate.
*/
const ParsePredicate* join_predicate() const {
return join_predicate_.get();
}
protected:
void getFieldStringItems(
std::vector<std::string> *inline_field_names,
std::vector<std::string> *inline_field_values,
std::vector<std::string> *non_container_child_field_names,
std::vector<const ParseTreeNode*> *non_container_child_fields,
std::vector<std::string> *container_child_field_names,
std::vector<std::vector<const ParseTreeNode*>> *container_child_fields) const override;
private:
const JoinType join_type_;
std::unique_ptr<ParseTableReference> left_table_;
std::unique_ptr<ParseTableReference> right_table_;
std::unique_ptr<ParsePredicate> join_predicate_;
DISALLOW_COPY_AND_ASSIGN(ParseJoinedTableReference);
};
/** @} */
} // namespace quickstep
#endif /* QUICKSTEP_PARSER_PARSE_JOINED_TABLE_REFERENCE_HPP_ */