http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParseAttributeDefinition.cpp ---------------------------------------------------------------------- diff --git a/parser/ParseAttributeDefinition.cpp b/parser/ParseAttributeDefinition.cpp deleted file mode 100644 index ec6508b..0000000 --- a/parser/ParseAttributeDefinition.cpp +++ /dev/null @@ -1,91 +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/ParseAttributeDefinition.hpp" - -#include <string> -#include <vector> - -#include "parser/ParseString.hpp" -#include "types/Type.hpp" -#include "utility/PtrList.hpp" - -namespace quickstep { - -ParseAttributeDefinition::ParseAttributeDefinition(const int line_number, - const int column_number, - ParseString *name, - ParseDataType *data_type, - PtrList<ParseColumnConstraint> *constraint_list) - : ParseTreeNode(line_number, column_number), name_(name), data_type_(data_type) { - if (constraint_list != nullptr) { - for (PtrList<ParseColumnConstraint>::const_iterator it = constraint_list->begin(); - it != constraint_list->end(); - ++it) { - it->applyTo(this); - } - - delete constraint_list; - } -} - -void ParseAttributeDefinition::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 { - inline_field_names->push_back("name"); - inline_field_values->push_back(name_->value()); - inline_field_names->push_back("type"); - inline_field_values->push_back(data_type_->getType().getName()); -} - -void ParseColumnConstraintNull::applyTo(ParseAttributeDefinition *target) const { - target->data_type_->type_ = &(target->data_type_->type_->getNullableVersion()); -} - -void ParseColumnConstraintNull::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 { - inline_field_names->push_back("nullable"); - inline_field_values->push_back("true"); -} - -void ParseColumnConstraintNotNull::applyTo(ParseAttributeDefinition *target) const { - target->data_type_->type_ = &(target->data_type_->type_->getNonNullableVersion()); -} - -void ParseColumnConstraintNotNull::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 { - inline_field_names->push_back("nullable"); - inline_field_values->push_back("false"); -} - -} // namespace quickstep
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParseAttributeDefinition.hpp ---------------------------------------------------------------------- diff --git a/parser/ParseAttributeDefinition.hpp b/parser/ParseAttributeDefinition.hpp deleted file mode 100644 index 5c20d13..0000000 --- a/parser/ParseAttributeDefinition.hpp +++ /dev/null @@ -1,255 +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_ATTRIBUTE_DEFINITION_HPP_ -#define QUICKSTEP_PARSER_PARSE_ATTRIBUTE_DEFINITION_HPP_ - -#include <memory> -#include <string> -#include <vector> - -#include "parser/ParseString.hpp" -#include "parser/ParseTreeNode.hpp" -#include "utility/Macros.hpp" - -namespace quickstep { - -class ParseColumnConstraint; -class Type; - -template <class T> class PtrList; - -/** \addtogroup Parser - * @{ - */ - -/** - * @brief Parsed representation of a data type. - **/ -class ParseDataType { - public: - /** - * @brief Constructor. - * - * @param type The Type of the data. - **/ - explicit ParseDataType(const Type &type) - : type_(&type) { - } - - /** - * @brief Get the type. - * - * @return The Type. - **/ - const Type& getType() const { - return *type_; - } - - private: - // Use a pointer instead of a reference so that it may be modified by column - // constraints. - const Type *type_; - - friend class ParseColumnConstraintNull; - friend class ParseColumnConstraintNotNull; - - DISALLOW_COPY_AND_ASSIGN(ParseDataType); -}; - -/** - * @brief Parsed representation of an attribute definition - **/ -class ParseAttributeDefinition : public ParseTreeNode { - 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 name The attribute name. - * @param data_type The parsed data type (becomes owned by this - * ParseAttributeDefinition). - * @param constraint_list An optional list of column constraints (may be NULL - * if no constraints). - **/ - ParseAttributeDefinition(const int line_number, - const int column_number, - ParseString *name, - ParseDataType *data_type, - PtrList<ParseColumnConstraint> *constraint_list); - - /** - * @brief Destructor - **/ - ~ParseAttributeDefinition() override {} - - std::string getName() const override { - return "AttributeDefinition"; - } - - /** - * @brief Get the attribute name - * - * @return The attribute name - **/ - const ParseString* name() const { - return name_.get(); - } - - /** - * @brief Get the parsed data type - * - * @return The data type - **/ - const ParseDataType& data_type() const { - return *data_type_; - } - - 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> name_; - std::unique_ptr<ParseDataType> data_type_; - - friend class ParseColumnConstraintNull; - friend class ParseColumnConstraintNotNull; - - DISALLOW_COPY_AND_ASSIGN(ParseAttributeDefinition); -}; - -/** - * @brief A column constraint that can be applied to an attribute definition. - **/ -class ParseColumnConstraint : public ParseTreeNode { - public: - /** - * @brief Virtual destructor. - **/ - ~ParseColumnConstraint() override { - } - - /** - * @brief Apply this constraint to an attribute definition. - * - * @param target The attribute definition to modify with this constraint. - **/ - virtual void applyTo(ParseAttributeDefinition *target) const = 0; - - protected: - ParseColumnConstraint(const int line_number, const int column_number) - : ParseTreeNode(line_number, column_number) { - } - - private: - DISALLOW_COPY_AND_ASSIGN(ParseColumnConstraint); -}; - -/** - * @brief A column constraint allowing NULL values. - **/ -class ParseColumnConstraintNull: public ParseColumnConstraint { - 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. - **/ - ParseColumnConstraintNull(const int line_number, const int column_number) - : ParseColumnConstraint(line_number, column_number) { - } - - /** - * @brief Destructor. - */ - ~ParseColumnConstraintNull() override { - } - - std::string getName() const override { - return "NullablityColumnConstraint"; - } - - void applyTo(ParseAttributeDefinition *target) const override; - - 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(ParseColumnConstraintNull); -}; - -/** - * @brief A column constraint disallowing NULL values. - **/ -class ParseColumnConstraintNotNull: public ParseColumnConstraint { - 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. - **/ - ParseColumnConstraintNotNull(const int line_number, const int column_number) - : ParseColumnConstraint(line_number, column_number) { - } - - /** - * @brief Destructor. - */ - ~ParseColumnConstraintNotNull() override { - } - - std::string getName() const override { - return "NullablityColumnConstraint"; - } - - void applyTo(ParseAttributeDefinition *target) const override; - - 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(ParseColumnConstraintNotNull); -}; - -/** @} */ - -} // namespace quickstep - -#endif // QUICKSTEP_PARSER_PARSE_ATTRIBUTE_DEFINITION_HPP_ http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParseBasicExpressions.cpp ---------------------------------------------------------------------- diff --git a/parser/ParseBasicExpressions.cpp b/parser/ParseBasicExpressions.cpp deleted file mode 100644 index b0b1247..0000000 --- a/parser/ParseBasicExpressions.cpp +++ /dev/null @@ -1,233 +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/ParseBasicExpressions.hpp" - -#include <string> -#include <vector> - -#include "parser/ParseLiteralValue.hpp" -#include "parser/ParseString.hpp" -#include "types/operations/binary_operations/BinaryOperation.hpp" -#include "types/operations/unary_operations/UnaryOperation.hpp" - -using std::string; - -namespace quickstep { - -void ParseScalarLiteral::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(""); - non_container_child_fields->push_back(literal_value_.get()); -} - -string ParseAttribute::generateName() const { - string name; - if (rel_name_ != nullptr) { - name.append(rel_name_->value()); - name.append("."); - } - name.append(attr_name_->value()); - return name; -} - -void ParseAttribute::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 { - inline_field_names->push_back("attribute_name"); - inline_field_values->push_back(attr_name_->value()); - - if (rel_name_ != nullptr) { - inline_field_names->push_back("relation_name"); - inline_field_values->push_back(rel_name_->value()); - } -} - -std::string ParseUnaryExpression::getName() const { - return op_.getName(); -} - -string ParseUnaryExpression::generateName() const { - string name(op_.getShortName()); - name.append(operand_->generateName()); - return name; -} - -void ParseUnaryExpression::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(""); - non_container_child_fields->push_back(operand_.get()); -} - -std::string ParseBinaryExpression::getName() const { - return op_.getName(); -} - -string ParseBinaryExpression::generateName() const { - string name("("); - name.append(left_operand_->generateName()); - name.append(op_.getShortName()); - name.append(right_operand_->generateName()); - name.push_back(')'); - return name; -} - -void ParseBinaryExpression::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("left_operand"); - non_container_child_fields->push_back(left_operand_.get()); - - non_container_child_field_names->push_back("right_operand"); - non_container_child_fields->push_back(right_operand_.get()); -} - -std::string ParseFunctionCall::generateName() const { - string name(name_->value()); - name.push_back('('); - if (star_ != nullptr) { - name.push_back('*'); - } else { - if (is_distinct_) { - name.append("DISTINCT "); - } - bool first = true; - for (const ParseExpression &argument : *arguments_) { - if (!first) { - name.append(", "); - } else { - first = false; - } - name.append(argument.generateName()); - } - } - name.push_back(')'); - return name; -} - -void ParseFunctionCall::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 { - inline_field_names->push_back("name"); - inline_field_values->push_back(name_->value()); - - if (is_distinct_) { - inline_field_names->push_back("is_distinct"); - inline_field_values->push_back("true"); - } - - if (star_ != nullptr) { - inline_field_names->push_back("is_star"); - inline_field_values->push_back("true"); - } else { - for (const ParseExpression &argument : *arguments_) { - non_container_child_field_names->push_back(""); - non_container_child_fields->push_back(&argument); - } - - if (window_name_ != nullptr) { - inline_field_names->push_back("window_name"); - inline_field_values->push_back(window_name_->value()); - } - - if (window_ != nullptr) { - non_container_child_field_names->push_back("window"); - non_container_child_fields->push_back(window_.get()); - } - } -} - -std::string ParseExtractFunction::generateName() const { - std::string name; - name.append("EXTRACT("); - name.append(extract_field_->value()); - name.append(" FROM "); - name.append(date_expression_->generateName()); - name.push_back(')'); - return name; -} - -void ParseExtractFunction::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 { - inline_field_names->push_back("unit"); - inline_field_values->push_back(extract_field_->value()); - - non_container_child_field_names->push_back("date_expression"); - non_container_child_fields->push_back(date_expression_.get()); -} - -std::string ParseSubstringFunction::generateName() const { - std::string name; - name.append("SUBSTRING("); - name.append(operand_->generateName()); - name.append(" FROM "); - name.append(std::to_string(start_position_)); - if (length_ != kDefaultLength) { - name.append(" FOR "); - name.append(std::to_string(length_)); - } - name.push_back(')'); - return name; -} - -void ParseSubstringFunction::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 { - inline_field_names->push_back("start_position"); - inline_field_values->push_back(std::to_string(start_position_)); - - inline_field_names->push_back("length"); - inline_field_values->push_back(std::to_string(length_)); - - non_container_child_field_names->push_back("operand"); - non_container_child_fields->push_back(operand_.get()); -} - -} // namespace quickstep http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParseBasicExpressions.hpp ---------------------------------------------------------------------- diff --git a/parser/ParseBasicExpressions.hpp b/parser/ParseBasicExpressions.hpp deleted file mode 100644 index d8de669..0000000 --- a/parser/ParseBasicExpressions.hpp +++ /dev/null @@ -1,640 +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_BASIC_EXPRESSIONS_HPP_ -#define QUICKSTEP_PARSER_PARSE_BASIC_EXPRESSIONS_HPP_ - -#include <cstddef> -#include <limits> -#include <memory> -#include <string> -#include <vector> - -#include "parser/ParseExpression.hpp" -#include "parser/ParseLiteralValue.hpp" -#include "parser/ParseString.hpp" -#include "parser/ParseTreeNode.hpp" -#include "parser/ParseWindow.hpp" -#include "utility/Macros.hpp" -#include "utility/PtrList.hpp" - -namespace quickstep { - -class BinaryOperation; -class UnaryOperation; - -/** \addtogroup Parser - * @{ - */ - -/** - * @brief The parsed representation of a literal value. - **/ -class ParseScalarLiteral : public ParseExpression { - public: - /** - * @brief Constructor. - * - * @param literal_value The parsed literal value to represent, which becomes - * owned by this ParseScalarLiteral. - **/ - explicit ParseScalarLiteral(ParseLiteralValue *literal_value) - : ParseExpression(literal_value->line_number(), - literal_value->column_number()), - literal_value_(literal_value) { - } - - /** - * @brief Destructor. - */ - ~ParseScalarLiteral() override { - } - - /** - * @brief Gets the parsed literal value. - * - * @return The parsed literal value. - */ - const ParseLiteralValue* literal_value() const { - return literal_value_.get(); - } - - ExpressionType getExpressionType() const override { - return kScalarLiteral; - } - - std::string getName() const override { - return "Literal"; - } - - std::string generateName() const override { - return literal_value_->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<ParseLiteralValue> literal_value_; - - DISALLOW_COPY_AND_ASSIGN(ParseScalarLiteral); -}; - - -/** - * @brief The parsed representation of an attribute reference. - **/ -class ParseAttribute : public ParseExpression { - 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 attr_name The name of the attribute. - * @param rel_name An optional relation name to qualify the attribute name - * (by default, all relations in the FROM list will be searched for - * the attribute). - **/ - ParseAttribute(const int line_number, - const int column_number, - ParseString *attr_name, - ParseString *rel_name = nullptr) - : ParseExpression(line_number, column_number), - attr_name_(attr_name), - rel_name_(rel_name) { - } - - /** - * @brief Destructor. - */ - ~ParseAttribute() override {} - - ExpressionType getExpressionType() const override { - return kAttribute; - } - - std::string getName() const override { - return "AttributeReference"; - } - - /** - * @return Attribute name. - */ - const ParseString* attr_name() const { - return attr_name_.get(); - } - - /** - * @return Relation name. - */ - const ParseString* rel_name() const { - return rel_name_.get(); - } - - std::string generateName() const override; - - 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> attr_name_, rel_name_; - - DISALLOW_COPY_AND_ASSIGN(ParseAttribute); -}; - - -/** - * @brief The parsed representation of an unary operation applied to an expression. - **/ -class ParseUnaryExpression : public ParseExpression { - 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 op The UnaryOperation from the quickstep type system to apply. - * @param operand The parsed scalar representation of the unary operation's - * argument, which becomes owned by this ParseScalarUnaryExpression. - **/ - ParseUnaryExpression(const int line_number, - const int column_number, - const UnaryOperation &op, - ParseExpression *operand) - : ParseExpression(line_number, column_number), - op_(op), - operand_(operand) { - } - - /** - * @brief Destructor. - */ - ~ParseUnaryExpression() override { - } - - ExpressionType getExpressionType() const override { - return kUnaryExpression; - } - - std::string getName() const override; - - /** - * @return The unary operation. - */ - const UnaryOperation& op() const { - return op_; - } - - /** - * @return The operand expression. - */ - const ParseExpression* operand() const { - return operand_.get(); - } - - std::string generateName() const override; - - 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 UnaryOperation &op_; - std::unique_ptr<ParseExpression> operand_; - - DISALLOW_COPY_AND_ASSIGN(ParseUnaryExpression); -}; - -/** - * @brief The parsed representation of a binary operation applied to two - * expressions. - **/ -class ParseBinaryExpression : public ParseExpression { - public: - /** - * @brief Constructor. - * - * @param line_number Line number of the binary operator token in the SQL statement. - * @param column_number Column number of the binary operator token in the SQL statement. - * @param op The BinaryOperation from the quickstep type system to apply. - * @param left_operand The parsed scalar representation of the binary - * operation's left argument, which becomes owned by this - * ParseScalarBinaryExpression. - * @param right_operand The parsed scalar representation of the binary - * operation's right argument, which becomes owned by this - * ParseScalarBinaryExpression. - **/ - ParseBinaryExpression(const int line_number, - const int column_number, - const BinaryOperation &op, - ParseExpression *left_operand, - ParseExpression *right_operand) - : ParseExpression(line_number, column_number), - op_(op), - left_operand_(left_operand), - right_operand_(right_operand) { - } - - /** - * @brief Destructor. - */ - ~ParseBinaryExpression() override { - } - - ExpressionType getExpressionType() const override { - return kBinaryExpression; - } - - std::string getName() const override; - - /** - * @return The binary operation. - */ - const BinaryOperation& op() const { - return op_; - } - - /** - * @return The left operand expression. - */ - const ParseExpression* left_operand() const { - return left_operand_.get(); - } - - /** - * @return The right operand expression. - */ - const ParseExpression* right_operand() const { - return right_operand_.get(); - } - - std::string generateName() const override; - - 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 BinaryOperation &op_; - std::unique_ptr<ParseExpression> left_operand_; - std::unique_ptr<ParseExpression> right_operand_; - - DISALLOW_COPY_AND_ASSIGN(ParseBinaryExpression); -}; - -/** - * @brief The parsed representation of '*' as a function argument. - */ -class ParseStar : public ParseTreeNode { - public: - ParseStar(const int line_number, const int column_number) - : ParseTreeNode(line_number, column_number) {} - - std::string getName() const override { - return "Star"; - } - - 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(ParseStar); -}; - -/** - * @brief Parsed function call in the form of a name with a list of arguments in parentheses. - */ -class ParseFunctionCall : public ParseExpression { - public: - /** - * @brief Constructor. - * @note Takes ownership of all pointers. - * - * @param line_number The line number of the first token of the function call. - * @param column_number The column number of the first token of the first call. - * @param is_distinct Whether this function call contains the DISTINCT keyword. - * @param name The function name. - * @param arguments The function argument list. - */ - ParseFunctionCall(const int line_number, - const int column_number, - const bool is_distinct, - ParseString *name, - PtrList<ParseExpression> *arguments) - : ParseExpression(line_number, column_number), - is_distinct_(is_distinct), - name_(name), - arguments_(arguments) { - } - - /** - * @brief Constructor for a function call that has "*" as the argument. - * @note Takes ownership of all pointers. - * - * @param line_number The line number of the first token of the function call. - * @param column_number The column number of the first token of the function call. - * @param name The function name. - * @param star The parsed star. - */ - ParseFunctionCall(const int line_number, const int column_number, ParseString *name, ParseStar *star) - : ParseExpression(line_number, column_number), - is_distinct_(false), - name_(name), - star_(star) { - } - - /** - * @brief Destructor. - */ - ~ParseFunctionCall() override { - } - - ExpressionType getExpressionType() const override { - return kFunctionCall; - } - - std::string getName() const override { - return "FunctionCall"; - } - - /** - * @return Whether this function call contains the DISTINCT keyword. - */ - bool is_distinct() const { - return is_distinct_; - } - - /** - * @return The function name. - */ - const ParseString* name() const { - return name_.get(); - } - - /** - * @return The argument list. - */ - const PtrList<ParseExpression>* arguments() const { - return arguments_.get(); - } - - /** - * @return The parsed star. - */ - const ParseStar* star() const { - return star_.get(); - } - - /** - * @return The window name. - **/ - const ParseString* window_name() const { - return window_name_.get(); - } - - /** - * @return The window. - **/ - const ParseWindow* window() const { - return window_.get(); - } - - /** - * @brief Check if this function is a window aggregation function - * - * @return True if this function is a window aggregation function; false - * otherwise. - **/ - bool isWindow() const { - return window_name_ != nullptr || window_ != nullptr; - } - - /** - * @brief Set the window name. - * @param window_name The window name. - **/ - void setWindowName(ParseString *window_name) { - window_name_.reset(window_name); - } - - /** - * @brief Set the window. - * @param window The window. - **/ - void setWindow(ParseWindow *window) { - window_.reset(window); - } - - std::string generateName() const override; - - 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 bool is_distinct_; - std::unique_ptr<ParseString> name_; - // Either <arguments_> or <star_> is NULL. - std::unique_ptr<PtrList<ParseExpression>> arguments_; - std::unique_ptr<ParseStar> star_; - // A window aggregation function should have either <window_name_> or <window_> but not both. - // <window_name_> and <window_> will both be NULL if it is not a window function. - std::unique_ptr<ParseString> window_name_; - std::unique_ptr<ParseWindow> window_; - - DISALLOW_COPY_AND_ASSIGN(ParseFunctionCall); -}; - - -/** - * @brief Parsed representation of EXTRACT(unit FROM date). - */ -class ParseExtractFunction : public ParseExpression { - public: - /** - * @brief Constructor. - * - * @param line_number The line number of the token "extract" in the statement. - * @param column_number The column number of the token "extract in the statement. - * @param extract_field The field to extract. - * @param source_expression The expression to extract a field from. - */ - ParseExtractFunction(const int line_number, - const int column_number, - ParseString *extract_field, - ParseExpression *date_expression) - : ParseExpression(line_number, column_number), - extract_field_(extract_field), - date_expression_(date_expression) { - } - - ExpressionType getExpressionType() const override { - return kExtract; - } - - std::string getName() const override { - return "Extract"; - } - - /** - * @return The field to extract. - */ - const ParseString* extract_field() const { - return extract_field_.get(); - } - - /** - * @return The expression to extract a field from. - */ - const ParseExpression* date_expression() const { - return date_expression_.get(); - } - - std::string generateName() const override; - - 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> extract_field_; - std::unique_ptr<ParseExpression> date_expression_; - - DISALLOW_COPY_AND_ASSIGN(ParseExtractFunction); -}; - - -/** - * @brief Parsed representation of the substring function. - */ -class ParseSubstringFunction : public ParseExpression { - public: - static constexpr std::size_t kDefaultLength = std::numeric_limits<std::size_t>::max(); - - /** - * @brief Constructor. - * - * @param line_number The line number of the first token of the function call. - * @param column_number The column number of the first token of the function call. - * @param operand The operand of the substring. - * @param start_position The 1-based starting position of the substring. - * @param length Optional substring length. - */ - ParseSubstringFunction(const int line_number, - const int column_number, - ParseExpression *operand, - const std::size_t start_position, - const std::size_t length = kDefaultLength) - : ParseExpression(line_number, column_number), - operand_(operand), - start_position_(start_position), - length_(length) {} - - ExpressionType getExpressionType() const override { - return kSubstring; - } - - std::string getName() const override { - return "Substring"; - } - - /** - * @return The operand of the substring. - */ - const ParseExpression* operand() const { - return operand_.get(); - } - - /** - * @return The 1-based starting position of the substring. - */ - std::size_t start_position() const { - return start_position_; - } - - /** - * @return Then substring length. - */ - std::size_t length() const { - return length_; - } - - std::string generateName() const override; - - 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> operand_; - const std::size_t start_position_; - const std::size_t length_; - - DISALLOW_COPY_AND_ASSIGN(ParseSubstringFunction); -}; - -/** @} */ - -} // namespace quickstep - -#endif // QUICKSTEP_PARSER_PARSE_BASIC_EXPRESSIONS_HPP_ http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParseBlockProperties.cpp ---------------------------------------------------------------------- diff --git a/parser/ParseBlockProperties.cpp b/parser/ParseBlockProperties.cpp deleted file mode 100644 index 31c30a0..0000000 --- a/parser/ParseBlockProperties.cpp +++ /dev/null @@ -1,31 +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/ParseBlockProperties.hpp" - -#include <string> - -namespace quickstep { - -const std::string ParseBlockProperties::kKeyBlockSizeMB = "blocksizemb"; -const std::string ParseBlockProperties::kKeyCompress = "compress"; -const std::string ParseBlockProperties::kKeySort = "sort"; -const std::string ParseBlockProperties::kKeyType = "type"; - -} // namespace quickstep http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParseBlockProperties.hpp ---------------------------------------------------------------------- diff --git a/parser/ParseBlockProperties.hpp b/parser/ParseBlockProperties.hpp deleted file mode 100644 index ce0cd92..0000000 --- a/parser/ParseBlockProperties.hpp +++ /dev/null @@ -1,256 +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_BLOCK_PROPERTIES_HPP_ -#define QUICKSTEP_PARSER_PARSE_BLOCK_PROPERTIES_HPP_ - -#include <cstdint> -#include <memory> -#include <set> -#include <string> -#include <vector> - -#include "parser/ParseKeyValue.hpp" -#include "parser/ParseString.hpp" -#include "parser/ParseTreeNode.hpp" -#include "utility/Macros.hpp" -#include "utility/PtrList.hpp" -#include "utility/StringUtil.hpp" - -#include "glog/logging.h" - -namespace quickstep { - -/** \addtogroup Parser - * @{ - */ - -/** - * @brief Encapsulates the BlockProperties key-value list. Makes the job - * of resolving BlockProperties easy. - */ -class ParseBlockProperties : public ParseTreeNode { - // Valid key names for the BlockProperties. - static const std::string kKeyBlockSizeMB; - static const std::string kKeyCompress; - static const std::string kKeySort; - static const std::string kKeyType; - - public: - /** - * @brief Constructor. - * - * @param line_number Beginning line number. - * @param column_number Beginning column number. - * @param properties PtrList to the KeyValues. - */ - ParseBlockProperties(int line_number, - int column_number, - PtrList<ParseKeyValue> *properties) - : ParseTreeNode(line_number, column_number), - properties_(properties) { } - - /** - * @return The name of this entity. - */ - std::string getName() const override { - return "BlockProperties"; - } - - /** - * @brief Returns the first repeated key contained in the key-value list. - * @details A repeated key is any 2 key-values with case-insensitive matching - * key names. - * - * @return A pointer to the first repeated key-value or nullptr if there - * are no repetitions. - */ - const ParseKeyValue* getFirstRepeatedKeyValue() const { - std::set<std::string> seen_keys; - for (const ParseKeyValue &key_value : *properties_) { - std::string lower_key = ToLower(key_value.key()->value()); - std::set<std::string>::iterator itr = seen_keys.find(lower_key); - if (itr != seen_keys.end()) { - return &key_value; - } - seen_keys.insert(lower_key); - } - return nullptr; - } - - /** - * @brief Returns the first invalid key contained in the key-value list. - * @details An invalid key-value is a key-value with a key whose case-insensitive - * string does not match one of the valid key names. - * - * @return A pointer to the first invalid key-value or nullptr if there none. - */ - const ParseKeyValue* getFirstInvalidKeyValue() const { - std::set<std::string> valid_names({kKeyCompress, - kKeyType, kKeySort, kKeyBlockSizeMB}); - for (const ParseKeyValue &key_value : *properties_) { - std::string lower_key = ToLower(key_value.key()->value()); - std::set<std::string>::iterator itr = valid_names.find(lower_key); - if (itr == valid_names.end()) { - return &key_value; - } - } - return nullptr; - } - - /** - * @brief Gets the ParseString value of the type property. - * - * @return ParseString value of the type property or nullptr if the type - * was incorrect ParseKeyValue type or not specified. - */ - const ParseString* getType() const { - const ParseKeyValue *type_key_value = getKeyValueByName(kKeyType); - if (type_key_value == nullptr) { - return nullptr; - } - if (type_key_value->getKeyValueType() != - ParseKeyValue::KeyValueType::kStringString) { - return nullptr; - } - return static_cast<const ParseKeyStringValue*>(type_key_value)->value(); - } - - /** - * @brief Gets the ParseString value of the sort property. - * - * @return ParseString value of the sort property or nullptr if the type - * was not a ParseKeyStringValue or was not specified. - */ - const ParseString* getSort() const { - const ParseKeyValue *sort_key_value = getKeyValueByName(kKeySort); - if (sort_key_value == nullptr) { - return nullptr; - } - if (sort_key_value->getKeyValueType() != - ParseKeyValue::KeyValueType::kStringString) { - return nullptr; - } - return static_cast<const ParseKeyStringValue*>(sort_key_value)->value(); - } - - /** - * @brief Get the list of compressed column names. - * @note Check compressAll() first to see if all columns are to be compressed. - * - * @return A list of column names to compress. - */ - const PtrList<ParseString>* getCompressed() const { - const ParseKeyValue *compress_key_value = getKeyValueByName(kKeyCompress); - if (compress_key_value == nullptr) { - return nullptr; - } - if (compress_key_value->getKeyValueType() != - ParseKeyValue::KeyValueType::kStringStringList) { - return nullptr; - } - return static_cast<const ParseKeyStringList*>(compress_key_value)->value(); - } - - /** - * @brief True if the user specified to compress all columns. - */ - bool compressAll() const { - const ParseKeyValue *compress_key_value = getKeyValueByName(kKeyCompress); - if (compress_key_value == nullptr) { - return false; - } - if (compress_key_value->getKeyValueType() != - ParseKeyValue::KeyValueType::kStringString) { - return false; - } - // The StringString value from the parser should always be, 'ALL'. - DCHECK(static_cast<const ParseKeyStringValue*>(compress_key_value) - ->value()->value().compare("ALL") == 0) - << "BlockProperties got an invalid COMPRESS value."; - return true; - } - - /** - * @return Pointer to the blocksize property, nullptr if not specified. - */ - const ParseKeyValue* getBlockSizeMb() const { - return getKeyValueByName(kKeyBlockSizeMB); - } - - /** - * @return the blocksizemb property or -1 if not specified or not an int. - */ - std::int64_t getBlockSizeMbValue() const { - const ParseKeyValue *size_key_value = getKeyValueByName(kKeyBlockSizeMB); - if (size_key_value == nullptr) { - return -1; - } - if (size_key_value->getKeyValueType() != - ParseKeyValue::KeyValueType::kStringInteger) { - return -1; - } - std::int64_t numeric_value = - static_cast<const ParseKeyIntegerValue*>(size_key_value)->value()->long_value(); - return numeric_value; - } - - /** - * @return True if the user specified the size property. Note that returning - * true does not mean the property was valid. - */ - bool hasBlockSizeMb() const { - return getKeyValueByName(kKeyBlockSizeMB) != nullptr; - } - - 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 { - for (const ParseKeyValue &block_property : *properties_) { - non_container_child_field_names->push_back("block_property"); - non_container_child_fields->push_back(&block_property); - } - } - - private: - const ParseKeyValue* getKeyValueByName(const std::string &name) const { - // Get the first occurance of this name. - for (const ParseKeyValue &key_value : *properties_) { - if (ToLower(key_value.key()->value()).compare(name) == 0) { - return &key_value; - } - } - return nullptr; - } - - std::unique_ptr<PtrList<ParseKeyValue> > properties_; - - DISALLOW_COPY_AND_ASSIGN(ParseBlockProperties); -}; - -/** @} */ - -} // namespace quickstep - -#endif /* QUICKSTEP_PARSER_PARSE_BLOCK_PROPERTIES_HPP_ */ http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParseCaseExpressions.cpp ---------------------------------------------------------------------- diff --git a/parser/ParseCaseExpressions.cpp b/parser/ParseCaseExpressions.cpp deleted file mode 100644 index 47f2a33..0000000 --- a/parser/ParseCaseExpressions.cpp +++ /dev/null @@ -1,131 +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/ParseCaseExpressions.hpp" - -#include <memory> -#include <sstream> -#include <string> -#include <vector> - -#include "parser/ParseExpression.hpp" -#include "parser/ParsePredicate.hpp" -#include "parser/ParseTreeNode.hpp" - -namespace quickstep { - -void ParseSimpleWhenClause::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("condition_operand"); - non_container_child_fields->push_back(condition_operand_.get()); - - non_container_child_field_names->push_back("result_expression"); - non_container_child_fields->push_back(result_expression_.get()); -} - -void ParseSearchedWhenClause::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("condition_predicate"); - non_container_child_fields->push_back(condition_predicate_.get()); - - non_container_child_field_names->push_back("result_expression"); - non_container_child_fields->push_back(result_expression_.get()); -} - -std::string ParseSimpleCaseExpression::generateName() const { - std::ostringstream out; - out << "CASE " << case_operand_->generateName(); - for (const ParseSimpleWhenClause &when_clause : *when_clauses_) { - out << " WHEN " << when_clause.condition_operand()->generateName() - << " THEN " << when_clause.result_expression()->generateName(); - } - if (else_result_expression_ != nullptr) { - out << " ELSE " << else_result_expression_->generateName(); - } - out << " END"; - return out.str(); -} - -void ParseSimpleCaseExpression::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("case_operand"); - non_container_child_fields->push_back(case_operand_.get()); - - container_child_field_names->push_back("when_clauses"); - container_child_fields->emplace_back(); - for (const ParseSimpleWhenClause &when_clause : *when_clauses_) { - container_child_fields->back().push_back(&when_clause); - } - - if (else_result_expression_ != nullptr) { - non_container_child_field_names->push_back("else_result_expression"); - non_container_child_fields->push_back(else_result_expression_.get()); - } -} - -std::string ParseSearchedCaseExpression::generateName() const { - std::ostringstream out; - out << "CASE"; - for (const ParseSearchedWhenClause &when_clause : *when_clauses_) { - // TODO(jianqiao): implement generateName() for Predicate. - out << " WHEN " << when_clause.condition_predicate()->getShortString() - << " THEN " << when_clause.result_expression()->generateName(); - } - if (else_result_expression_ != nullptr) { - out << " ELSE " << else_result_expression_->generateName(); - } - out << " END"; - return out.str(); -} - -void ParseSearchedCaseExpression::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("when_clauses"); - container_child_fields->emplace_back(); - for (const ParseSearchedWhenClause &when_clause : *when_clauses_) { - container_child_fields->back().push_back(&when_clause); - } - - if (else_result_expression_ != nullptr) { - non_container_child_field_names->push_back("else_result_expression"); - non_container_child_fields->push_back(else_result_expression_.get()); - } -} - -} // namespace quickstep http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParseCaseExpressions.hpp ---------------------------------------------------------------------- diff --git a/parser/ParseCaseExpressions.hpp b/parser/ParseCaseExpressions.hpp deleted file mode 100644 index 6bc0b00..0000000 --- a/parser/ParseCaseExpressions.hpp +++ /dev/null @@ -1,315 +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_CASE_EXPRESSIONS_HPP_ -#define QUICKSTEP_PARSER_PARSE_CASE_EXPRESSIONS_HPP_ - -#include <memory> -#include <string> -#include <vector> - -#include "parser/ParseExpression.hpp" -#include "parser/ParsePredicate.hpp" -#include "parser/ParseTreeNode.hpp" -#include "utility/Macros.hpp" -#include "utility/PtrVector.hpp" - -namespace quickstep { - -/** \addtogroup Parser - * @{ - */ - -/** - * @brief The parsed representation of a WHEN clause in a simple CASE - * expression (WHEN <condition operand> THEN <result expression>). - */ -class ParseSimpleWhenClause : public ParseTreeNode { - public: - /** - * @brief Constructor. Takes ownership of all pointers. - * - * @param line_number The line number of "WHEN" in the SQL statement. - * @param column_number The column number of "WHEN" in the SQL statement. - * @param check_operand The condition operand to be compared with the - * CASE operand (not in this class) of the CASE - * expression. - * @param result_expression The result expression for this condition. - */ - ParseSimpleWhenClause(int line_number, - int column_number, - ParseExpression *condition_operand, - ParseExpression *result_expression) - : ParseTreeNode(line_number, column_number), - condition_operand_(condition_operand), - result_expression_(result_expression) { - } - - std::string getName() const override { - return "SimpleWhenClause"; - } - - /** - * @return The condition operand. - */ - const ParseExpression* condition_operand() const { - return condition_operand_.get(); - } - - /** - * @return The result expression for this condition. - */ - const ParseExpression* result_expression() const { - return result_expression_.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> condition_operand_; - std::unique_ptr<ParseExpression> result_expression_; - - DISALLOW_COPY_AND_ASSIGN(ParseSimpleWhenClause); -}; - -/** - * @brief The parsed representation of a WHEN clause in a searched CASE - * expression (WHEN <condition predicate> THEN <result expression>). - * - */ -class ParseSearchedWhenClause : public ParseTreeNode { - public: - /** - * @brief Constructor. Takes ownership of all pointers. - * - * @param line_number The line number of "WHEN" in the SQL statement. - * @param column_number The column number of "WHEN" in the SQL statement. - * @param condition_predicate The condition predicate. - * @param result_expression The result expression for this condition. - */ - ParseSearchedWhenClause(int line_number, - int column_number, - ParsePredicate *condition_predicate, - ParseExpression *result_expression) - : ParseTreeNode(line_number, column_number), - condition_predicate_(condition_predicate), - result_expression_(result_expression) { - } - - std::string getName() const override { - return "SearchedWhenClause"; - } - - /** - * @return The condition predicate. - */ - const ParsePredicate* condition_predicate() const { - return condition_predicate_.get(); - } - - /** - * @return The result expression. - */ - const ParseExpression* result_expression() const { - return result_expression_.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<ParsePredicate> condition_predicate_; - std::unique_ptr<ParseExpression> result_expression_; - - DISALLOW_COPY_AND_ASSIGN(ParseSearchedWhenClause); -}; - -/** - * @brief The parsed representation of a simple CASE expression: - * CASE <case operand> - * WHEN <condition_operand> THEN <result_expression> - * [...n] - * [ELSE <else_result_expression>] - * END - * It returns the <result_expression> of the first <case operand> = <when_operand> - * that evaluates to true; if none is found and <else_result_expression> exists, - * returns <else_result_expression>; otherwise, returns NULL. - **/ -class ParseSimpleCaseExpression : public ParseExpression { - public: - /** - * @brief Constructor. Takes ownership of all pointers. - * - * @param line_number The line number of "CASE" in the SQL statement. - * @param column_number The column number of "CASE" in the SQL statement. - * @param case_operand The CASE operand. - * @param when_clauses A vector of WHEN clauses, each having a check operand to - * be compared with the CASE operand and a result expression - * to be evaluated if the condition is satisfied. - * @param else_result_expression Optional ELSE result expression. - */ - ParseSimpleCaseExpression(int line_number, - int column_number, - ParseExpression *case_operand, - PtrVector<ParseSimpleWhenClause> *when_clauses, - ParseExpression *else_result_expression) - : ParseExpression(line_number, column_number), - case_operand_(case_operand), - when_clauses_(when_clauses), - else_result_expression_(else_result_expression) { - } - - std::string getName() const override { - return "SimpleCaseExpression"; - } - - ExpressionType getExpressionType() const override { - return kSimpleCaseExpression; - } - - /** - * @return The CASE operand. - */ - const ParseExpression* case_operand() const { - return case_operand_.get(); - } - - /** - * @return The vector of WHEN clauses. - */ - const PtrVector<ParseSimpleWhenClause>* when_clauses() const { - return when_clauses_.get(); - } - - /** - * @return The ELSE result expression. Can be NULL. - */ - const ParseExpression* else_result_expression() const { - return else_result_expression_.get(); - } - - std::string generateName() const override; - - 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> case_operand_; - std::unique_ptr<PtrVector<ParseSimpleWhenClause>> when_clauses_; - std::unique_ptr<ParseExpression> else_result_expression_; - - DISALLOW_COPY_AND_ASSIGN(ParseSimpleCaseExpression); -}; - -/** - * @brief The parsed representation of a searched CASE expression: - * CASE - * WHEN <condition_predicate> THEN <result_expression> - * [...n] - * [ELSE <else_result_expression>] - * END - * It returns the <result_expression> of the first <condition_predicate> - * that evaluates to true; if none is found and <else_result_expression> exists, - * returns <else_result_expression>; otherwise, returns NULL. - */ -class ParseSearchedCaseExpression : public ParseExpression { - public: - /** - * @brief Constructor. Takes ownership of all pointers. - * - * @param line_number The line number of "CASE" in the SQL statement. - * @param column_number The column number of "CASE" in the SQL statement. - * @param when_clauses A vector of WHEN clauses, each having a predicate - * and a result expression to be evaluate if - * the predicate evaluates to true. - * @param else_result_expression Optional ELSE result expression. - */ - ParseSearchedCaseExpression(int line_number, - int column_number, - PtrVector<ParseSearchedWhenClause> *when_clauses, - ParseExpression *else_result_expression) - : ParseExpression(line_number, column_number), - when_clauses_(when_clauses), - else_result_expression_(else_result_expression) { - } - - std::string getName() const override { - return "SearchedCaseExpression"; - } - - ExpressionType getExpressionType() const override { - return kSearchedCaseExpression; - } - - /** - * @return The vector of WHEN clauses. - */ - const PtrVector<ParseSearchedWhenClause>* when_clauses() const { - return when_clauses_.get(); - } - - /** - * @return The ELSE result expression. Can be NULL. - */ - const ParseExpression* else_result_expression() const { - return else_result_expression_.get(); - } - - std::string generateName() const override; - - 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<PtrVector<ParseSearchedWhenClause>> when_clauses_; - std::unique_ptr<ParseExpression> else_result_expression_; - - DISALLOW_COPY_AND_ASSIGN(ParseSearchedCaseExpression); -}; - -/** @} */ - -} // namespace quickstep - -#endif /* QUICKSTEP_PARSER_PARSE_CASE_EXPRESSIONS_HPP_ */ http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParseExpression.hpp ---------------------------------------------------------------------- diff --git a/parser/ParseExpression.hpp b/parser/ParseExpression.hpp deleted file mode 100644 index 1b9ade4..0000000 --- a/parser/ParseExpression.hpp +++ /dev/null @@ -1,82 +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_EXPRESSION_HPP_ -#define QUICKSTEP_PARSER_PARSE_EXPRESSION_HPP_ - -#include <string> - -#include "parser/ParseTreeNode.hpp" -#include "utility/Macros.hpp" - -namespace quickstep { - -/** \addtogroup Parser - * @{ - */ - -/** - * @brief The parsed representation of an expression. - **/ -class ParseExpression : public ParseTreeNode { - public: - enum ExpressionType { - kAttribute, - kBinaryExpression, - kExtract, - kFunctionCall, - kScalarLiteral, - kSearchedCaseExpression, - kSimpleCaseExpression, - kSubqueryExpression, - kSubstring, - kUnaryExpression, - }; - - /** - * @brief Virtual destructor. - **/ - ~ParseExpression() override { - } - - /** - * @return The expression type. - */ - virtual ExpressionType getExpressionType() const = 0; - - /** - * @brief Get a human-readable representation of this expression. - * - * @return The human-readable form of this expression. - **/ - virtual std::string generateName() const = 0; - - protected: - ParseExpression(const int line_number, const int column_number) - : ParseTreeNode(line_number, column_number) { - } - - private: - DISALLOW_COPY_AND_ASSIGN(ParseExpression); -}; - - -} // namespace quickstep - -#endif /* QUICKSTEP_PARSER_PARSE_EXPRESSION_HPP_ */ http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParseGeneratorTableReference.cpp ---------------------------------------------------------------------- diff --git a/parser/ParseGeneratorTableReference.cpp b/parser/ParseGeneratorTableReference.cpp deleted file mode 100644 index d8f5a48..0000000 --- a/parser/ParseGeneratorTableReference.cpp +++ /dev/null @@ -1,40 +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/ParseGeneratorTableReference.hpp" - -#include <string> -#include <vector> - -namespace quickstep { - -class ParseTreeNode; - -void ParseGeneratorTableReference::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(""); - non_container_child_fields->push_back(generator_function_.get()); -} - -} // namespace quickstep http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParseGeneratorTableReference.hpp ---------------------------------------------------------------------- diff --git a/parser/ParseGeneratorTableReference.hpp b/parser/ParseGeneratorTableReference.hpp deleted file mode 100644 index 4604b87..0000000 --- a/parser/ParseGeneratorTableReference.hpp +++ /dev/null @@ -1,93 +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_GENERATOR_TABLE_REFERENCE_HPP_ -#define QUICKSTEP_PARSER_PARSE_GENERATOR_TABLE_REFERENCE_HPP_ - -#include <memory> -#include <string> -#include <vector> - -#include "parser/ParseBasicExpressions.hpp" -#include "parser/ParseTableReference.hpp" -#include "utility/Macros.hpp" - -namespace quickstep { - -class ParseTreeNode; - -/** \addtogroup Parser - * @{ - */ - -/** - * @brief A table that is generated by a generator function. - */ -class ParseGeneratorTableReference : public ParseTableReference { - public: - /** - * @brief Constructor. Takes ownership of \p generator_function. - * - * @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 generator_function_ The parsed generator function. - */ - ParseGeneratorTableReference(const int line_number, - const int column_number, - ParseFunctionCall *generator_function) - : ParseTableReference(line_number, column_number), - generator_function_(generator_function) { - } - - /** - * @brief Destructor. - */ - ~ParseGeneratorTableReference() override {} - - TableReferenceType getTableReferenceType() const override { - return kGeneratorTableReference; - } - - std::string getName() const override { return "TableGenerator"; } - - /** - * @return The parsed generator function. - */ - const ParseFunctionCall* generator_function() const { return generator_function_.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<ParseFunctionCall> generator_function_; - - DISALLOW_COPY_AND_ASSIGN(ParseGeneratorTableReference); -}; - -/** @} */ - -} // namespace quickstep - -#endif /* QUICKSTEP_PARSER_PARSE_GENERATOR_TABLE_REFERENCE_HPP_ */ http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParseGroupBy.cpp ---------------------------------------------------------------------- diff --git a/parser/ParseGroupBy.cpp b/parser/ParseGroupBy.cpp deleted file mode 100644 index 324a4c6..0000000 --- a/parser/ParseGroupBy.cpp +++ /dev/null @@ -1,41 +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/ParseGroupBy.hpp" - -#include <string> -#include <vector> - -#include "parser/ParseExpression.hpp" - -namespace quickstep { - -void ParseGroupBy::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 { - for (const ParseExpression &group_by_expression : *grouping_expressions_) { - non_container_child_field_names->push_back(""); - non_container_child_fields->push_back(&group_by_expression); - } -} - -} // namespace quickstep http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParseGroupBy.hpp ---------------------------------------------------------------------- diff --git a/parser/ParseGroupBy.hpp b/parser/ParseGroupBy.hpp deleted file mode 100644 index 1e36cd0..0000000 --- a/parser/ParseGroupBy.hpp +++ /dev/null @@ -1,91 +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_GROUP_BY_HPP_ -#define QUICKSTEP_PARSER_PARSE_GROUP_BY_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 { - -/** \addtogroup Parser - * @{ - */ - -/** - * @brief The parsed representaiton of a GROUP BY clause. - */ -class ParseGroupBy : public ParseTreeNode { - public: - /** - * @brief Constructor. - * - * @param line_number The line number of "GROUP" in the SQL statement. - * @param column_number The column number of "GROUP" in the SQL statement. - * @param group_by_expressions The group by expressions. - */ - ParseGroupBy(const int line_number, const int column_number, PtrList<ParseExpression> *grouping_expressions) - : ParseTreeNode(line_number, column_number), - grouping_expressions_(grouping_expressions) { - } - - /** - * @brief Destructor. - */ - ~ParseGroupBy() override {} - - /** - * @brief Gets the GROUP BY expressions. - * - * @return GROUP BY expressions. - */ - const PtrList<ParseExpression>* grouping_expressions() const { - return grouping_expressions_.get(); - } - - std::string getName() const override { - return "GroupBy"; - } - - 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<PtrList<ParseExpression>> grouping_expressions_; - - DISALLOW_COPY_AND_ASSIGN(ParseGroupBy); -}; - -/** @} */ - -} // namespace quickstep - -#endif /* QUICKSTEP_PARSER_PARSEGROUPBY_HPP_ */ http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParseHaving.cpp ---------------------------------------------------------------------- diff --git a/parser/ParseHaving.cpp b/parser/ParseHaving.cpp deleted file mode 100644 index 277f922..0000000 --- a/parser/ParseHaving.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/ParseHaving.hpp" - -#include <string> -#include <vector> - -#include "parser/ParsePredicate.hpp" - -namespace quickstep { - -void ParseHaving::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(""); - non_container_child_fields->push_back(having_predicate_.get()); -} - -} // namespace quickstep http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParseHaving.hpp ---------------------------------------------------------------------- diff --git a/parser/ParseHaving.hpp b/parser/ParseHaving.hpp deleted file mode 100644 index 1059a7a..0000000 --- a/parser/ParseHaving.hpp +++ /dev/null @@ -1,89 +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_HAVING_HPP_ -#define QUICKSTEP_PARSER_PARSE_HAVING_HPP_ - -#include <memory> -#include <string> -#include <vector> - -#include "parser/ParsePredicate.hpp" -#include "parser/ParseTreeNode.hpp" -#include "utility/Macros.hpp" - -namespace quickstep { - -/** \addtogroup Parser - * @{ - */ - -/** - * @brief The parsed representation of HAVING. - */ -class ParseHaving : public ParseTreeNode { - public: - /** - * @brief Constructor. - * - * @param line_number The line number of "HAVING" in the SQL statement. - * @param column_number The column number of "HAVING" in the SQL statement. - * @param having_predicate The HAVING predicate. - */ - ParseHaving(const int line_number, const int column_number, ParsePredicate *having_predicate) - : ParseTreeNode(line_number, column_number), having_predicate_(having_predicate) { - } - - /** - * @brief Destructor. - */ - ~ParseHaving() override {} - - /** - * @brief Gets the HAVING predicate. - * - * @return HAVING predicate - */ - const ParsePredicate *having_predicate() const { - return having_predicate_.get(); - } - - std::string getName() const override { - return "HAVING"; - } - - 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> having_predicate_; - - DISALLOW_COPY_AND_ASSIGN(ParseHaving); -}; - -/** @} */ - -} // namespace quickstep - -#endif /* QUICKSTEP_PARSER_PARSEHAVING_HPP_ */ http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/156290a4/parser/ParseIndexProperties.cpp ---------------------------------------------------------------------- diff --git a/parser/ParseIndexProperties.cpp b/parser/ParseIndexProperties.cpp deleted file mode 100644 index 8268b5c..0000000 --- a/parser/ParseIndexProperties.cpp +++ /dev/null @@ -1,29 +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/ParseIndexProperties.hpp" - -namespace quickstep { - // Initialize constants for various index properties. - const char *BitWeavingIndexProperties::kBitWeavingType = "type"; - const char *BloomFilterIndexProperties::kBloomFilterSizeInBytes = "size"; - const char *BloomFilterIndexProperties::kBloomFilterNumHashes = "num_hashes"; - const char *BloomFilterIndexProperties::kBloomFilterProjectElementCount = "projected_element_count"; - -} // namespace quickstep