http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParsePredicate.hpp ---------------------------------------------------------------------- diff --git a/parser/ParsePredicate.hpp b/parser/ParsePredicate.hpp deleted file mode 100644 index cc3e66d..0000000 --- a/parser/ParsePredicate.hpp +++ /dev/null @@ -1,453 +0,0 @@ -/** - * 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_PREDICATE_HPP_ -#define QUICKSTEP_PARSER_PARSE_PREDICATE_HPP_ - -#include <memory> -#include <string> -#include <vector> - -#include "parser/ParseExpression.hpp" -#include "parser/ParseTreeNode.hpp" -#include "utility/Macros.hpp" -#include "utility/PtrList.hpp" - -namespace quickstep { - -class Comparison; - -/** \addtogroup Parser - * @{ - */ - -/** - * @brief The parsed representation of a predicate. - **/ -class ParsePredicate : public ParseTreeNode { - public: - /** - * @brief The possible types of ParsePredicates. - **/ - enum ParsePredicateType { - kBetween, - kComparison, - kNegation, - kConjunction, - kDisjunction, - kExists, - kInTableQuery, - kInValueList - }; - - /** - * @brief Virtual destructor. - **/ - ~ParsePredicate() override {} - - /** - * @brief Identify the type of this ParsePredicate. - * - * @return The type of this ParsePredicate. - **/ - virtual ParsePredicateType getParsePredicateType() const = 0; - - protected: - ParsePredicate(const int line_number, const int column_number) - : ParseTreeNode(line_number, column_number) { - } - - private: - DISALLOW_COPY_AND_ASSIGN(ParsePredicate); -}; - -/** - * @brief The parsed representation of a simple comparison predicate. - **/ -class ParsePredicateComparison : public ParsePredicate { - public: - /** - * @brief Constructor. - * - * @param line_number Line number of the comparison operator token in the SQL statement. - * @param column_number Column number of the comparison operator token in the SQL statement. - * @param op The comparison (from the quickstep type system). - * @param left_operand The left operand of the comparison, which becomes - * owned by this ParsePredicateComparison. - * @param right_operand The right operand of the comparison, which becomes - * owned by this ParsePredicateComparison. - **/ - ParsePredicateComparison(const int line_number, - const int column_number, - const Comparison &op, - ParseExpression *left_operand, - ParseExpression *right_operand) - : ParsePredicate(line_number, column_number), - op_(op), - left_operand_(left_operand), - right_operand_(right_operand) { - } - - /** - * @brief Destructor. - */ - ~ParsePredicateComparison() override {} - - /** - * @return The comparison operator. - */ - const Comparison& op() const { - return op_; - } - - /** - * @return The left operand. - */ - const ParseExpression* left_operand() const { - return left_operand_.get(); - } - - /** - * @return The right operand. - */ - const ParseExpression* right_operand() const { - return right_operand_.get(); - } - - std::string getName() const override; - - ParsePredicateType getParsePredicateType() const override { - return kComparison; - } - - 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 Comparison &op_; - std::unique_ptr<ParseExpression> left_operand_; - std::unique_ptr<ParseExpression> right_operand_; - - DISALLOW_COPY_AND_ASSIGN(ParsePredicateComparison); -}; - -/** - * @brief The parsed representation of a NOT predicate. - **/ -class ParsePredicateNegation : public ParsePredicate { - public: - /** - * @brief Constructor. - * - * @param line_number Line number of the first token of this node in the SQL statement. - * @param column_number Column number of the first token of this node in the SQL statement. - * @param operand The inner predicate to be negated, becomes owned by this - * ParsePredicateNegation. - **/ - ParsePredicateNegation(const int line_number, const int column_number, ParsePredicate *operand) - : ParsePredicate(line_number, column_number), operand_(operand) { - } - - /** - * @brief Destructor. - */ - ~ParsePredicateNegation() override {} - - /** - * @return The operand. - */ - const ParsePredicate* operand() const { - return operand_.get(); - } - - ParsePredicateType getParsePredicateType() const override { - return kNegation; - } - - std::string getName() const override { - return "Not"; - } - - 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: - std::unique_ptr<ParsePredicate> operand_; - - DISALLOW_COPY_AND_ASSIGN(ParsePredicateNegation); -}; - -/** - * @brief The parsed representation of a BETWEEN predicate. - * The parser does not convert it to two comparison - * predicates to avoid cloning and evaluating \p middle_operand_ - * twice for complex expressions (subqueries or - * aggregations). The query optimizer is responsible for the conversion. - **/ -class ParsePredicateBetween : public ParsePredicate { - public: - /** - * @brief Construction. - * - * @param line_number The line number of 'BETWEEN' in the SQL statement. - * @param column_number The column number of 'BETWEEN' in the SQL statement. - * @param lower_bound_operand The operand on the left side of BETWEEN. - * @param check_operand The operand in between BETWEEN and AND. - * @param upper_bound_operand The operand after AND. - */ - ParsePredicateBetween(const int line_number, - const int column_number, - ParseExpression *check_operand, - ParseExpression *lower_bound_operand, - ParseExpression *upper_bound_operand) - : ParsePredicate(line_number, column_number), - check_operand_(check_operand), - lower_bound_operand_(lower_bound_operand), - upper_bound_operand_(upper_bound_operand) { - } - - /** - * @brief Destructor. - */ - ~ParsePredicateBetween() override {} - - /** - * @return The operand to be compared with the lower bound and - * the upper bound. - */ - const ParseExpression* check_operand() const { - return check_operand_.get(); - } - - /** - * @return Lower bound operand. - */ - const ParseExpression* lower_bound_operand() const { - return lower_bound_operand_.get(); - } - - /** - * @return Upper bound operand. - */ - const ParseExpression* upper_bound_operand() const { - return upper_bound_operand_.get(); - } - - ParsePredicateType getParsePredicateType() const override { - return kBetween; - } - - std::string getName() const override { - return "Between"; - } - - 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: - std::unique_ptr<ParseExpression> check_operand_; - std::unique_ptr<ParseExpression> lower_bound_operand_; - std::unique_ptr<ParseExpression> upper_bound_operand_; - - DISALLOW_COPY_AND_ASSIGN(ParsePredicateBetween); -}; - -/** - * @brief Abstract base class of conjunction and disjunction predicates. - **/ -class ParsePredicateWithList : public ParsePredicate { - public: - ~ParsePredicateWithList() override {} - - const PtrList<ParsePredicate>& operands() const { - return operands_; - } - - /** - * @brief Add a child predicate to this conjunction or disjunction. - * - * @param operand The child predicate to add to this one, which becomes - * owned by this predicate. - **/ - void addPredicate(ParsePredicate *operand) { - operands_.push_back(operand); - } - - protected: - /** - * @brief Constructor. - * - * @param line_number Line number of the first token of this node in the SQL statement. - * @param column_number Column number of the first token of this node in the SQL statement. - **/ - ParsePredicateWithList(const int line_number, const int column_number) - : ParsePredicate(line_number, column_number) { - } - - 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; - - PtrList<ParsePredicate> operands_; - - private: - DISALLOW_COPY_AND_ASSIGN(ParsePredicateWithList); -}; - -/** - * @brief An AND over other predicates. - **/ -class ParsePredicateConjunction : public ParsePredicateWithList { - public: - /** - * @brief Constructor. - * - * @param line_number Line number of the first token of this node in the SQL statement. - * @param column_number Column number of the first token of this node in the SQL statement. - **/ - ParsePredicateConjunction(const int line_number, const int column_number) - : ParsePredicateWithList(line_number, column_number) { - } - - ParsePredicateType getParsePredicateType() const override { - return kConjunction; - } - - std::string getName() const override { - return "And"; - } - - private: - DISALLOW_COPY_AND_ASSIGN(ParsePredicateConjunction); -}; - -/** - * @brief An OR over other predicates. - **/ -class ParsePredicateDisjunction : public ParsePredicateWithList { - public: - /** - * @brief Constructor. - * - * @param line_number Line number of the first token of this node in the SQL statement. - * @param column_number Column number of the first token of this node in the SQL statement. - **/ - ParsePredicateDisjunction(const int line_number, const int column_number) - : ParsePredicateWithList(line_number, column_number) { - } - - ParsePredicateType getParsePredicateType() const override { - return kDisjunction; - } - - std::string getName() const override { - return "Or"; - } - - private: - DISALLOW_COPY_AND_ASSIGN(ParsePredicateDisjunction); -}; - - -/** - * @brief Parsed representation of IN with a value list. - */ -class ParsePredicateInValueList : public ParsePredicate { - public: - /** - * @brief Constructor. - * - * @param line_number The line number of the token "IN" in the statement. - * @param column_number The column number of the token "IN" in the statement. - * @param test_expression The expression to be compared with a value list. - * @param value_list The list of values to match with test_expression. - */ - ParsePredicateInValueList(const int line_number, - const int column_number, - ParseExpression *test_expression, - PtrList<ParseExpression> *value_list) - : ParsePredicate(line_number, column_number), - test_expression_(test_expression), - value_list_(value_list) {} - - ParsePredicateType getParsePredicateType() const override { - return kInValueList; - } - - std::string getName() const override { - return "InValueList"; - } - - /** - * @return The expression to be compared with a value list. - */ - const ParseExpression* test_expression() const { - return test_expression_.get(); - } - - /** - * @return The list of values to match with test_expression. - */ - const PtrList<ParseExpression>* value_list() const { - return value_list_.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: - std::unique_ptr<ParseExpression> test_expression_; - std::unique_ptr<PtrList<ParseExpression>> value_list_; - - DISALLOW_COPY_AND_ASSIGN(ParsePredicateInValueList); -}; - -/** @} */ - -} // namespace quickstep - -#endif // QUICKSTEP_PARSER_PARSE_PREDICATE_HPP_
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParsePredicateExists.hpp ---------------------------------------------------------------------- diff --git a/parser/ParsePredicateExists.hpp b/parser/ParsePredicateExists.hpp deleted file mode 100644 index 1738964..0000000 --- a/parser/ParsePredicateExists.hpp +++ /dev/null @@ -1,95 +0,0 @@ -/** - * 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_PREDICATE_EXISTS_HPP_ -#define QUICKSTEP_PARSER_PARSE_PREDICATE_EXISTS_HPP_ - -#include <memory> -#include <string> -#include <vector> - -#include "parser/ParsePredicate.hpp" -#include "parser/ParseSubqueryExpression.hpp" -#include "utility/Macros.hpp" - -namespace quickstep { - -class ParseTreeNode; - -/** \addtogroup Parser - * @{ - */ - -/** - * @brief The parsed representation of an EXISTS predicate. - */ -class ParsePredicateExists : public ParsePredicate { - public: - /** - * @brief Constructor. - * - * @param line_number The line number of the EXISTS token in the statement. - * @param column_number The column number of the EXISTS token in the statement. - * @param subquery The subquery expression for this EXISTS predicate. - */ - ParsePredicateExists(const int line_number, - const int column_number, - ParseSubqueryExpression *subquery) - : ParsePredicate(line_number, column_number), - subquery_(subquery) { - } - - ParsePredicateType getParsePredicateType() const override { - return kExists; - } - - std::string getName() const override { - return "Exists"; - } - - /** - * @return The subquery expression for this EXISTS predicate. - */ - const ParseSubqueryExpression* subquery() const { - return subquery_.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 { - non_container_child_field_names->push_back("subquery"); - non_container_child_fields->push_back(subquery_.get()); - } - - private: - std::unique_ptr<ParseSubqueryExpression> subquery_; - - DISALLOW_COPY_AND_ASSIGN(ParsePredicateExists); -}; - -/** @} */ - -} // namespace quickstep - -#endif // QUICKSTEP_PARSER_PARSE_PREDICATE_EXISTS_HPP_ http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParsePredicateInTableQuery.hpp ---------------------------------------------------------------------- diff --git a/parser/ParsePredicateInTableQuery.hpp b/parser/ParsePredicateInTableQuery.hpp deleted file mode 100644 index d669522..0000000 --- a/parser/ParsePredicateInTableQuery.hpp +++ /dev/null @@ -1,112 +0,0 @@ -/** - * 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_PREDICATE_IN_TABLE_QUERY_HPP_ -#define QUICKSTEP_PARSER_PARSE_PREDICATE_IN_TABLE_QUERY_HPP_ - -#include <memory> -#include <string> -#include <vector> - -#include "parser/ParseExpression.hpp" -#include "parser/ParsePredicate.hpp" -#include "parser/ParseSubqueryExpression.hpp" -#include "utility/Macros.hpp" - -namespace quickstep { - -class ParseTreeNode; - -/** \addtogroup Parser - * @{ - */ - -/** - * @brief Parsed representation of IN with a table subquery expression. - * - * @note Putting the class here instead of in ParsePredicate.hpp is to avoid - * circular dependencies with ParseSelect. - */ -class ParsePredicateInTableQuery : public ParsePredicate { - public: - /** - * @brief Constructor. - * - * @param line_number The line number of the token "IN" in the statement. - * @param column_number The column number of the token "IN" in the statement. - * @param test_expression The expression to test with a subquery expression. - * @param table_query The table subquery expression to search for test_expression. - */ - ParsePredicateInTableQuery(const int line_number, - const int column_number, - ParseExpression *test_expression, - ParseSubqueryExpression *table_query) - : ParsePredicate(line_number, column_number), - test_expression_(test_expression), - table_query_(table_query) {} - - ParsePredicateType getParsePredicateType() const override { - return kInTableQuery; - } - - std::string getName() const override { - return "InTableQuery"; - } - - /** - * @return The expression to test with a subquery expression. - */ - const ParseExpression* test_expression() const { - return test_expression_.get(); - } - - /** - * @return The table subquery expression to search for test_expression. - */ - const ParseSubqueryExpression* table_query() const { - return table_query_.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 { - non_container_child_field_names->push_back("test_expression"); - non_container_child_fields->push_back(test_expression_.get()); - - non_container_child_field_names->push_back("table_query"); - non_container_child_fields->push_back(table_query_.get()); - } - - private: - std::unique_ptr<ParseExpression> test_expression_; - std::unique_ptr<ParseSubqueryExpression> table_query_; - - DISALLOW_COPY_AND_ASSIGN(ParsePredicateInTableQuery); -}; - -/** @} */ - -} // namespace quickstep - -#endif // QUICKSTEP_PARSER_PARSE_PREDICATE_IN_TABLE_QUERY_HPP_ http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParsePriority.hpp ---------------------------------------------------------------------- diff --git a/parser/ParsePriority.hpp b/parser/ParsePriority.hpp deleted file mode 100644 index e53fbfa..0000000 --- a/parser/ParsePriority.hpp +++ /dev/null @@ -1,96 +0,0 @@ -/** - * 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_PRIORITY_HPP_ -#define QUICKSTEP_PARSER_PARSE_PRIORITY_HPP_ - -#include <memory> -#include <string> -#include <vector> - -#include "parser/ParseLiteralValue.hpp" -#include "parser/ParseTreeNode.hpp" -#include "utility/Macros.hpp" - -namespace quickstep { - -/** \addtogroup Parser - * @{ - */ - -/** - * @brief A parsed representation of PRIORITY. - **/ -class ParsePriority : public ParseTreeNode { - public: - /** - * @brief Constructor. - * - * @param line_number The line number of "PRIORITY" in the SQL statement. - * @param column_number The column number of "PRIORITY" in the SQL statement. - * @param priority_expression The PRIORITY value expression. - **/ - ParsePriority(const int line_number, - const int column_number, - NumericParseLiteralValue *priority_expression) - : ParseTreeNode(line_number, column_number), - priority_expression_(priority_expression) {} - - /** - * @brief Destructor. - */ - ~ParsePriority() override {} - - /** - * @brief Gets the PRIORITY expression. - * - * @return PRIORITY expression - */ - const NumericParseLiteralValue* priority_expression() const { - return priority_expression_.get(); - } - - std::string getName() const override { - return "PRIORITY"; - } - - 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 { - non_container_child_field_names->push_back(""); - non_container_child_fields->push_back(priority_expression_.get()); - } - - private: - std::unique_ptr<NumericParseLiteralValue> priority_expression_; - - DISALLOW_COPY_AND_ASSIGN(ParsePriority); -}; - -/** @} */ - -} // namespace quickstep - -#endif // QUICKSTEP_PARSER_PARSE_PRIORITY_HPP_ http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParseSample.cpp ---------------------------------------------------------------------- diff --git a/parser/ParseSample.cpp b/parser/ParseSample.cpp deleted file mode 100644 index 47e69e6..0000000 --- a/parser/ParseSample.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/** - * 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. - **/ - -#include "parser/ParseSample.hpp" - -#include <string> -#include <vector> - -#include "parser/ParseLiteralValue.hpp" - -namespace quickstep { - -void ParseSample::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 { - non_container_child_field_names->push_back("Sample Percentage"); - non_container_child_fields->push_back(percentage_.get()); -} - -} // namespace quickstep http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParseSample.hpp ---------------------------------------------------------------------- diff --git a/parser/ParseSample.hpp b/parser/ParseSample.hpp deleted file mode 100644 index e2b5672..0000000 --- a/parser/ParseSample.hpp +++ /dev/null @@ -1,105 +0,0 @@ -/** - * 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_SAMPLE_HPP_ -#define QUICKSTEP_PARSER_PARSE_SAMPLE_HPP_ - -#include <memory> -#include <string> -#include <vector> - -#include "parser/ParseLiteralValue.hpp" -#include "parser/ParseTreeNode.hpp" -#include "utility/Macros.hpp" - -namespace quickstep { - -/** \addtogroup Parser - * @{ - */ - -/** - * @brief A parsed representation of block/tuple sample. - */ -class ParseSample : public ParseTreeNode { - public: - /** - * @brief Constructor. - * @note This constructor takes ownership of \c percentage. - * - * @param line_number The line number of "SAMPLE" in the SQL statement. - * @param column_number The column number of "SAMPLE" in the SQL statement. - * @param is_block_sample The flag indicating whether this is block sample or tuple sample. - * @param percentage The percentage of data to sample. - */ - ParseSample(const int line_number, - const int column_number, - const bool is_block_sample, - NumericParseLiteralValue *percentage) - : ParseTreeNode(line_number, column_number), - percentage_(percentage), - is_block_sample_(is_block_sample) {} - - /** - * @brief Destructor. - */ - ~ParseSample() override {} - - /** - * @brief Get the sample percentage. - * - * @return The sample percentage. - */ - const NumericParseLiteralValue* percentage() const { - return percentage_.get(); - } - - /** - * @brief Get the sample type indicating flag. - * - * @return True if this is a block sample. False if this is a tuple sample. - */ - bool is_block_sample() const { - return is_block_sample_; - } - - std::string getName() const override { - return "SAMPLE"; - } - - 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: - std::unique_ptr<NumericParseLiteralValue> percentage_; - const bool is_block_sample_; - - DISALLOW_COPY_AND_ASSIGN(ParseSample); -}; - -/** @} */ - -} // namespace quickstep - -#endif // QUICKSTEP_PARSER_PARSE_SAMPLE_HPP_ http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParseSelect.hpp ---------------------------------------------------------------------- diff --git a/parser/ParseSelect.hpp b/parser/ParseSelect.hpp deleted file mode 100644 index d6732e6..0000000 --- a/parser/ParseSelect.hpp +++ /dev/null @@ -1,235 +0,0 @@ -/** - * 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_SELECT_HPP_ -#define QUICKSTEP_PARSER_PARSE_SELECT_HPP_ - -#include <memory> -#include <string> -#include <vector> - -#include "parser/ParseGroupBy.hpp" -#include "parser/ParseHaving.hpp" -#include "parser/ParseLimit.hpp" -#include "parser/ParseOrderBy.hpp" -#include "parser/ParsePredicate.hpp" -#include "parser/ParseSelectionClause.hpp" -#include "parser/ParseTableReference.hpp" -#include "parser/ParseTreeNode.hpp" -#include "parser/ParseWindow.hpp" -#include "utility/Macros.hpp" -#include "utility/PtrList.hpp" - -#include "glog/logging.h" - -namespace quickstep { - -/** - * @brief The parsed representation of a (sub-query) SELECT statement. - **/ -class ParseSelect : public ParseTreeNode { - public: - /** - * @brief Constructor. - * @note Takes ownership of all pointers. - * - * @param line_number Line number of the first token of this node in the SQL statement. - * @param column_number Column number of the first token of this node in the SQL statement. - * @param selection The parsed selection, which becomes owned by this - * ParseStatementSelect. - * @param from_list The parsed list of table references in the FROM clause, - * which becomes owned by this ParseStatementSelect. - * @param where_predicate An optional predicate representing the parsed - * WHERE clause (may be NULL if no predicate). Becomes owned by this - * ParseStatementSelect if non-NULL. - * @param group_by Optional parsed GROUP BY clause. Becomes owned by this ParseStatementSelect. - * @param having_predicate Optional parsed HAVING clause. Becomes owned by this ParseStatementSelect. - * @param order_by Optional parsed ORDER BY clause. Becomes owned by this ParseStatementSelect. - * @param limit Optional parsed LIMIT clause. Becomes owned by this ParseStatementSelect. - **/ - ParseSelect(const int line_number, - const int column_number, - ParseSelectionClause *selection, - PtrList<ParseTableReference> *from_list, - ParsePredicate *where_predicate, - ParseGroupBy *group_by, - ParseHaving *having, - ParseOrderBy *order_by, - ParseLimit *limit, - PtrList<ParseWindow> *window_list) - : ParseTreeNode(line_number, column_number), - selection_(selection), - from_list_(from_list), - where_predicate_(where_predicate), - group_by_(group_by), - having_(having), - order_by_(order_by), - limit_(limit), - window_list_(window_list) { - } - - ~ParseSelect() override { - } - - std::string getName() const override { - return "Select"; - } - - /** - * @brief Gets the selection. - * - * @return The selection. - **/ - const ParseSelectionClause& selection() const { - return *selection_; - } - - /** - * @brief Gets the FROM list. - * - * @return The list of table references in the FROM clause. - **/ - const PtrList<ParseTableReference>& from_list() const { - return *from_list_; - } - - /** - * @brief Determines whether this select statement has a WHERE predicate. - * - * @return Whether there is a WHERE predicate in this statement. - **/ - bool hasWherePredicate() const { - return where_predicate_.get() != nullptr; - } - - /** - * @brief Gets the WHERE predicate. - * @warning Always call hasWherePredicate() first. - * - * @return The parsed WHERE predicate. - **/ - const ParsePredicate& where_predicate() const { - DCHECK(hasWherePredicate()); - return *where_predicate_; - } - - /** - * @brief Gets the parsed GROUP BY. - * - * @return The parsed GROUP BY. - */ - const ParseGroupBy* group_by() const { return group_by_.get(); } - - /** - * @brief Gets the parsed HAVING. - * - * @return The parsed HAVNING. - */ - const ParseHaving* having() const { return having_.get(); } - - /** - * @brief Gets the parsed ORDER BY. - * - * @return The parsed ORDER BY. - */ - const ParseOrderBy* order_by() const { return order_by_.get(); } - - /** - * @brief Gets the parsed LIMIT. - * - * @return The parsed LIMIT. - */ - const ParseLimit* limit() const { return limit_.get(); } - - /** - * @brief Gets the parsed WINDOW. - * - * @return The parsed WINDOW. - */ - const PtrList<ParseWindow>* window_list() const { return window_list_.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 { - non_container_child_field_names->push_back("select_clause"); - non_container_child_fields->push_back(selection_.get()); - - if (where_predicate_ != nullptr) { - non_container_child_field_names->push_back("where_clause"); - non_container_child_fields->push_back(where_predicate_.get()); - } - - if (from_list_ != nullptr) { - container_child_field_names->push_back("from_clause"); - container_child_fields->emplace_back(); - for (const ParseTableReference &from_item : *from_list_) { - container_child_fields->back().push_back(&from_item); - } - } - - if (group_by_ != nullptr) { - non_container_child_field_names->push_back("group_by"); - non_container_child_fields->push_back(group_by_.get()); - } - - if (having_ != nullptr) { - non_container_child_field_names->push_back("having"); - non_container_child_fields->push_back(having_.get()); - } - - if (order_by_ != nullptr) { - non_container_child_field_names->push_back("order_by"); - non_container_child_fields->push_back(order_by_.get()); - } - - if (limit_ != nullptr) { - non_container_child_field_names->push_back("limit"); - non_container_child_fields->push_back(limit_.get()); - } - - if (window_list_ != nullptr) { - container_child_field_names->push_back("window_list"); - container_child_fields->emplace_back(); - for (const ParseWindow &window : *window_list_) { - container_child_fields->back().push_back(&window); - } - } - } - - private: - std::unique_ptr<ParseSelectionClause> selection_; - std::unique_ptr<PtrList<ParseTableReference> > from_list_; - std::unique_ptr<ParsePredicate> where_predicate_; - std::unique_ptr<ParseGroupBy> group_by_; - std::unique_ptr<ParseHaving> having_; - std::unique_ptr<ParseOrderBy> order_by_; - std::unique_ptr<ParseLimit> limit_; - std::unique_ptr<PtrList<ParseWindow>> window_list_; - - DISALLOW_COPY_AND_ASSIGN(ParseSelect); -}; - -} // namespace quickstep - -#endif /* QUICKSTEP_PARSER_PARSESELECT_HPP_ */ http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParseSelectionClause.cpp ---------------------------------------------------------------------- diff --git a/parser/ParseSelectionClause.cpp b/parser/ParseSelectionClause.cpp deleted file mode 100644 index 1e9a807..0000000 --- a/parser/ParseSelectionClause.cpp +++ /dev/null @@ -1,60 +0,0 @@ -/** - * 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. - **/ - -#include "parser/ParseSelectionClause.hpp" - -#include <string> -#include <vector> - -#include "parser/ParseExpression.hpp" -#include "parser/ParseString.hpp" - -namespace quickstep { - -void ParseSelectionItem::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 { - if (alias_ != nullptr) { - inline_field_names->push_back("alias"); - inline_field_values->push_back(alias_->value()); - } - - non_container_child_field_names->push_back(""); - non_container_child_fields->push_back(expression_.get()); -} - -void ParseSelectionList::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 { - container_child_field_names->push_back(""); - container_child_fields->emplace_back(); - for (const ParseSelectionItem& select_item : select_item_list_) { - container_child_fields->back().push_back(&select_item); - } -} - -} // namespace quickstep http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParseSelectionClause.hpp ---------------------------------------------------------------------- diff --git a/parser/ParseSelectionClause.hpp b/parser/ParseSelectionClause.hpp deleted file mode 100644 index f636f36..0000000 --- a/parser/ParseSelectionClause.hpp +++ /dev/null @@ -1,219 +0,0 @@ -/** - * 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_SELECTION_CLAUSE_HPP_ -#define QUICKSTEP_PARSER_PARSE_SELECTION_CLAUSE_HPP_ - -#include <memory> -#include <string> -#include <vector> - -#include "parser/ParseExpression.hpp" -#include "parser/ParseString.hpp" -#include "parser/ParseTreeNode.hpp" -#include "utility/Macros.hpp" -#include "utility/PtrList.hpp" - -namespace quickstep { - -class ParseSelectionItem; - -/** \addtogroup Parser - * @{ - */ - -/** - * @brief The complete selection in a SELECT statement. - **/ -class ParseSelectionClause : public ParseTreeNode { - public: - /** - * @brief The type of a SELECT clause. - */ - enum SelectionType { - kStar, //!< kStar Represents a SELECT clause with * as its only SELECT-list item. - kNonStar, //!< kNonStar Represents a SELECT clause with expressions. - }; - - /** - * @return The type of this SELECT clause. - */ - virtual SelectionType getSelectionType() const = 0; - - protected: - ParseSelectionClause(const int line_number, const int column_number) - : ParseTreeNode(line_number, column_number) { - } - - private: - DISALLOW_COPY_AND_ASSIGN(ParseSelectionClause); -}; - -/** - * @brief A "star" (*) selection, representing all attributes from all - * relations in the FROM list. - **/ -class ParseSelectionStar : public ParseSelectionClause { - public: - /** - * @brief Constructor. - * - * @param line_number The line number of "*" in the SQL statement string. - * @param column_number The column number of "*" in the SQL statement string. - */ - ParseSelectionStar(const int line_number, const int column_number) - : ParseSelectionClause(line_number, column_number) { - } - - SelectionType getSelectionType() const override { - return kStar; - } - - std::string getName() const override { return "SelectStar"; } - - 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: - DISALLOW_COPY_AND_ASSIGN(ParseSelectionStar); -}; - -/** - * @brief A list of comma-seperated ParseSelectionItems. - **/ -class ParseSelectionList : public ParseSelectionClause { - public: - /** - * @brief Constructor. - * - * @param line_number The line number of the first token of the SELECT list in the SQL statement string. - * @param column_number The column number of the first token of the SELECT list in the SQL statement string. - */ - ParseSelectionList(const int line_number, const int column_number) - : ParseSelectionClause(line_number, column_number) { - } - - SelectionType getSelectionType() const override { - return kNonStar; - } - - std::string getName() const override { return "SelectList"; } - - /** - * @return The list of SELECT-list items. - */ - const PtrList<ParseSelectionItem>& select_item_list() const { return select_item_list_; } - - /** - * @brief Append an item to the selection list. - * - * @param item The selection item to add to the end of this selection list, - * which becomes owned by this ParseSelectionList. - **/ - void add(ParseSelectionItem *item) { - select_item_list_.push_back(item); - } - - 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: - PtrList<ParseSelectionItem> select_item_list_; - - DISALLOW_COPY_AND_ASSIGN(ParseSelectionList); -}; - -/** - * @brief A SELECT-list item that consists of an expression and optionally an alias. - */ -class ParseSelectionItem : public ParseTreeNode { - public: - /** - * @brief Constructor. - * - * @param line_number The line number of the first token of this item in the SQL statement string. - * @param column_number The column number of the first token of this item in the SQL statement string. - * @param expression The SELECT-list expression. - * @param alias The expression alias name. - */ - ParseSelectionItem(const int line_number, - const int column_number, - ParseExpression *expression, - ParseString *alias = nullptr) - : ParseTreeNode(line_number, column_number), - expression_(expression), - alias_(alias) {} - - /** - * @brief Destructor. - */ - ~ParseSelectionItem() override {} - - std::string getName() const override { return "SelectListItem"; } - - /** - * @return The SELECT-list expression. - */ - const ParseExpression* expression() const { return expression_.get(); } - - /** - * @return The alias of the SELECT-list expression. - */ - const ParseString* alias() const { return alias_.get(); } - - /** - * @return Generates a human-readable name for the current expression. - */ - std::string generateName() const { - return expression_->generateName(); - } - - 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: - std::unique_ptr<ParseExpression> expression_; - std::unique_ptr<ParseString> alias_; - - DISALLOW_COPY_AND_ASSIGN(ParseSelectionItem); -}; - -/** @} */ - -} // namespace quickstep - -#endif // QUICKSTEP_PARSER_PARSE_SELECTION_CLAUSE_HPP_ http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParseSimpleTableReference.cpp ---------------------------------------------------------------------- diff --git a/parser/ParseSimpleTableReference.cpp b/parser/ParseSimpleTableReference.cpp deleted file mode 100644 index 518dc20..0000000 --- a/parser/ParseSimpleTableReference.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/** - * 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. - **/ - -#include "parser/ParseSimpleTableReference.hpp" - -#include <string> -#include <vector> - -#include "parser/ParseSample.hpp" -#include "parser/ParseTableReference.hpp" - -namespace quickstep { - -class ParseTreeNode; - -void ParseSimpleTableReference::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 { - ParseTableReference::getFieldStringItems(inline_field_names, - inline_field_values, - non_container_child_field_names, - non_container_child_fields, - container_child_field_names, - container_child_fields); - inline_field_names->push_back("table"); - inline_field_values->push_back(table_name_->value()); - if (sample_ != nullptr) { - non_container_child_field_names->push_back("sample"); - non_container_child_fields->push_back(sample_.get()); - } -} - -} // namespace quickstep http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParseSimpleTableReference.hpp ---------------------------------------------------------------------- diff --git a/parser/ParseSimpleTableReference.hpp b/parser/ParseSimpleTableReference.hpp deleted file mode 100644 index 4ff92a5..0000000 --- a/parser/ParseSimpleTableReference.hpp +++ /dev/null @@ -1,102 +0,0 @@ -/** - * 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_SIMPLE_TABLE_REFERENCE_HPP_ -#define QUICKSTEP_PARSER_PARSE_SIMPLE_TABLE_REFERENCE_HPP_ - -#include <memory> -#include <string> -#include <vector> - -#include "parser/ParseSample.hpp" -#include "parser/ParseString.hpp" -#include "parser/ParseTableReference.hpp" -#include "utility/Macros.hpp" - -namespace quickstep { - -class ParseTreeNode; - -/** \addtogroup Parser - * @{ - */ - -/** - * @brief A FROM-list table reference by relation name. - */ -class ParseSimpleTableReference : public ParseTableReference { - public: - /** - * @brief Constructor. - * @note Takes ownership of \p table_name and \p sample. - * - * @param line_number The line number of the first token of the table reference. - * @param column_number The column number of the first token of the table reference. - * @param table_name The table name. - * @param sample The sampling type and percentage associated with the table reference. - */ - ParseSimpleTableReference(const int line_number, - const int column_number, - ParseString *table_name, - ParseSample *sample) - : ParseTableReference(line_number, column_number), - table_name_(table_name), - sample_(sample) {} - - /** - * @brief Destructor. - */ - ~ParseSimpleTableReference() override {} - - TableReferenceType getTableReferenceType() const override { - return kSimpleTableReference; - } - - std::string getName() const override { return "TableReference"; } - - /** - * @return The table name. - */ - const ParseString* table_name() const { return table_name_.get(); } - - /** - * @return The sample type and percentage. - */ - const ParseSample* sample() const { return sample_.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: - std::unique_ptr<ParseString> table_name_; - std::unique_ptr<ParseSample> sample_; - DISALLOW_COPY_AND_ASSIGN(ParseSimpleTableReference); -}; - -/** @} */ - -} // namespace quickstep - -#endif // QUICKSTEP_PARSER_PARSE_SIMPLE_TABLE_REFERENCE_HPP_