Adds support for IN predicate (#167) Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/0fd8c039 Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/0fd8c039 Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/0fd8c039
Branch: refs/heads/master Commit: 0fd8c039ac45269dca65caa5970e41040310762b Parents: ff20277 Author: Jianqiao Zhu <[email protected]> Authored: Fri Apr 15 14:20:47 2016 -0500 Committer: Zuyu ZHANG <[email protected]> Committed: Fri Apr 15 14:20:47 2016 -0500 ---------------------------------------------------------------------- parser/CMakeLists.txt | 10 + parser/ParsePredicate.cpp | 19 + parser/ParsePredicate.hpp | 66 +- parser/ParsePredicateInTableQuery.hpp | 110 + parser/SqlLexer.lpp | 1 + parser/SqlParser.ypp | 24 +- parser/preprocessed/SqlLexer_gen.cpp | 375 +-- parser/preprocessed/SqlLexer_gen.hpp | 2 +- parser/preprocessed/SqlParser_gen.cpp | 2700 +++++++++--------- parser/preprocessed/SqlParser_gen.hpp | 111 +- parser/tests/Select.test | 130 + parser/tests/TPCH.test | 403 ++- query_optimizer/expressions/CMakeLists.txt | 29 + query_optimizer/expressions/ExpressionType.hpp | 2 + query_optimizer/expressions/InTableQuery.cpp | 53 + query_optimizer/expressions/InTableQuery.hpp | 143 + query_optimizer/expressions/InValueList.cpp | 72 + query_optimizer/expressions/InValueList.hpp | 157 + query_optimizer/expressions/PatternMatcher.hpp | 6 + query_optimizer/resolver/CMakeLists.txt | 5 + query_optimizer/resolver/Resolver.cpp | 84 +- query_optimizer/resolver/Resolver.hpp | 5 +- query_optimizer/rules/CMakeLists.txt | 2 + query_optimizer/rules/UnnestSubqueries.cpp | 59 + query_optimizer/rules/UnnestSubqueries.hpp | 15 + .../tests/execution_generator/Select.test | 56 + .../tests/logical_generator/Select.test | 176 ++ .../tests/physical_generator/Select.test | 311 ++ query_optimizer/tests/resolver/Select.test | 194 ++ 29 files changed, 3727 insertions(+), 1593 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/parser/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/parser/CMakeLists.txt b/parser/CMakeLists.txt index 8206caf..8f4bae9 100644 --- a/parser/CMakeLists.txt +++ b/parser/CMakeLists.txt @@ -1,5 +1,7 @@ # Copyright 2011-2015 Quickstep Technologies LLC. # Copyright 2015 Pivotal Software, Inc. +# Copyright 2016, Quickstep Research Group, Computer Sciences Department, +# University of WisconsinâMadison. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -99,6 +101,7 @@ add_library(quickstep_parser_ParseOrderBy ParseOrderBy.cpp ParseOrderBy.hpp) add_library(quickstep_parser_ParsePartitionClause ../empty_src.cpp ParsePartitionClause.hpp) add_library(quickstep_parser_ParsePredicate ParsePredicate.cpp ParsePredicate.hpp) add_library(quickstep_parser_ParsePredicateExists ../empty_src.cpp ParsePredicateExists.hpp) +add_library(quickstep_parser_ParsePredicateInTableQuery ../empty_src.cpp ParsePredicateInTableQuery.hpp) add_library(quickstep_parser_ParseSample ParseSample.cpp ParseSample.hpp) add_library(quickstep_parser_ParseSelect ../empty_src.cpp ParseSelect.hpp) add_library(quickstep_parser_ParseSelectionClause ParseSelectionClause.cpp ParseSelectionClause.hpp) @@ -213,6 +216,11 @@ target_link_libraries(quickstep_parser_ParsePredicateExists quickstep_parser_ParsePredicate quickstep_parser_ParseSubqueryExpression quickstep_utility_Macros) +target_link_libraries(quickstep_parser_ParsePredicateInTableQuery + quickstep_parser_ParseExpression + quickstep_parser_ParsePredicate + quickstep_parser_ParseSubqueryExpression + quickstep_utility_Macros) target_link_libraries(quickstep_parser_ParseSample quickstep_parser_ParseLiteralValue quickstep_parser_ParseTreeNode @@ -311,6 +319,7 @@ target_link_libraries(quickstep_parser_SqlParser quickstep_parser_ParsePartitionClause quickstep_parser_ParsePredicate quickstep_parser_ParsePredicateExists + quickstep_parser_ParsePredicateInTableQuery quickstep_parser_ParseSample quickstep_parser_ParseSelect quickstep_parser_ParseSelectionClause @@ -384,6 +393,7 @@ target_link_libraries(quickstep_parser quickstep_parser_ParsePartitionClause quickstep_parser_ParsePredicate quickstep_parser_ParsePredicateExists + quickstep_parser_ParsePredicateInTableQuery quickstep_parser_ParserUtil quickstep_parser_ParseSample quickstep_parser_ParseSelect http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/parser/ParsePredicate.cpp ---------------------------------------------------------------------- diff --git a/parser/ParsePredicate.cpp b/parser/ParsePredicate.cpp index d7db285..ad786b5 100644 --- a/parser/ParsePredicate.cpp +++ b/parser/ParsePredicate.cpp @@ -1,6 +1,8 @@ /** * Copyright 2011-2015 Quickstep Technologies LLC. * Copyright 2015 Pivotal Software, Inc. + * Copyright 2016, Quickstep Research Group, Computer Sciences Department, + * University of WisconsinâMadison. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -84,4 +86,21 @@ void ParsePredicateWithList::getFieldStringItems( } } +void ParsePredicateInValueList::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("test_expression"); + non_container_child_fields->push_back(test_expression_.get()); + + container_child_field_names->push_back("value_list"); + container_child_fields->emplace_back(); + for (const ParseExpression &value : *value_list_) { + container_child_fields->back().emplace_back(&value); + } +} + } // namespace quickstep http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/parser/ParsePredicate.hpp ---------------------------------------------------------------------- diff --git a/parser/ParsePredicate.hpp b/parser/ParsePredicate.hpp index 2f8d08b..2d65142 100644 --- a/parser/ParsePredicate.hpp +++ b/parser/ParsePredicate.hpp @@ -1,6 +1,8 @@ /** * Copyright 2011-2015 Quickstep Technologies LLC. * Copyright 2015 Pivotal Software, Inc. + * Copyright 2016, Quickstep Research Group, Computer Sciences Department, + * University of WisconsinâMadison. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -49,7 +51,9 @@ class ParsePredicate : public ParseTreeNode { kNegation, kConjunction, kDisjunction, - kExists + kExists, + kInTableQuery, + kInValueList }; /** @@ -382,6 +386,66 @@ class ParsePredicateDisjunction : public ParsePredicateWithList { 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 http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/parser/ParsePredicateInTableQuery.hpp ---------------------------------------------------------------------- diff --git a/parser/ParsePredicateInTableQuery.hpp b/parser/ParsePredicateInTableQuery.hpp new file mode 100644 index 0000000..423ec3a --- /dev/null +++ b/parser/ParsePredicateInTableQuery.hpp @@ -0,0 +1,110 @@ +/** + * Copyright 2016, Quickstep Research Group, Computer Sciences Department, + * University of WisconsinâMadison. + * + * Licensed 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/0fd8c039/parser/SqlLexer.lpp ---------------------------------------------------------------------- diff --git a/parser/SqlLexer.lpp b/parser/SqlLexer.lpp index 0c9e646..4ee50ec 100644 --- a/parser/SqlLexer.lpp +++ b/parser/SqlLexer.lpp @@ -212,6 +212,7 @@ unsigned_numeric_literal {exact_numeric_literal}|{approximate_numeric_literal} "group" return TOKEN_GROUP; "hash" return TOKEN_HASH; "having" return TOKEN_HAVING; + "in" return TOKEN_IN; "index" return TOKEN_INDEX; "inner" return TOKEN_INNER; "insert" return TOKEN_INSERT; http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/parser/SqlParser.ypp ---------------------------------------------------------------------- diff --git a/parser/SqlParser.ypp b/parser/SqlParser.ypp index c6ff7db..70db649 100644 --- a/parser/SqlParser.ypp +++ b/parser/SqlParser.ypp @@ -83,6 +83,7 @@ typedef struct YYLTYPE { #include "parser/ParsePartitionClause.hpp" #include "parser/ParsePredicate.hpp" #include "parser/ParsePredicateExists.hpp" +#include "parser/ParsePredicateInTableQuery.hpp" #include "parser/ParserUtil.hpp" #include "parser/ParseSample.hpp" #include "parser/ParseSelect.hpp" @@ -273,6 +274,7 @@ void NotSupported(const YYLTYPE *location, yyscan_t yyscanner, const std::string %token TOKEN_GROUP; %token TOKEN_HASH; %token TOKEN_HAVING; +%token TOKEN_IN; %token TOKEN_INDEX; %token TOKEN_INNER; %token TOKEN_INSERT; @@ -1458,9 +1460,25 @@ predicate_expression_base: $$ = $2; } | TOKEN_EXISTS subquery_expression { - $$ = new quickstep::ParsePredicateExists(@1.first_line, - @1.first_column, - $2); + $$ = new quickstep::ParsePredicateExists(@1.first_line, @1.first_column, $2); + } + | add_expression TOKEN_IN subquery_expression { + $$ = new quickstep::ParsePredicateInTableQuery(@2.first_line, @2.first_column, $1, $3); + } + | add_expression TOKEN_IN '(' expression_list ')' { + $$ = new quickstep::ParsePredicateInValueList(@2.first_line, @2.first_column, $1, $4); + } + | add_expression TOKEN_NOT TOKEN_IN subquery_expression { + $$ = new quickstep::ParsePredicateNegation( + @2.first_line, + @2.first_column, + new quickstep::ParsePredicateInTableQuery(@3.first_line, @3.first_column, $1, $4)); + } + | add_expression TOKEN_NOT TOKEN_IN '(' expression_list ')' { + $$ = new quickstep::ParsePredicateNegation( + @2.first_line, + @2.first_column, + new quickstep::ParsePredicateInValueList(@3.first_line, @3.first_column, $1, $5)); }; /* Scalars */ http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/parser/preprocessed/SqlLexer_gen.cpp ---------------------------------------------------------------------- diff --git a/parser/preprocessed/SqlLexer_gen.cpp b/parser/preprocessed/SqlLexer_gen.cpp index 878ac58..4175e20 100644 --- a/parser/preprocessed/SqlLexer_gen.cpp +++ b/parser/preprocessed/SqlLexer_gen.cpp @@ -381,8 +381,8 @@ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner ); *yy_cp = '\0'; \ yyg->yy_c_buf_p = yy_cp; -#define YY_NUM_RULES 142 -#define YY_END_OF_BUFFER 143 +#define YY_NUM_RULES 143 +#define YY_END_OF_BUFFER 144 /* This struct is not used in this scanner, but its presence is necessary. */ struct yy_trans_info @@ -393,62 +393,62 @@ struct yy_trans_info static yyconst flex_int16_t yy_accept[520] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 143, 2, 2, 141, 141, 140, 139, 141, - 118, 114, 117, 114, 114, 137, 110, 107, 111, 136, - 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, - 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, - 136, 136, 136, 115, 4, 5, 5, 3, 133, 133, - 130, 134, 134, 128, 135, 135, 132, 1, 140, 108, - 138, 137, 137, 137, 0, 112, 109, 113, 136, 136, - 136, 136, 10, 136, 136, 136, 21, 136, 136, 136, - 136, 136, 136, 136, 136, 136, 136, 116, 136, 136, - - 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, - 136, 61, 136, 136, 136, 136, 136, 136, 136, 136, - 136, 73, 74, 136, 136, 136, 136, 136, 136, 136, - 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, - 136, 136, 136, 136, 136, 136, 4, 5, 3, 133, - 129, 134, 127, 127, 119, 121, 122, 123, 124, 125, - 126, 127, 135, 131, 138, 137, 0, 137, 6, 7, - 136, 9, 11, 136, 136, 15, 136, 136, 136, 136, - 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, - 136, 136, 136, 136, 41, 136, 136, 136, 136, 136, - - 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, - 57, 136, 63, 136, 136, 136, 136, 136, 69, 136, - 72, 136, 136, 136, 136, 136, 136, 136, 136, 136, - 136, 136, 136, 136, 89, 90, 136, 136, 136, 136, - 136, 136, 136, 136, 136, 136, 136, 136, 136, 119, - 121, 120, 136, 136, 136, 136, 136, 136, 19, 22, - 136, 136, 136, 27, 136, 136, 29, 136, 136, 136, - 136, 35, 136, 136, 39, 40, 136, 136, 136, 136, - 136, 136, 136, 49, 50, 136, 52, 136, 136, 136, - 136, 136, 60, 62, 64, 65, 66, 136, 68, 70, - - 136, 136, 136, 136, 136, 81, 136, 83, 136, 136, - 136, 136, 136, 136, 136, 93, 94, 96, 136, 136, - 136, 136, 136, 136, 103, 136, 105, 136, 119, 120, - 8, 136, 136, 136, 136, 136, 136, 24, 136, 136, - 136, 136, 136, 136, 136, 136, 136, 136, 136, 136, - 136, 136, 136, 45, 46, 47, 136, 51, 136, 54, - 55, 136, 136, 136, 67, 71, 75, 76, 136, 136, - 136, 82, 136, 136, 86, 136, 136, 136, 92, 136, - 136, 136, 136, 100, 136, 136, 104, 136, 136, 136, - 14, 136, 136, 136, 136, 25, 136, 28, 136, 136, - - 136, 136, 33, 136, 136, 136, 38, 136, 43, 136, - 136, 53, 56, 136, 136, 136, 136, 136, 136, 85, - 136, 88, 136, 136, 136, 98, 99, 101, 136, 136, - 136, 13, 136, 136, 136, 136, 136, 20, 136, 31, - 32, 136, 136, 136, 136, 44, 48, 58, 136, 136, - 79, 80, 136, 136, 136, 136, 136, 102, 136, 136, - 136, 136, 136, 136, 136, 30, 136, 136, 37, 136, - 59, 136, 136, 136, 91, 136, 136, 136, 12, 136, - 136, 136, 23, 136, 34, 136, 136, 77, 136, 136, - 95, 136, 106, 136, 136, 136, 26, 36, 136, 78, - - 84, 136, 136, 136, 17, 18, 136, 136, 97, 136, - 136, 136, 136, 136, 87, 136, 42, 16, 0 + 0, 0, 144, 2, 2, 142, 142, 141, 140, 142, + 119, 115, 118, 115, 115, 138, 111, 108, 112, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 116, 4, 5, 5, 3, 134, 134, + 131, 135, 135, 129, 136, 136, 133, 1, 141, 109, + 139, 138, 138, 138, 0, 113, 110, 114, 137, 137, + 137, 137, 10, 137, 137, 137, 21, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 117, 137, 137, + + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 54, 62, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 74, 75, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 4, 5, 3, 134, + 130, 135, 128, 128, 120, 122, 123, 124, 125, 126, + 127, 128, 136, 132, 139, 138, 0, 138, 6, 7, + 137, 9, 11, 137, 137, 15, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 41, 137, 137, 137, 137, 137, + + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 58, 137, 64, 137, 137, 137, 137, 137, 70, 137, + 73, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 137, 90, 91, 137, 137, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 120, + 122, 121, 137, 137, 137, 137, 137, 137, 19, 22, + 137, 137, 137, 27, 137, 137, 29, 137, 137, 137, + 137, 35, 137, 137, 39, 40, 137, 137, 137, 137, + 137, 137, 137, 49, 50, 137, 52, 137, 137, 137, + 137, 137, 61, 63, 65, 66, 67, 137, 69, 71, + + 137, 137, 137, 137, 137, 82, 137, 84, 137, 137, + 137, 137, 137, 137, 137, 94, 95, 97, 137, 137, + 137, 137, 137, 137, 104, 137, 106, 137, 120, 121, + 8, 137, 137, 137, 137, 137, 137, 24, 137, 137, + 137, 137, 137, 137, 137, 137, 137, 137, 137, 137, + 137, 137, 137, 45, 46, 47, 137, 51, 137, 55, + 56, 137, 137, 137, 68, 72, 76, 77, 137, 137, + 137, 83, 137, 137, 87, 137, 137, 137, 93, 137, + 137, 137, 137, 101, 137, 137, 105, 137, 137, 137, + 14, 137, 137, 137, 137, 25, 137, 28, 137, 137, + + 137, 137, 33, 137, 137, 137, 38, 137, 43, 137, + 137, 53, 57, 137, 137, 137, 137, 137, 137, 86, + 137, 89, 137, 137, 137, 99, 100, 102, 137, 137, + 137, 13, 137, 137, 137, 137, 137, 20, 137, 31, + 32, 137, 137, 137, 137, 44, 48, 59, 137, 137, + 80, 81, 137, 137, 137, 137, 137, 103, 137, 137, + 137, 137, 137, 137, 137, 30, 137, 137, 37, 137, + 60, 137, 137, 137, 92, 137, 137, 137, 12, 137, + 137, 137, 23, 137, 34, 137, 137, 78, 137, 137, + 96, 137, 107, 137, 137, 137, 26, 36, 137, 79, + + 85, 137, 137, 137, 17, 18, 137, 137, 98, 137, + 137, 137, 137, 137, 88, 137, 42, 16, 0 } ; static yyconst YY_CHAR yy_ec[256] = @@ -900,7 +900,7 @@ static yyconst flex_int16_t yy_chk[1229] = } ; /* Table of booleans, true if rule could match eol. */ -static yyconst flex_int32_t yy_rule_can_match_eol[143] = +static yyconst flex_int32_t yy_rule_can_match_eol[144] = { 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, @@ -908,8 +908,8 @@ static yyconst flex_int32_t yy_rule_can_match_eol[143] = 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 1, - 0, 0, 0, }; + 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, + 1, 0, 0, 0, }; /* The intent behind this definition is that it'll catch * any uses of REJECT which flex missed. @@ -1678,22 +1678,22 @@ return TOKEN_HAVING; case 54: YY_RULE_SETUP #line 215 "../SqlLexer.lpp" -return TOKEN_INDEX; +return TOKEN_IN; YY_BREAK case 55: YY_RULE_SETUP #line 216 "../SqlLexer.lpp" -return TOKEN_INNER; +return TOKEN_INDEX; YY_BREAK case 56: YY_RULE_SETUP #line 217 "../SqlLexer.lpp" -return TOKEN_INSERT; +return TOKEN_INNER; YY_BREAK case 57: YY_RULE_SETUP #line 218 "../SqlLexer.lpp" -return TOKEN_INTEGER; +return TOKEN_INSERT; YY_BREAK case 58: YY_RULE_SETUP @@ -1703,252 +1703,252 @@ return TOKEN_INTEGER; case 59: YY_RULE_SETUP #line 220 "../SqlLexer.lpp" -return TOKEN_INTERVAL; +return TOKEN_INTEGER; YY_BREAK case 60: YY_RULE_SETUP #line 221 "../SqlLexer.lpp" -return TOKEN_INTO; +return TOKEN_INTERVAL; YY_BREAK case 61: YY_RULE_SETUP #line 222 "../SqlLexer.lpp" -return TOKEN_IS; +return TOKEN_INTO; YY_BREAK case 62: YY_RULE_SETUP #line 223 "../SqlLexer.lpp" -return TOKEN_JOIN; +return TOKEN_IS; YY_BREAK case 63: YY_RULE_SETUP #line 224 "../SqlLexer.lpp" -return TOKEN_KEY; +return TOKEN_JOIN; YY_BREAK case 64: YY_RULE_SETUP #line 225 "../SqlLexer.lpp" -return TOKEN_LAST; +return TOKEN_KEY; YY_BREAK case 65: YY_RULE_SETUP #line 226 "../SqlLexer.lpp" -return TOKEN_LEFT; +return TOKEN_LAST; YY_BREAK case 66: YY_RULE_SETUP #line 227 "../SqlLexer.lpp" -return TOKEN_LIKE; +return TOKEN_LEFT; YY_BREAK case 67: YY_RULE_SETUP #line 228 "../SqlLexer.lpp" -return TOKEN_LIMIT; +return TOKEN_LIKE; YY_BREAK case 68: YY_RULE_SETUP #line 229 "../SqlLexer.lpp" -return TOKEN_LONG; +return TOKEN_LIMIT; YY_BREAK case 69: YY_RULE_SETUP #line 230 "../SqlLexer.lpp" -return TOKEN_NOT; +return TOKEN_LONG; YY_BREAK case 70: YY_RULE_SETUP #line 231 "../SqlLexer.lpp" -return TOKEN_NULL; +return TOKEN_NOT; YY_BREAK case 71: YY_RULE_SETUP #line 232 "../SqlLexer.lpp" -return TOKEN_NULLS; +return TOKEN_NULL; YY_BREAK case 72: YY_RULE_SETUP #line 233 "../SqlLexer.lpp" -return TOKEN_OFF; +return TOKEN_NULLS; YY_BREAK case 73: YY_RULE_SETUP #line 234 "../SqlLexer.lpp" -return TOKEN_ON; +return TOKEN_OFF; YY_BREAK case 74: YY_RULE_SETUP #line 235 "../SqlLexer.lpp" -return TOKEN_OR; +return TOKEN_ON; YY_BREAK case 75: YY_RULE_SETUP #line 236 "../SqlLexer.lpp" -return TOKEN_ORDER; +return TOKEN_OR; YY_BREAK case 76: YY_RULE_SETUP #line 237 "../SqlLexer.lpp" -return TOKEN_OUTER; +return TOKEN_ORDER; YY_BREAK case 77: YY_RULE_SETUP #line 238 "../SqlLexer.lpp" -return TOKEN_PARTITION; +return TOKEN_OUTER; YY_BREAK case 78: YY_RULE_SETUP #line 239 "../SqlLexer.lpp" -return TOKEN_PARTITIONS; +return TOKEN_PARTITION; YY_BREAK case 79: YY_RULE_SETUP #line 240 "../SqlLexer.lpp" -return TOKEN_PERCENT; +return TOKEN_PARTITIONS; YY_BREAK case 80: YY_RULE_SETUP #line 241 "../SqlLexer.lpp" -return TOKEN_PRIMARY; +return TOKEN_PERCENT; YY_BREAK case 81: YY_RULE_SETUP #line 242 "../SqlLexer.lpp" -return TOKEN_QUIT; +return TOKEN_PRIMARY; YY_BREAK case 82: YY_RULE_SETUP #line 243 "../SqlLexer.lpp" -return TOKEN_RANGE; +return TOKEN_QUIT; YY_BREAK case 83: YY_RULE_SETUP #line 244 "../SqlLexer.lpp" -return TOKEN_REAL; +return TOKEN_RANGE; YY_BREAK case 84: YY_RULE_SETUP #line 245 "../SqlLexer.lpp" -return TOKEN_REFERENCES; +return TOKEN_REAL; YY_BREAK case 85: YY_RULE_SETUP #line 246 "../SqlLexer.lpp" -return TOKEN_REGEXP; +return TOKEN_REFERENCES; YY_BREAK case 86: YY_RULE_SETUP #line 247 "../SqlLexer.lpp" -return TOKEN_RIGHT; +return TOKEN_REGEXP; YY_BREAK case 87: YY_RULE_SETUP #line 248 "../SqlLexer.lpp" -return TOKEN_ROW_DELIMITER; +return TOKEN_RIGHT; YY_BREAK case 88: YY_RULE_SETUP #line 249 "../SqlLexer.lpp" -return TOKEN_SELECT; +return TOKEN_ROW_DELIMITER; YY_BREAK case 89: YY_RULE_SETUP #line 250 "../SqlLexer.lpp" -return TOKEN_SET; +return TOKEN_SELECT; YY_BREAK case 90: YY_RULE_SETUP #line 251 "../SqlLexer.lpp" -return TOKEN_SMA; +return TOKEN_SET; YY_BREAK case 91: YY_RULE_SETUP #line 252 "../SqlLexer.lpp" -return TOKEN_SMALLINT; +return TOKEN_SMA; YY_BREAK case 92: YY_RULE_SETUP #line 253 "../SqlLexer.lpp" -return TOKEN_TABLE; +return TOKEN_SMALLINT; YY_BREAK case 93: YY_RULE_SETUP #line 254 "../SqlLexer.lpp" -return TOKEN_THEN; +return TOKEN_TABLE; YY_BREAK case 94: YY_RULE_SETUP #line 255 "../SqlLexer.lpp" -return TOKEN_TIME; +return TOKEN_THEN; YY_BREAK case 95: YY_RULE_SETUP #line 256 "../SqlLexer.lpp" -return TOKEN_TIMESTAMP; +return TOKEN_TIME; YY_BREAK case 96: YY_RULE_SETUP #line 257 "../SqlLexer.lpp" -return TOKEN_TRUE; +return TOKEN_TIMESTAMP; YY_BREAK case 97: YY_RULE_SETUP #line 258 "../SqlLexer.lpp" -return TOKEN_TUPLESAMPLE; +return TOKEN_TRUE; YY_BREAK case 98: YY_RULE_SETUP #line 259 "../SqlLexer.lpp" -return TOKEN_UNIQUE; +return TOKEN_TUPLESAMPLE; YY_BREAK case 99: YY_RULE_SETUP #line 260 "../SqlLexer.lpp" -return TOKEN_UPDATE; +return TOKEN_UNIQUE; YY_BREAK case 100: YY_RULE_SETUP #line 261 "../SqlLexer.lpp" -return TOKEN_USING; +return TOKEN_UPDATE; YY_BREAK case 101: YY_RULE_SETUP #line 262 "../SqlLexer.lpp" -return TOKEN_VALUES; +return TOKEN_USING; YY_BREAK case 102: YY_RULE_SETUP #line 263 "../SqlLexer.lpp" -return TOKEN_VARCHAR; +return TOKEN_VALUES; YY_BREAK case 103: YY_RULE_SETUP #line 264 "../SqlLexer.lpp" -return TOKEN_WHEN; +return TOKEN_VARCHAR; YY_BREAK case 104: YY_RULE_SETUP #line 265 "../SqlLexer.lpp" -return TOKEN_WHERE; +return TOKEN_WHEN; YY_BREAK case 105: YY_RULE_SETUP #line 266 "../SqlLexer.lpp" -return TOKEN_WITH; +return TOKEN_WHERE; YY_BREAK case 106: YY_RULE_SETUP #line 267 "../SqlLexer.lpp" -return TOKEN_YEARMONTH; +return TOKEN_WITH; YY_BREAK case 107: YY_RULE_SETUP -#line 269 "../SqlLexer.lpp" -return TOKEN_EQ; +#line 268 "../SqlLexer.lpp" +return TOKEN_YEARMONTH; YY_BREAK case 108: YY_RULE_SETUP #line 270 "../SqlLexer.lpp" -return TOKEN_NEQ; +return TOKEN_EQ; YY_BREAK case 109: YY_RULE_SETUP @@ -1958,56 +1958,61 @@ return TOKEN_NEQ; case 110: YY_RULE_SETUP #line 272 "../SqlLexer.lpp" -return TOKEN_LT; +return TOKEN_NEQ; YY_BREAK case 111: YY_RULE_SETUP #line 273 "../SqlLexer.lpp" -return TOKEN_GT; +return TOKEN_LT; YY_BREAK case 112: YY_RULE_SETUP #line 274 "../SqlLexer.lpp" -return TOKEN_LEQ; +return TOKEN_GT; YY_BREAK case 113: YY_RULE_SETUP #line 275 "../SqlLexer.lpp" -return TOKEN_GEQ; +return TOKEN_LEQ; YY_BREAK case 114: YY_RULE_SETUP -#line 277 "../SqlLexer.lpp" -return yytext[0]; +#line 276 "../SqlLexer.lpp" +return TOKEN_GEQ; YY_BREAK case 115: YY_RULE_SETUP #line 278 "../SqlLexer.lpp" return yytext[0]; YY_BREAK +case 116: +YY_RULE_SETUP +#line 279 "../SqlLexer.lpp" +return yytext[0]; + YY_BREAK /** * Quoted strings. Prefacing a string with an 'e' or 'E' causes escape * sequences to be processed (as in PostgreSQL). **/ -case 116: +case 117: YY_RULE_SETUP -#line 284 "../SqlLexer.lpp" +#line 285 "../SqlLexer.lpp" { yylval->string_value_ = new quickstep::ParseString(yylloc->first_line, yylloc->first_column); BEGIN(CONDITION_STRING_SINGLE_QUOTED_ESCAPED); } YY_BREAK -case 117: +case 118: YY_RULE_SETUP -#line 289 "../SqlLexer.lpp" +#line 290 "../SqlLexer.lpp" { yylval->string_value_ = new quickstep::ParseString(yylloc->first_line, yylloc->first_column); BEGIN(CONDITION_STRING_SINGLE_QUOTED); } YY_BREAK -case 118: +case 119: YY_RULE_SETUP -#line 294 "../SqlLexer.lpp" +#line 295 "../SqlLexer.lpp" { yylval->string_value_ = new quickstep::ParseString(yylloc->first_line, yylloc->first_column); BEGIN(CONDITION_STRING_DOUBLE_QUOTED); @@ -2019,7 +2024,7 @@ YY_RULE_SETUP case YY_STATE_EOF(CONDITION_STRING_SINGLE_QUOTED): case YY_STATE_EOF(CONDITION_STRING_SINGLE_QUOTED_ESCAPED): case YY_STATE_EOF(CONDITION_STRING_DOUBLE_QUOTED): -#line 303 "../SqlLexer.lpp" +#line 304 "../SqlLexer.lpp" { delete yylval->string_value_; BEGIN(INITIAL); @@ -2030,9 +2035,9 @@ case YY_STATE_EOF(CONDITION_STRING_DOUBLE_QUOTED): /* Process escape sequences. */ -case 119: +case 120: YY_RULE_SETUP -#line 313 "../SqlLexer.lpp" +#line 314 "../SqlLexer.lpp" { /* Octal code */ unsigned int code; @@ -2046,9 +2051,9 @@ YY_RULE_SETUP yylval->string_value_->push_back(code); } YY_BREAK -case 120: +case 121: YY_RULE_SETUP -#line 325 "../SqlLexer.lpp" +#line 326 "../SqlLexer.lpp" { /* Hexadecimal code */ unsigned int code; @@ -2056,9 +2061,9 @@ YY_RULE_SETUP yylval->string_value_->push_back(code); } YY_BREAK -case 121: +case 122: YY_RULE_SETUP -#line 331 "../SqlLexer.lpp" +#line 332 "../SqlLexer.lpp" { /* A numeric escape sequence that isn't correctly specified. */ delete yylval->string_value_; @@ -2067,58 +2072,58 @@ YY_RULE_SETUP return TOKEN_LEX_ERROR; } YY_BREAK -case 122: +case 123: YY_RULE_SETUP -#line 338 "../SqlLexer.lpp" +#line 339 "../SqlLexer.lpp" { /* Backspace */ yylval->string_value_->push_back('\b'); } YY_BREAK -case 123: +case 124: YY_RULE_SETUP -#line 342 "../SqlLexer.lpp" +#line 343 "../SqlLexer.lpp" { /* Form-feed */ yylval->string_value_->push_back('\f'); } YY_BREAK -case 124: +case 125: YY_RULE_SETUP -#line 346 "../SqlLexer.lpp" +#line 347 "../SqlLexer.lpp" { /* Newline */ yylval->string_value_->push_back('\n'); } YY_BREAK -case 125: +case 126: YY_RULE_SETUP -#line 350 "../SqlLexer.lpp" +#line 351 "../SqlLexer.lpp" { /* Carriage-return */ yylval->string_value_->push_back('\r'); } YY_BREAK -case 126: +case 127: YY_RULE_SETUP -#line 354 "../SqlLexer.lpp" +#line 355 "../SqlLexer.lpp" { /* Horizontal Tab */ yylval->string_value_->push_back('\t'); } YY_BREAK -case 127: -/* rule 127 can match eol */ +case 128: +/* rule 128 can match eol */ YY_RULE_SETUP -#line 358 "../SqlLexer.lpp" +#line 359 "../SqlLexer.lpp" { /* Any other character (including actual newline or carriage return) */ yylval->string_value_->push_back(yytext[1]); } YY_BREAK -case 128: +case 129: YY_RULE_SETUP -#line 362 "../SqlLexer.lpp" +#line 363 "../SqlLexer.lpp" { /* This should only be encountered right before an EOF. */ delete yylval->string_value_; @@ -2129,17 +2134,17 @@ YY_RULE_SETUP YY_BREAK -case 129: +case 130: YY_RULE_SETUP -#line 372 "../SqlLexer.lpp" +#line 373 "../SqlLexer.lpp" { /* Two quotes in a row become a single quote (this is specified by the SQL standard). */ yylval->string_value_->push_back('\''); } YY_BREAK -case 130: +case 131: YY_RULE_SETUP -#line 376 "../SqlLexer.lpp" +#line 377 "../SqlLexer.lpp" { /* End string */ BEGIN(CONDITION_SQL); @@ -2148,17 +2153,17 @@ YY_RULE_SETUP YY_BREAK -case 131: +case 132: YY_RULE_SETUP -#line 384 "../SqlLexer.lpp" +#line 385 "../SqlLexer.lpp" { /* Two quotes in a row become a single quote (this is specified by the SQL standard). */ yylval->string_value_->push_back('"'); } YY_BREAK -case 132: +case 133: YY_RULE_SETUP -#line 388 "../SqlLexer.lpp" +#line 389 "../SqlLexer.lpp" { /* End string */ BEGIN(CONDITION_SQL); @@ -2166,94 +2171,94 @@ YY_RULE_SETUP } YY_BREAK -case 133: -/* rule 133 can match eol */ +case 134: +/* rule 134 can match eol */ YY_RULE_SETUP -#line 395 "../SqlLexer.lpp" +#line 396 "../SqlLexer.lpp" { /* Scan up to a quote. */ yylval->string_value_->append(yytext, yyleng); } YY_BREAK -case 134: -/* rule 134 can match eol */ +case 135: +/* rule 135 can match eol */ YY_RULE_SETUP -#line 400 "../SqlLexer.lpp" +#line 401 "../SqlLexer.lpp" { /* Scan up to a quote or escape sequence. */ yylval->string_value_->append(yytext, yyleng); } YY_BREAK -case 135: -/* rule 135 can match eol */ +case 136: +/* rule 136 can match eol */ YY_RULE_SETUP -#line 405 "../SqlLexer.lpp" +#line 406 "../SqlLexer.lpp" { /* Scan up to a quote. */ yylval->string_value_->append(yytext, yyleng); } YY_BREAK -case 136: +case 137: YY_RULE_SETUP -#line 411 "../SqlLexer.lpp" +#line 412 "../SqlLexer.lpp" { yylval->string_value_ = new quickstep::ParseString( yylloc->first_line, yylloc->first_column, std::string(yytext, yyleng)); return TOKEN_NAME; } YY_BREAK -case 137: +case 138: YY_RULE_SETUP -#line 417 "../SqlLexer.lpp" +#line 418 "../SqlLexer.lpp" { yylval->numeric_literal_value_ = new quickstep::NumericParseLiteralValue( yylloc->first_line, yylloc->first_column, yytext); return TOKEN_UNSIGNED_NUMVAL; } YY_BREAK -case 138: +case 139: YY_RULE_SETUP -#line 423 "../SqlLexer.lpp" +#line 424 "../SqlLexer.lpp" /* comment */ YY_BREAK -case 139: -/* rule 139 can match eol */ +case 140: +/* rule 140 can match eol */ YY_RULE_SETUP -#line 425 "../SqlLexer.lpp" +#line 426 "../SqlLexer.lpp" { yycolumn = 0; } YY_BREAK -case 140: +case 141: YY_RULE_SETUP -#line 427 "../SqlLexer.lpp" +#line 428 "../SqlLexer.lpp" ; /* ignore white space */ YY_BREAK /* CONDITION_SQL */ case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(CONDITION_COMMAND): case YY_STATE_EOF(CONDITION_SQL): -#line 431 "../SqlLexer.lpp" +#line 432 "../SqlLexer.lpp" { /* All conditions except for mutli-state string extracting conditions. */ BEGIN(INITIAL); return TOKEN_EOF; } YY_BREAK -case 141: +case 142: YY_RULE_SETUP -#line 437 "../SqlLexer.lpp" +#line 438 "../SqlLexer.lpp" { BEGIN(INITIAL); quickstep_yyerror(NULL, yyscanner, NULL, "illegal character"); return TOKEN_LEX_ERROR; } YY_BREAK -case 142: +case 143: YY_RULE_SETUP -#line 443 "../SqlLexer.lpp" +#line 444 "../SqlLexer.lpp" YY_FATAL_ERROR( "flex scanner jammed" ); YY_BREAK -#line 2257 "SqlLexer_gen.cpp" +#line 2262 "SqlLexer_gen.cpp" case YY_END_OF_BUFFER: { @@ -3414,7 +3419,7 @@ void quickstep_yyfree (void * ptr , yyscan_t yyscanner) #define YYTABLES_NAME "yytables" -#line 443 "../SqlLexer.lpp" +#line 444 "../SqlLexer.lpp" http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/parser/preprocessed/SqlLexer_gen.hpp ---------------------------------------------------------------------- diff --git a/parser/preprocessed/SqlLexer_gen.hpp b/parser/preprocessed/SqlLexer_gen.hpp index 287c93b..39d4cc0 100644 --- a/parser/preprocessed/SqlLexer_gen.hpp +++ b/parser/preprocessed/SqlLexer_gen.hpp @@ -360,7 +360,7 @@ extern int quickstep_yylex \ #undef YY_DECL #endif -#line 443 "../SqlLexer.lpp" +#line 444 "../SqlLexer.lpp" #line 367 "SqlLexer_gen.hpp"
