You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@quickstep.apache.org by zu...@apache.org on 2016/04/19 18:44:14 UTC

[01/24] incubator-quickstep git commit: Support, and tests for SMA index creation via parser.

Repository: incubator-quickstep
Updated Branches:
  refs/heads/master 390a267a8 -> 2577cf72b


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/57e12d53/parser/preprocessed/SqlParser_gen.hpp
----------------------------------------------------------------------
diff --git a/parser/preprocessed/SqlParser_gen.hpp b/parser/preprocessed/SqlParser_gen.hpp
index 26adf87..9447a22 100644
--- a/parser/preprocessed/SqlParser_gen.hpp
+++ b/parser/preprocessed/SqlParser_gen.hpp
@@ -1,8 +1,8 @@
-/* A Bison parser, made by GNU Bison 3.0.4.  */
+/* A Bison parser, made by GNU Bison 3.0.2.  */
 
 /* Bison interface for Yacc-like parsers in C
 
-   Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
+   Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -138,33 +138,34 @@ extern int quickstep_yydebug;
     TOKEN_ROW_DELIMITER = 348,
     TOKEN_SELECT = 349,
     TOKEN_SET = 350,
-    TOKEN_SMALLINT = 351,
-    TOKEN_TABLE = 352,
-    TOKEN_THEN = 353,
-    TOKEN_TIME = 354,
-    TOKEN_TIMESTAMP = 355,
-    TOKEN_TRUE = 356,
-    TOKEN_TUPLESAMPLE = 357,
-    TOKEN_UNIQUE = 358,
-    TOKEN_UPDATE = 359,
-    TOKEN_USING = 360,
-    TOKEN_VALUES = 361,
-    TOKEN_VARCHAR = 362,
-    TOKEN_WHEN = 363,
-    TOKEN_WHERE = 364,
-    TOKEN_WITH = 365,
-    TOKEN_YEARMONTH = 366,
-    TOKEN_EOF = 367,
-    TOKEN_LEX_ERROR = 368
+    TOKEN_SMA = 351,
+    TOKEN_SMALLINT = 352,
+    TOKEN_TABLE = 353,
+    TOKEN_THEN = 354,
+    TOKEN_TIME = 355,
+    TOKEN_TIMESTAMP = 356,
+    TOKEN_TRUE = 357,
+    TOKEN_TUPLESAMPLE = 358,
+    TOKEN_UNIQUE = 359,
+    TOKEN_UPDATE = 360,
+    TOKEN_USING = 361,
+    TOKEN_VALUES = 362,
+    TOKEN_VARCHAR = 363,
+    TOKEN_WHEN = 364,
+    TOKEN_WHERE = 365,
+    TOKEN_WITH = 366,
+    TOKEN_YEARMONTH = 367,
+    TOKEN_EOF = 368,
+    TOKEN_LEX_ERROR = 369
   };
 #endif
 
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-
+typedef union YYSTYPE YYSTYPE;
 union YYSTYPE
 {
-#line 116 "../SqlParser.ypp" /* yacc.c:1915  */
+#line 116 "../SqlParser.ypp" /* yacc.c:1909  */
 
   quickstep::ParseString *string_value_;
 
@@ -254,10 +255,8 @@ union YYSTYPE
   quickstep::PtrVector<quickstep::ParseSubqueryTableReference> *with_list_;
   quickstep::ParseSubqueryTableReference *with_list_element_;
 
-#line 258 "SqlParser_gen.hpp" /* yacc.c:1915  */
+#line 259 "SqlParser_gen.hpp" /* yacc.c:1909  */
 };
-
-typedef union YYSTYPE YYSTYPE;
 # define YYSTYPE_IS_TRIVIAL 1
 # define YYSTYPE_IS_DECLARED 1
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/57e12d53/parser/tests/Index.test
----------------------------------------------------------------------
diff --git a/parser/tests/Index.test b/parser/tests/Index.test
index 09525f6..b5184bd 100644
--- a/parser/tests/Index.test
+++ b/parser/tests/Index.test
@@ -37,8 +37,8 @@ CREATE INDEX test ON test
                          ^
 ==
 
-# Currently supported indices (csbtree, bloomfilter)
-# Unsupported indices should result in syntax error
+# Currently supported indices are csbtree, bloomfilter, and sma.
+# Unsupported indices should result in syntax error.
 CREATE INDEX test ON test USING arbitrary
 --
 ERROR: syntax error (1 : 33)
@@ -47,9 +47,7 @@ CREATE INDEX test ON test USING arbitrary
 ==
 CREATE INDEX smaIndex ON test USING SMA
 --
-ERROR: syntax error (1 : 37)
-CREATE INDEX smaIndex ON test USING SMA
-                                    ^
+CreateIndexStatement[index_name=smaIndex,relation_name=test,index_type=sma]
 ==
 CREATE INDEX bloomIndex ON test USING BLOOMFILTER
 --

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/57e12d53/query_optimizer/tests/execution_generator/Index.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/execution_generator/Index.test b/query_optimizer/tests/execution_generator/Index.test
index 2dd71f4..749afcb 100644
--- a/query_optimizer/tests/execution_generator/Index.test
+++ b/query_optimizer/tests/execution_generator/Index.test
@@ -53,9 +53,28 @@ SELECT * FROM foo3;
 +-----------+-----------+
 +-----------+-----------+
 ==
-# SMA Index creation is not supported using CREATE INDEX.
-CREATE INDEX smaIndex ON test USING SMA
+# Specifying no columns will index all the columns.
+# Calling INSERT will force creation of the block.
+CREATE TABLE smaTable1 (int_attr int, str_attr VARCHAR(20));
+CREATE INDEX smaIndex ON smaTable1 USING SMA;
+INSERT INTO smaTable1 VALUES (1, 'val1');
+SELECT COUNT(*) FROM smaTable1;
 --
-ERROR: syntax error (1 : 37)
-CREATE INDEX smaIndex ON test USING SMA
-                                    ^
++--------------------+
+|COUNT(*)            |
++--------------------+
+|                   1|
++--------------------+
+==
+# SMA can also specify an index on selected columns.
+# Calling INSERT will force creation of the block.
+CREATE TABLE smaTable2 (int_attr int, str_attr VARCHAR(20));
+CREATE INDEX smaIndex2 ON smaTable2(int_attr) USING SMA;
+INSERT INTO smaTable2 VALUES (1, 'val1');
+SELECT COUNT(*) FROM smaTable2;
+--
++--------------------+
+|COUNT(*)            |
++--------------------+
+|                   1|
++--------------------+

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/57e12d53/query_optimizer/tests/logical_generator/Index.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/logical_generator/Index.test b/query_optimizer/tests/logical_generator/Index.test
index 5a38567..bbab354 100644
--- a/query_optimizer/tests/logical_generator/Index.test
+++ b/query_optimizer/tests/logical_generator/Index.test
@@ -52,10 +52,30 @@ TopLevelPlan
 +-output_attributes=
   +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
 ==
-
-# SMA Index creation is not supported using CREATE INDEX
 CREATE INDEX smaIndex ON test USING SMA
 --
-ERROR: syntax error (1 : 37)
-CREATE INDEX smaIndex ON test USING SMA
-                                    ^
+TopLevelPlan
++-plan=CreateIndex[index_name=smaIndex,
+| serialized_index_description=sub_block_type: SMA
+]
+| +-relation=TableReference[relation_name=Test,relation_alias=test]
+| | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| | +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+| | +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+| | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+| | +-AttributeReference[id=5,name=vchar_col,relation=test,type=VarChar(20) NULL]
+| +-index_attributes=
+|   +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+|   +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+|   +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+|   +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+|   +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+|   +-AttributeReference[id=5,name=vchar_col,relation=test,type=VarChar(20) NULL]
++-output_attributes=
+  +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+  +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+  +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+  +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+  +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+  +-AttributeReference[id=5,name=vchar_col,relation=test,type=VarChar(20) NULL]

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/57e12d53/query_optimizer/tests/physical_generator/Index.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/physical_generator/Index.test b/query_optimizer/tests/physical_generator/Index.test
index 59f514d..2ef989a 100644
--- a/query_optimizer/tests/physical_generator/Index.test
+++ b/query_optimizer/tests/physical_generator/Index.test
@@ -86,10 +86,57 @@ TopLevelPlan
 +-output_attributes=
   +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
 ==
-
-# SMA Index creation is not supported using CREATE INDEX
 CREATE INDEX smaIndex ON test USING SMA
 --
-ERROR: syntax error (1 : 37)
-CREATE INDEX smaIndex ON test USING SMA
-                                    ^
+[Optimized Logical Plan]
+TopLevelPlan
++-plan=CreateIndex[index_name=smaIndex,
+| serialized_index_description=sub_block_type: SMA
+]
+| +-relation=TableReference[relation_name=Test,relation_alias=test]
+| | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| | +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+| | +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+| | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+| | +-AttributeReference[id=5,name=vchar_col,relation=test,type=VarChar(20) NULL]
+| +-index_attributes=
+|   +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+|   +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+|   +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+|   +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+|   +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+|   +-AttributeReference[id=5,name=vchar_col,relation=test,type=VarChar(20) NULL]
++-output_attributes=
+  +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+  +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+  +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+  +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+  +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+  +-AttributeReference[id=5,name=vchar_col,relation=test,type=VarChar(20) NULL]
+[Physical Plan]
+TopLevelPlan
++-plan=CreateIndex[index_name=smaIndex,
+| serialized_index_description=sub_block_type: SMA
+]
+| +-relation=TableReference[relation=Test,alias=test]
+| | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| | +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+| | +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+| | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+| | +-AttributeReference[id=5,name=vchar_col,relation=test,type=VarChar(20) NULL]
+| +-index_attributes=
+|   +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+|   +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+|   +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+|   +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+|   +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+|   +-AttributeReference[id=5,name=vchar_col,relation=test,type=VarChar(20) NULL]
++-output_attributes=
+  +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+  +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+  +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+  +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+  +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+  +-AttributeReference[id=5,name=vchar_col,relation=test,type=VarChar(20) NULL]

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/57e12d53/query_optimizer/tests/resolver/Index.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/resolver/Index.test b/query_optimizer/tests/resolver/Index.test
index 869f1e3..1164172 100644
--- a/query_optimizer/tests/resolver/Index.test
+++ b/query_optimizer/tests/resolver/Index.test
@@ -99,10 +99,30 @@ ERROR: syntax error (1 : 40)
 CREATE INDEX randomIndex ON test USING RANDOM;
                                        ^
 ==
-
-# SMA Index creation is not supported using CREATE INDEX
 CREATE INDEX smaIndex ON test USING SMA
 --
-ERROR: syntax error (1 : 37)
-CREATE INDEX smaIndex ON test USING SMA
-                                    ^
+TopLevelPlan
++-plan=CreateIndex[index_name=smaIndex,
+| serialized_index_description=sub_block_type: SMA
+]
+| +-relation=TableReference[relation_name=Test,relation_alias=test]
+| | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| | +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+| | +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+| | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+| | +-AttributeReference[id=5,name=vchar_col,relation=test,type=VarChar(20) NULL]
+| +-index_attributes=
+|   +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+|   +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+|   +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+|   +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+|   +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+|   +-AttributeReference[id=5,name=vchar_col,relation=test,type=VarChar(20) NULL]
++-output_attributes=
+  +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+  +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+  +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+  +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+  +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+  +-AttributeReference[id=5,name=vchar_col,relation=test,type=VarChar(20) NULL]


[03/24] incubator-quickstep git commit: Support, and tests for SMA index creation via parser.

Posted by zu...@apache.org.
Support, and tests for SMA index creation via parser.

https://github.com/pivotalsoftware/quickstep/pull/157

Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/57e12d53
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/57e12d53
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/57e12d53

Branch: refs/heads/master
Commit: 57e12d5339f4b97084a710c5fa74b952c5d201e1
Parents: 390a267
Author: Marc S <cr...@users.noreply.github.com>
Authored: Wed Apr 13 18:19:16 2016 -0500
Committer: Saket Saurabh <sa...@users.noreply.github.com>
Committed: Wed Apr 13 18:19:16 2016 -0500

----------------------------------------------------------------------
 parser/ParseIndexProperties.hpp                 |   39 +
 parser/ParseStatement.hpp                       |    5 +-
 parser/SqlLexer.lpp                             |    1 +
 parser/SqlParser.ypp                            |    5 +
 parser/preprocessed/SqlLexer_gen.cpp            |  303 +-
 parser/preprocessed/SqlLexer_gen.hpp            |    2 +-
 parser/preprocessed/SqlParser_gen.cpp           | 2875 +++++++++---------
 parser/preprocessed/SqlParser_gen.hpp           |   49 +-
 parser/tests/Index.test                         |    8 +-
 .../tests/execution_generator/Index.test        |   29 +-
 .../tests/logical_generator/Index.test          |   30 +-
 .../tests/physical_generator/Index.test         |   57 +-
 query_optimizer/tests/resolver/Index.test       |   30 +-
 13 files changed, 1791 insertions(+), 1642 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/57e12d53/parser/ParseIndexProperties.hpp
----------------------------------------------------------------------
diff --git a/parser/ParseIndexProperties.hpp b/parser/ParseIndexProperties.hpp
index 0acca62..b34346c 100644
--- a/parser/ParseIndexProperties.hpp
+++ b/parser/ParseIndexProperties.hpp
@@ -343,6 +343,45 @@ class CSBTreeIndexProperties : public IndexProperties {
 };
 
 /**
+ * @brief Implementation of index properties for SMA Index.
+ */
+class SMAIndexProperties : public IndexProperties {
+ public:
+  /**
+   * @brief Constructor.
+   */
+  SMAIndexProperties() : IndexProperties(new IndexSubBlockDescription()) {
+    index_sub_block_description_->set_sub_block_type(IndexSubBlockDescription::SMA);
+  }
+
+  ~SMAIndexProperties() override {
+  }
+
+  std::string getReasonForInvalidIndexDescription() const override {
+    switch (invalid_index_type_) {
+      case InvalidIndexType::kNone:
+        return "";
+      case InvalidIndexType::kInvalidKey:
+        return "SMA index does not define index properties";
+      default:
+        return "Unknown reason";
+    }
+  }
+
+  bool addCustomProperties(const PtrList<ParseKeyValue> *key_value_list) override {
+    // SMA does not define any index properties, so calling this function
+    // will invalidate the index.
+    invalid_index_type_ = InvalidIndexType::kInvalidKey;
+    invalid_property_node_ = nullptr;
+    index_sub_block_description_.reset();
+    return false;
+  }
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(SMAIndexProperties);
+};
+
+/**
  * @brief Encapsulates the IndexProperties key-value list. Makes the job
  *        of resolving IndexProperties easy.
  */

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/57e12d53/parser/ParseStatement.hpp
----------------------------------------------------------------------
diff --git a/parser/ParseStatement.hpp b/parser/ParseStatement.hpp
index 9807e0a..643643d 100644
--- a/parser/ParseStatement.hpp
+++ b/parser/ParseStatement.hpp
@@ -355,7 +355,7 @@ class ParseStatementCreateIndex : public ParseStatement {
           inline_field_values->push_back("sma");
           break;
         default:
-          inline_field_values->push_back("unkown");
+          inline_field_values->push_back("unknown");
       }
 
       if (attribute_list_ != nullptr) {
@@ -392,7 +392,8 @@ class ParseStatementCreateIndex : public ParseStatement {
           index_properties_.reset(new CSBTreeIndexProperties());
           break;
         case IndexSubBlockType::kSMA:
-          LOG(FATAL) << "Currently cannot create this index subblock type using CREATE INDEX.";
+          index_properties_.reset(new SMAIndexProperties());
+          break;
         default:
           LOG(FATAL) << "Unknown index subblock type.";
           break;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/57e12d53/parser/SqlLexer.lpp
----------------------------------------------------------------------
diff --git a/parser/SqlLexer.lpp b/parser/SqlLexer.lpp
index 354db86..0c9e646 100644
--- a/parser/SqlLexer.lpp
+++ b/parser/SqlLexer.lpp
@@ -248,6 +248,7 @@ unsigned_numeric_literal {exact_numeric_literal}|{approximate_numeric_literal}
   "row_delimiter"    return TOKEN_ROW_DELIMITER;
   "select"           return TOKEN_SELECT;
   "set"              return TOKEN_SET;
+  "sma"              return TOKEN_SMA;
   "smallint"         return TOKEN_SMALLINT;
   "table"            return TOKEN_TABLE;
   "then"             return TOKEN_THEN;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/57e12d53/parser/SqlParser.ypp
----------------------------------------------------------------------
diff --git a/parser/SqlParser.ypp b/parser/SqlParser.ypp
index 56f50b6..c6ff7db 100644
--- a/parser/SqlParser.ypp
+++ b/parser/SqlParser.ypp
@@ -306,6 +306,7 @@ void NotSupported(const YYLTYPE *location, yyscan_t yyscanner, const std::string
 %token TOKEN_ROW_DELIMITER;
 %token TOKEN_SELECT;
 %token TOKEN_SET;
+%token TOKEN_SMA;
 %token TOKEN_SMALLINT;
 %token TOKEN_TABLE;
 %token TOKEN_THEN;
@@ -989,6 +990,10 @@ index_type:
   | TOKEN_CSB_TREE {
     $$ = new quickstep::ParseString(@1.first_line, @1.first_column,
            std::to_string(quickstep::IndexSubBlockType::kCSBTree));
+  }
+  | TOKEN_SMA {
+    $$ = new quickstep::ParseString(@1.first_line, @1.first_column,
+           std::to_string(quickstep::IndexSubBlockType::kSMA));
   };
 
 opt_index_properties:

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/57e12d53/parser/preprocessed/SqlLexer_gen.cpp
----------------------------------------------------------------------
diff --git a/parser/preprocessed/SqlLexer_gen.cpp b/parser/preprocessed/SqlLexer_gen.cpp
index a6173d7..878ac58 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 141
-#define YY_END_OF_BUFFER 142
+#define YY_NUM_RULES 142
+#define YY_END_OF_BUFFER 143
 /* 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,  142,    2,    2,  140,  140,  139,  138,  140,
-      117,  113,  116,  113,  113,  136,  109,  106,  110,  135,
-      135,  135,  135,  135,  135,  135,  135,  135,  135,  135,
-      135,  135,  135,  135,  135,  135,  135,  135,  135,  135,
-      135,  135,  135,  114,    4,    5,    5,    3,  132,  132,
-      129,  133,  133,  127,  134,  134,  131,    1,  139,  107,
-      137,  136,  136,  136,    0,  111,  108,  112,  135,  135,
-      135,  135,   10,  135,  135,  135,   21,  135,  135,  135,
-      135,  135,  135,  135,  135,  135,  135,  115,  135,  135,
-
-      135,  135,  135,  135,  135,  135,  135,  135,  135,  135,
-      135,   61,  135,  135,  135,  135,  135,  135,  135,  135,
-      135,   73,   74,  135,  135,  135,  135,  135,  135,  135,
-      135,  135,  135,  135,  135,  135,  135,  135,  135,  135,
-      135,  135,  135,  135,  135,  135,    4,    5,    3,  132,
-      128,  133,  126,  126,  118,  120,  121,  122,  123,  124,
-      125,  126,  134,  130,  137,  136,    0,  136,    6,    7,
-      135,    9,   11,  135,  135,   15,  135,  135,  135,  135,
-      135,  135,  135,  135,  135,  135,  135,  135,  135,  135,
-      135,  135,  135,  135,   41,  135,  135,  135,  135,  135,
-
-      135,  135,  135,  135,  135,  135,  135,  135,  135,  135,
-       57,  135,   63,  135,  135,  135,  135,  135,   69,  135,
-       72,  135,  135,  135,  135,  135,  135,  135,  135,  135,
-      135,  135,  135,  135,   89,  135,  135,  135,  135,  135,
-      135,  135,  135,  135,  135,  135,  135,  135,  135,  118,
-      120,  119,  135,  135,  135,  135,  135,  135,   19,   22,
-      135,  135,  135,   27,  135,  135,   29,  135,  135,  135,
-      135,   35,  135,  135,   39,   40,  135,  135,  135,  135,
-      135,  135,  135,   49,   50,  135,   52,  135,  135,  135,
-      135,  135,   60,   62,   64,   65,   66,  135,   68,   70,
-
-      135,  135,  135,  135,  135,   81,  135,   83,  135,  135,
-      135,  135,  135,  135,  135,   92,   93,   95,  135,  135,
-      135,  135,  135,  135,  102,  135,  104,  135,  118,  119,
-        8,  135,  135,  135,  135,  135,  135,   24,  135,  135,
-      135,  135,  135,  135,  135,  135,  135,  135,  135,  135,
-      135,  135,  135,   45,   46,   47,  135,   51,  135,   54,
-       55,  135,  135,  135,   67,   71,   75,   76,  135,  135,
-      135,   82,  135,  135,   86,  135,  135,  135,   91,  135,
-      135,  135,  135,   99,  135,  135,  103,  135,  135,  135,
-       14,  135,  135,  135,  135,   25,  135,   28,  135,  135,
-
-      135,  135,   33,  135,  135,  135,   38,  135,   43,  135,
-      135,   53,   56,  135,  135,  135,  135,  135,  135,   85,
-      135,   88,  135,  135,  135,   97,   98,  100,  135,  135,
-      135,   13,  135,  135,  135,  135,  135,   20,  135,   31,
-       32,  135,  135,  135,  135,   44,   48,   58,  135,  135,
-       79,   80,  135,  135,  135,  135,  135,  101,  135,  135,
-      135,  135,  135,  135,  135,   30,  135,  135,   37,  135,
-       59,  135,  135,  135,   90,  135,  135,  135,   12,  135,
-      135,  135,   23,  135,   34,  135,  135,   77,  135,  135,
-       94,  135,  105,  135,  135,  135,   26,   36,  135,   78,
-
-       84,  135,  135,  135,   17,   18,  135,  135,   96,  135,
-      135,  135,  135,  135,   87,  135,   42,   16,    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
     } ;
 
 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[142] =
+static yyconst flex_int32_t yy_rule_can_match_eol[143] =
     {   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[142] =
     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, 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.
@@ -1858,92 +1858,92 @@ return TOKEN_SET;
 case 90:
 YY_RULE_SETUP
 #line 251 "../SqlLexer.lpp"
-return TOKEN_SMALLINT;
+return TOKEN_SMA;
 	YY_BREAK
 case 91:
 YY_RULE_SETUP
 #line 252 "../SqlLexer.lpp"
-return TOKEN_TABLE;
+return TOKEN_SMALLINT;
 	YY_BREAK
 case 92:
 YY_RULE_SETUP
 #line 253 "../SqlLexer.lpp"
-return TOKEN_THEN;
+return TOKEN_TABLE;
 	YY_BREAK
 case 93:
 YY_RULE_SETUP
 #line 254 "../SqlLexer.lpp"
-return TOKEN_TIME;
+return TOKEN_THEN;
 	YY_BREAK
 case 94:
 YY_RULE_SETUP
 #line 255 "../SqlLexer.lpp"
-return TOKEN_TIMESTAMP;
+return TOKEN_TIME;
 	YY_BREAK
 case 95:
 YY_RULE_SETUP
 #line 256 "../SqlLexer.lpp"
-return TOKEN_TRUE;
+return TOKEN_TIMESTAMP;
 	YY_BREAK
 case 96:
 YY_RULE_SETUP
 #line 257 "../SqlLexer.lpp"
-return TOKEN_TUPLESAMPLE;
+return TOKEN_TRUE;
 	YY_BREAK
 case 97:
 YY_RULE_SETUP
 #line 258 "../SqlLexer.lpp"
-return TOKEN_UNIQUE;
+return TOKEN_TUPLESAMPLE;
 	YY_BREAK
 case 98:
 YY_RULE_SETUP
 #line 259 "../SqlLexer.lpp"
-return TOKEN_UPDATE;
+return TOKEN_UNIQUE;
 	YY_BREAK
 case 99:
 YY_RULE_SETUP
 #line 260 "../SqlLexer.lpp"
-return TOKEN_USING;
+return TOKEN_UPDATE;
 	YY_BREAK
 case 100:
 YY_RULE_SETUP
 #line 261 "../SqlLexer.lpp"
-return TOKEN_VALUES;
+return TOKEN_USING;
 	YY_BREAK
 case 101:
 YY_RULE_SETUP
 #line 262 "../SqlLexer.lpp"
-return TOKEN_VARCHAR;
+return TOKEN_VALUES;
 	YY_BREAK
 case 102:
 YY_RULE_SETUP
 #line 263 "../SqlLexer.lpp"
-return TOKEN_WHEN;
+return TOKEN_VARCHAR;
 	YY_BREAK
 case 103:
 YY_RULE_SETUP
 #line 264 "../SqlLexer.lpp"
-return TOKEN_WHERE;
+return TOKEN_WHEN;
 	YY_BREAK
 case 104:
 YY_RULE_SETUP
 #line 265 "../SqlLexer.lpp"
-return TOKEN_WITH;
+return TOKEN_WHERE;
 	YY_BREAK
 case 105:
 YY_RULE_SETUP
 #line 266 "../SqlLexer.lpp"
-return TOKEN_YEARMONTH;
+return TOKEN_WITH;
 	YY_BREAK
 case 106:
 YY_RULE_SETUP
-#line 268 "../SqlLexer.lpp"
-return TOKEN_EQ;
+#line 267 "../SqlLexer.lpp"
+return TOKEN_YEARMONTH;
 	YY_BREAK
 case 107:
 YY_RULE_SETUP
 #line 269 "../SqlLexer.lpp"
-return TOKEN_NEQ;
+return TOKEN_EQ;
 	YY_BREAK
 case 108:
 YY_RULE_SETUP
@@ -1953,56 +1953,61 @@ return TOKEN_NEQ;
 case 109:
 YY_RULE_SETUP
 #line 271 "../SqlLexer.lpp"
-return TOKEN_LT;
+return TOKEN_NEQ;
 	YY_BREAK
 case 110:
 YY_RULE_SETUP
 #line 272 "../SqlLexer.lpp"
-return TOKEN_GT;
+return TOKEN_LT;
 	YY_BREAK
 case 111:
 YY_RULE_SETUP
 #line 273 "../SqlLexer.lpp"
-return TOKEN_LEQ;
+return TOKEN_GT;
 	YY_BREAK
 case 112:
 YY_RULE_SETUP
 #line 274 "../SqlLexer.lpp"
-return TOKEN_GEQ;
+return TOKEN_LEQ;
 	YY_BREAK
 case 113:
 YY_RULE_SETUP
-#line 276 "../SqlLexer.lpp"
-return yytext[0];
+#line 275 "../SqlLexer.lpp"
+return TOKEN_GEQ;
 	YY_BREAK
 case 114:
 YY_RULE_SETUP
 #line 277 "../SqlLexer.lpp"
 return yytext[0];
 	YY_BREAK
+case 115:
+YY_RULE_SETUP
+#line 278 "../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 115:
+case 116:
 YY_RULE_SETUP
-#line 283 "../SqlLexer.lpp"
+#line 284 "../SqlLexer.lpp"
 {
     yylval->string_value_ = new quickstep::ParseString(yylloc->first_line, yylloc->first_column);
     BEGIN(CONDITION_STRING_SINGLE_QUOTED_ESCAPED);
   }
 	YY_BREAK
-case 116:
+case 117:
 YY_RULE_SETUP
-#line 288 "../SqlLexer.lpp"
+#line 289 "../SqlLexer.lpp"
 {
     yylval->string_value_ = new quickstep::ParseString(yylloc->first_line, yylloc->first_column);
     BEGIN(CONDITION_STRING_SINGLE_QUOTED);
   }
 	YY_BREAK
-case 117:
+case 118:
 YY_RULE_SETUP
-#line 293 "../SqlLexer.lpp"
+#line 294 "../SqlLexer.lpp"
 {
     yylval->string_value_ = new quickstep::ParseString(yylloc->first_line, yylloc->first_column);
     BEGIN(CONDITION_STRING_DOUBLE_QUOTED);
@@ -2014,7 +2019,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 302 "../SqlLexer.lpp"
+#line 303 "../SqlLexer.lpp"
 {
     delete yylval->string_value_;
     BEGIN(INITIAL);
@@ -2025,9 +2030,9 @@ case YY_STATE_EOF(CONDITION_STRING_DOUBLE_QUOTED):
 
 /* Process escape sequences. */
 
-case 118:
+case 119:
 YY_RULE_SETUP
-#line 312 "../SqlLexer.lpp"
+#line 313 "../SqlLexer.lpp"
 {
     /* Octal code */
     unsigned int code;
@@ -2041,9 +2046,9 @@ YY_RULE_SETUP
     yylval->string_value_->push_back(code);
   }
 	YY_BREAK
-case 119:
+case 120:
 YY_RULE_SETUP
-#line 324 "../SqlLexer.lpp"
+#line 325 "../SqlLexer.lpp"
 {
     /* Hexadecimal code */
     unsigned int code;
@@ -2051,9 +2056,9 @@ YY_RULE_SETUP
     yylval->string_value_->push_back(code);
   }
 	YY_BREAK
-case 120:
+case 121:
 YY_RULE_SETUP
-#line 330 "../SqlLexer.lpp"
+#line 331 "../SqlLexer.lpp"
 {
     /* A numeric escape sequence that isn't correctly specified. */
     delete yylval->string_value_;
@@ -2062,58 +2067,58 @@ YY_RULE_SETUP
     return TOKEN_LEX_ERROR;
   }
 	YY_BREAK
-case 121:
+case 122:
 YY_RULE_SETUP
-#line 337 "../SqlLexer.lpp"
+#line 338 "../SqlLexer.lpp"
 {
     /* Backspace */
     yylval->string_value_->push_back('\b');
   }
 	YY_BREAK
-case 122:
+case 123:
 YY_RULE_SETUP
-#line 341 "../SqlLexer.lpp"
+#line 342 "../SqlLexer.lpp"
 {
     /* Form-feed */
     yylval->string_value_->push_back('\f');
   }
 	YY_BREAK
-case 123:
+case 124:
 YY_RULE_SETUP
-#line 345 "../SqlLexer.lpp"
+#line 346 "../SqlLexer.lpp"
 {
     /* Newline */
     yylval->string_value_->push_back('\n');
   }
 	YY_BREAK
-case 124:
+case 125:
 YY_RULE_SETUP
-#line 349 "../SqlLexer.lpp"
+#line 350 "../SqlLexer.lpp"
 {
     /* Carriage-return */
     yylval->string_value_->push_back('\r');
   }
 	YY_BREAK
-case 125:
+case 126:
 YY_RULE_SETUP
-#line 353 "../SqlLexer.lpp"
+#line 354 "../SqlLexer.lpp"
 {
     /* Horizontal Tab */
     yylval->string_value_->push_back('\t');
   }
 	YY_BREAK
-case 126:
-/* rule 126 can match eol */
+case 127:
+/* rule 127 can match eol */
 YY_RULE_SETUP
-#line 357 "../SqlLexer.lpp"
+#line 358 "../SqlLexer.lpp"
 {
     /* Any other character (including actual newline or carriage return) */
     yylval->string_value_->push_back(yytext[1]);
   }
 	YY_BREAK
-case 127:
+case 128:
 YY_RULE_SETUP
-#line 361 "../SqlLexer.lpp"
+#line 362 "../SqlLexer.lpp"
 {
     /* This should only be encountered right before an EOF. */
     delete yylval->string_value_;
@@ -2124,17 +2129,17 @@ YY_RULE_SETUP
 	YY_BREAK
 
 
-case 128:
+case 129:
 YY_RULE_SETUP
-#line 371 "../SqlLexer.lpp"
+#line 372 "../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 129:
+case 130:
 YY_RULE_SETUP
-#line 375 "../SqlLexer.lpp"
+#line 376 "../SqlLexer.lpp"
 {
     /* End string */
     BEGIN(CONDITION_SQL);
@@ -2143,17 +2148,17 @@ YY_RULE_SETUP
 	YY_BREAK
 
 
-case 130:
+case 131:
 YY_RULE_SETUP
-#line 383 "../SqlLexer.lpp"
+#line 384 "../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 131:
+case 132:
 YY_RULE_SETUP
-#line 387 "../SqlLexer.lpp"
+#line 388 "../SqlLexer.lpp"
 {
     /* End string */
     BEGIN(CONDITION_SQL);
@@ -2161,94 +2166,94 @@ YY_RULE_SETUP
   }
 	YY_BREAK
 
-case 132:
-/* rule 132 can match eol */
+case 133:
+/* rule 133 can match eol */
 YY_RULE_SETUP
-#line 394 "../SqlLexer.lpp"
+#line 395 "../SqlLexer.lpp"
 {
   /* Scan up to a quote. */
   yylval->string_value_->append(yytext, yyleng);
 }
 	YY_BREAK
-case 133:
-/* rule 133 can match eol */
+case 134:
+/* rule 134 can match eol */
 YY_RULE_SETUP
-#line 399 "../SqlLexer.lpp"
+#line 400 "../SqlLexer.lpp"
 {
   /* Scan up to a quote or escape sequence. */
   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 404 "../SqlLexer.lpp"
+#line 405 "../SqlLexer.lpp"
 {
   /* Scan up to a quote. */
   yylval->string_value_->append(yytext, yyleng);
 }
 	YY_BREAK
 
-case 135:
+case 136:
 YY_RULE_SETUP
-#line 410 "../SqlLexer.lpp"
+#line 411 "../SqlLexer.lpp"
 {
     yylval->string_value_ = new quickstep::ParseString(
         yylloc->first_line, yylloc->first_column, std::string(yytext, yyleng));
     return TOKEN_NAME;
   }
 	YY_BREAK
-case 136:
+case 137:
 YY_RULE_SETUP
-#line 416 "../SqlLexer.lpp"
+#line 417 "../SqlLexer.lpp"
 {
     yylval->numeric_literal_value_ = new quickstep::NumericParseLiteralValue(
         yylloc->first_line, yylloc->first_column, yytext);
     return TOKEN_UNSIGNED_NUMVAL;
   }
 	YY_BREAK
-case 137:
+case 138:
 YY_RULE_SETUP
-#line 422 "../SqlLexer.lpp"
+#line 423 "../SqlLexer.lpp"
 /* comment */
 	YY_BREAK
-case 138:
-/* rule 138 can match eol */
+case 139:
+/* rule 139 can match eol */
 YY_RULE_SETUP
-#line 424 "../SqlLexer.lpp"
+#line 425 "../SqlLexer.lpp"
 { yycolumn = 0; }
 	YY_BREAK
-case 139:
+case 140:
 YY_RULE_SETUP
-#line 426 "../SqlLexer.lpp"
+#line 427 "../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 430 "../SqlLexer.lpp"
+#line 431 "../SqlLexer.lpp"
 {
   /* All conditions except for mutli-state string extracting conditions. */
   BEGIN(INITIAL);
   return TOKEN_EOF;
 }
 	YY_BREAK
-case 140:
+case 141:
 YY_RULE_SETUP
-#line 436 "../SqlLexer.lpp"
+#line 437 "../SqlLexer.lpp"
 {
   BEGIN(INITIAL);
   quickstep_yyerror(NULL, yyscanner, NULL, "illegal character");
   return TOKEN_LEX_ERROR;
 }
 	YY_BREAK
-case 141:
+case 142:
 YY_RULE_SETUP
-#line 442 "../SqlLexer.lpp"
+#line 443 "../SqlLexer.lpp"
 YY_FATAL_ERROR( "flex scanner jammed" );
 	YY_BREAK
-#line 2252 "SqlLexer_gen.cpp"
+#line 2257 "SqlLexer_gen.cpp"
 
 	case YY_END_OF_BUFFER:
 		{
@@ -3409,7 +3414,7 @@ void quickstep_yyfree (void * ptr , yyscan_t yyscanner)
 
 #define YYTABLES_NAME "yytables"
 
-#line 442 "../SqlLexer.lpp"
+#line 443 "../SqlLexer.lpp"
 
 
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/57e12d53/parser/preprocessed/SqlLexer_gen.hpp
----------------------------------------------------------------------
diff --git a/parser/preprocessed/SqlLexer_gen.hpp b/parser/preprocessed/SqlLexer_gen.hpp
index f454e7b..287c93b 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 442 "../SqlLexer.lpp"
+#line 443 "../SqlLexer.lpp"
 
 
 #line 367 "SqlLexer_gen.hpp"


[24/24] incubator-quickstep git commit: Update .travis.yml (#177)

Posted by zu...@apache.org.
Update .travis.yml (#177)

Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/2577cf72
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/2577cf72
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/2577cf72

Branch: refs/heads/master
Commit: 2577cf72b6f8cc811a4f3d429fcc1b88c67122bc
Parents: 19e74ab
Author: Hakan Memisoglu <ha...@gmail.com>
Authored: Tue Apr 19 06:36:20 2016 -0500
Committer: Jignesh Patel <pa...@users.noreply.github.com>
Committed: Tue Apr 19 06:36:20 2016 -0500

----------------------------------------------------------------------
 .travis.yml | 2 ++
 1 file changed, 2 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/2577cf72/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index e1a9cba..483a02b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,6 +8,8 @@
 
 language: cpp
 
+cache: ccache
+
 compiler:
   - gcc
   - clang


[08/24] incubator-quickstep git commit: Use gcc5 in Travis (#161)

Posted by zu...@apache.org.
Use gcc5 in Travis (#161)

* Changed travis configuration to use gcc-5.

* Fixed the errors that causes gcc-5.3 to fail.


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/476f0aca
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/476f0aca
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/476f0aca

Branch: refs/heads/master
Commit: 476f0aca3b6d0991fb4dc677efa4fdad32e7c0b1
Parents: aee53ee
Author: Hakan Memisoglu <ha...@gmail.com>
Authored: Thu Apr 14 16:30:48 2016 -0500
Committer: Jignesh Patel <pa...@users.noreply.github.com>
Committed: Thu Apr 14 16:30:48 2016 -0500

----------------------------------------------------------------------
 .travis.yml                                          | 10 +++++-----
 CMakeLists.txt                                       |  2 +-
 cli/CommandExecutor.cpp                              |  2 +-
 expressions/aggregation/AggregationHandleCount.cpp   |  2 +-
 expressions/scalar/ScalarAttribute.cpp               |  7 +++++--
 query_optimizer/ExecutionGenerator.cpp               |  4 ++--
 relational_operators/SortMergeRunOperatorHelpers.cpp |  4 ++--
 relational_operators/TextScanOperator.cpp            |  2 +-
 storage/InsertDestination.cpp                        | 11 +++++++++--
 storage/PackedRowStoreTupleStorageSubBlock.cpp       |  4 ++--
 storage/StorageBlock.cpp                             |  7 ++++++-
 storage/StorageManager.cpp                           | 12 ++++++------
 12 files changed, 41 insertions(+), 26 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/476f0aca/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 9c5eacf..16bb6fb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -19,15 +19,15 @@ env:
   - BUILD_TYPE=Release VECTOR_COPY_ELISION_LEVEL=none
 
 install:
-  - if [ "$VECTOR_COPY_ELISION_LEVEL" = "joinwithbinaryexpressions" ] && [ "$CC" = "gcc" ]; then
+  - if [ "$VECTOR_COPY_ELISION_LEVEL" = "joinwithbinaryexpressions" ] && [ "$CC" = "gcc" ] && [ "$BUILD_TYPE" = "Debug" ]; then
       export MAKE_JOBS=1;
     else
       export MAKE_JOBS=2;
     fi
   - export TEST_JOBS=2;
   - if [ "$CC" = "gcc" ]; then
-      export CC="gcc-4.9";
-      export CXX="g++-4.9";
+      export CC="gcc-5";
+      export CXX="g++-5";
     elif [ "$CC" = "clang" ]; then
       export CC="clang-3.7";
       export CXX="clang++-3.7";
@@ -74,8 +74,8 @@ addons:
       - ubuntu-toolchain-r-test
       - llvm-toolchain-precise-3.7
     packages:
-      - gcc-4.9
-      - g++-4.9
+      - gcc-5
+      - g++-5
       - clang-3.7
       - libprotobuf-dev
       - protobuf-compiler

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/476f0aca/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b97adfa..869d43c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -585,7 +585,7 @@ endfunction()
 set(gtest_force_shared_crt ON CACHE BOOL "Link gtest against shared DLLs on Windows")
 add_subdirectory ("${THIRD_PARTY_SOURCE_DIR}/googletest/googletest"
                   "${CMAKE_CURRENT_BINARY_DIR}/third_party/googletest/googletest")
-include_directories("${THIRD_PARTY_SOURCE_DIR}/googletest/googletest/include")
+include_directories(SYSTEM "${THIRD_PARTY_SOURCE_DIR}/googletest/googletest/include")
 enable_testing()
 
 if (UNIX)

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/476f0aca/cli/CommandExecutor.cpp
----------------------------------------------------------------------
diff --git a/cli/CommandExecutor.cpp b/cli/CommandExecutor.cpp
index e9db628..f38121f 100644
--- a/cli/CommandExecutor.cpp
+++ b/cli/CommandExecutor.cpp
@@ -56,7 +56,7 @@ void executeDescribeDatabase(
   // Column width initialized to 6 to take into account the header name
   // and the column value table
   int max_column_width = C::kInitMaxColumnWidth;
-  const CatalogRelation *relation;
+  const CatalogRelation *relation = nullptr;
   if (arguments->size() == 0) {
     for (const CatalogRelation &rel : catalog_database) {
       max_column_width =

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/476f0aca/expressions/aggregation/AggregationHandleCount.cpp
----------------------------------------------------------------------
diff --git a/expressions/aggregation/AggregationHandleCount.cpp b/expressions/aggregation/AggregationHandleCount.cpp
index 9fb9fd4..5ece8ba 100644
--- a/expressions/aggregation/AggregationHandleCount.cpp
+++ b/expressions/aggregation/AggregationHandleCount.cpp
@@ -112,7 +112,7 @@ AggregationState*
   std::size_t count = 0;
   InvokeOnValueAccessorMaybeTupleIdSequenceAdapter(
       accessor,
-      [&](auto *accessor) -> void {  // NOLINT(build/c++11)
+      [&accessor_id, &count](auto *accessor) -> void {  // NOLINT(build/c++11)
     if (nullable_type) {
       while (accessor->next()) {
         count += !accessor->getTypedValue(accessor_id).isNull();

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/476f0aca/expressions/scalar/ScalarAttribute.cpp
----------------------------------------------------------------------
diff --git a/expressions/scalar/ScalarAttribute.cpp b/expressions/scalar/ScalarAttribute.cpp
index 738b1d7..ed91bd1 100644
--- a/expressions/scalar/ScalarAttribute.cpp
+++ b/expressions/scalar/ScalarAttribute.cpp
@@ -92,7 +92,7 @@ ColumnVector* ScalarAttribute::getAllValues(ValueAccessor *accessor,
   const Type &result_type = attribute_.getType();
   return InvokeOnValueAccessorMaybeTupleIdSequenceAdapter(
       accessor,
-      [&](auto *accessor) -> ColumnVector* {  // NOLINT(build/c++11)
+      [&attr_id, &result_type](auto *accessor) -> ColumnVector* {  // NOLINT(build/c++11)
     if (NativeColumnVector::UsableForType(result_type)) {
       NativeColumnVector *result = new NativeColumnVector(result_type,
                                                           accessor->getNumTuples());
@@ -143,7 +143,10 @@ ColumnVector* ScalarAttribute::getAllValuesForJoin(
 
   return InvokeOnValueAccessorNotAdapter(
       accessor,
-      [&](auto *accessor) -> ColumnVector* {  // NOLINT(build/c++11)
+      [&joined_tuple_ids,
+       &attr_id,
+       &result_type,
+       &using_left_relation](auto *accessor) -> ColumnVector* {  // NOLINT(build/c++11)
     if (NativeColumnVector::UsableForType(result_type)) {
       NativeColumnVector *result = new NativeColumnVector(result_type,
                                                           joined_tuple_ids.size());

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/476f0aca/query_optimizer/ExecutionGenerator.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp
index aa6b0dc..43825b9 100644
--- a/query_optimizer/ExecutionGenerator.cpp
+++ b/query_optimizer/ExecutionGenerator.cpp
@@ -121,14 +121,14 @@ namespace optimizer {
 DEFINE_string(join_hashtable_type, "SeparateChaining",
               "HashTable implementation to use for hash joins (valid options "
               "are SeparateChaining or LinearOpenAddressing)");
-static const bool join_hashtable_type_dummy
+static const volatile bool join_hashtable_type_dummy
     = gflags::RegisterFlagValidator(&FLAGS_join_hashtable_type,
                                     &ValidateHashTableImplTypeString);
 
 DEFINE_string(aggregate_hashtable_type, "LinearOpenAddressing",
               "HashTable implementation to use for aggregates with GROUP BY "
               "(valid options are SeparateChaining or LinearOpenAddressing)");
-static const bool aggregate_hashtable_type_dummy
+static const volatile bool aggregate_hashtable_type_dummy
     = gflags::RegisterFlagValidator(&FLAGS_aggregate_hashtable_type,
                                     &ValidateHashTableImplTypeString);
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/476f0aca/relational_operators/SortMergeRunOperatorHelpers.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/SortMergeRunOperatorHelpers.cpp b/relational_operators/SortMergeRunOperatorHelpers.cpp
index 1b4332f..4b8c0d9 100644
--- a/relational_operators/SortMergeRunOperatorHelpers.cpp
+++ b/relational_operators/SortMergeRunOperatorHelpers.cpp
@@ -243,7 +243,7 @@ void RunMerger::mergeSingleColumnNullFirst(ValueAccessor *first_accessor) {
 
   InvokeOnValueAccessorNotAdapter(
       first_accessor,
-      [&](auto *accessor) -> void {  // NOLINT(build/c++11)
+      [this, &attr_id, &comp](auto *accessor) -> void {  // NOLINT(build/c++11)
     typedef typename std::remove_reference<decltype(*accessor)>::type ValueAccessorT;
 
     PtrVector<RunIterator<ValueAccessorT>, true> iterators;
@@ -322,7 +322,7 @@ void RunMerger::mergeSingleColumnNullLast(ValueAccessor *first_accessor) {
 
   InvokeOnValueAccessorNotAdapter(
       first_accessor,
-      [&](auto *accessor) -> void {  // NOLINT(build/c++11)
+      [this, &attr_id, &comp](auto *accessor) -> void {  // NOLINT(build/c++11)
     typedef typename std::remove_reference<decltype(*accessor)>::type ValueAccessorT;
 
     PtrVector<RunIterator<ValueAccessorT>> iterators;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/476f0aca/relational_operators/TextScanOperator.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/TextScanOperator.cpp b/relational_operators/TextScanOperator.cpp
index 4614050..a311a81 100644
--- a/relational_operators/TextScanOperator.cpp
+++ b/relational_operators/TextScanOperator.cpp
@@ -74,7 +74,7 @@ static bool ValidateTextScanSplitBlobSize(const char *flagname,
   return true;
 }
 
-static const bool text_scan_split_blob_size_dummy = gflags::RegisterFlagValidator(
+static const volatile bool text_scan_split_blob_size_dummy = gflags::RegisterFlagValidator(
     &FLAGS_textscan_split_blob_size, &ValidateTextScanSplitBlobSize);
 
 namespace {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/476f0aca/storage/InsertDestination.cpp
----------------------------------------------------------------------
diff --git a/storage/InsertDestination.cpp b/storage/InsertDestination.cpp
index 30fd2c3..354bed4 100644
--- a/storage/InsertDestination.cpp
+++ b/storage/InsertDestination.cpp
@@ -511,7 +511,10 @@ void PartitionAwareInsertDestination::bulkInsertTuples(ValueAccessor *accessor,
 
   InvokeOnAnyValueAccessor(
       accessor,
-      [&](auto *accessor) -> void {  // NOLINT(build/c++11)
+      [this,
+       &partition_attribute_id,
+       &always_mark_full,
+       &num_partitions](auto *accessor) -> void {  // NOLINT(build/c++11)
     std::vector<std::unique_ptr<TupleIdSequence>> partition_membership;
     partition_membership.resize(num_partitions);
 
@@ -564,7 +567,11 @@ void PartitionAwareInsertDestination::bulkInsertTuplesWithRemappedAttributes(
 
   InvokeOnAnyValueAccessor(
       accessor,
-      [&](auto *accessor) -> void {  // NOLINT(build/c++11)
+      [this,
+       &partition_attribute_id,
+       &attribute_map,
+       &always_mark_full,
+       &num_partitions](auto *accessor) -> void {  // NOLINT(build/c++11)
     std::vector<std::unique_ptr<TupleIdSequence>> partition_membership;
     partition_membership.resize(num_partitions);
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/476f0aca/storage/PackedRowStoreTupleStorageSubBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/PackedRowStoreTupleStorageSubBlock.cpp b/storage/PackedRowStoreTupleStorageSubBlock.cpp
index 4cb6d02..ef83a29 100644
--- a/storage/PackedRowStoreTupleStorageSubBlock.cpp
+++ b/storage/PackedRowStoreTupleStorageSubBlock.cpp
@@ -145,7 +145,7 @@ tuple_id PackedRowStoreTupleStorageSubBlock::bulkInsertTuples(ValueAccessor *acc
 
   InvokeOnAnyValueAccessor(
       accessor,
-      [&](auto *accessor) -> void {  // NOLINT(build/c++11)
+      [this, &dest_addr, &num_nullable_attrs](auto *accessor) -> void {  // NOLINT(build/c++11)
     const std::size_t num_attrs = relation_.size();
     const std::vector<std::size_t> &attrs_max_size =
         relation_.getMaximumAttributeByteLengths();
@@ -216,7 +216,7 @@ tuple_id PackedRowStoreTupleStorageSubBlock::bulkInsertTuplesWithRemappedAttribu
 
   InvokeOnAnyValueAccessor(
       accessor,
-      [&](auto *accessor) -> void {  // NOLINT(build/c++11)
+      [this, &num_nullable_attrs, &attribute_map, &dest_addr](auto *accessor) -> void {  // NOLINT(build/c++11)
     const std::size_t num_attrs = relation_.size();
     const std::vector<std::size_t> &attrs_max_size =
         relation_.getMaximumAttributeByteLengths();

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/476f0aca/storage/StorageBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/StorageBlock.cpp b/storage/StorageBlock.cpp
index 2850c9c..fba4d60 100644
--- a/storage/StorageBlock.cpp
+++ b/storage/StorageBlock.cpp
@@ -805,7 +805,12 @@ void StorageBlock::sortColumn(bool use_input_sequence,
   ValueAccessor *all_accessor = tuple_store_->createValueAccessor(nullptr);
   InvokeOnValueAccessorNotAdapter(
       all_accessor,
-      [&](auto *all_accessor) -> void {  // NOLINT(build/c++11)
+      [&sort_attr_id,
+       &use_input_sequence,
+       &nulls,
+       &refs,
+       &accessor,
+       &sorted_sequence](auto *all_accessor) -> void {  // NOLINT(build/c++11)
     if (use_input_sequence) {
       auto *seq_value_accessor = new OrderedTupleIdSequenceAdapterValueAccessor<
           typename std::remove_reference<decltype(*all_accessor)>::type>(

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/476f0aca/storage/StorageManager.cpp
----------------------------------------------------------------------
diff --git a/storage/StorageManager.cpp b/storage/StorageManager.cpp
index 9965dce..1cdbcb6 100644
--- a/storage/StorageManager.cpp
+++ b/storage/StorageManager.cpp
@@ -94,18 +94,18 @@ static bool ValidateBlockDomain(const char *flagname,
 }
 DEFINE_int32(block_domain, 1,
              "The unique domain for a distributed Quickstep instance.");
-static const bool block_domain_dummy
+static const volatile bool block_domain_dummy
     = gflags::RegisterFlagValidator(&FLAGS_block_domain, &ValidateBlockDomain);
 
 /**
  * @brief Set or validate the buffer pool slots. When automatically picking a
- *        default value, check if the system is "small" or "large." Set the 
+ *        default value, check if the system is "small" or "large." Set the
  *        buffer pool space to 80% of the installed main memory for small
- *        and 90% otherwise. 
+ *        and 90% otherwise.
  *        This method follows the signature that is set by the gflags module.
- * @param flagname The name of the buffer pool flag. 
+ * @param flagname The name of the buffer pool flag.
  * @param value The value of this flag from the command line, or default (0)
- * @return True if the value was set to a legimate value, false otherwise. 
+ * @return True if the value was set to a legimate value, false otherwise.
  *         Currently this method aims to always find some legitimate value,
  *         and never returns false.
  **/
@@ -149,7 +149,7 @@ DEFINE_uint64(buffer_pool_slots, 0,
               "the buffer pool may temporarily grow larger than this size "
               "if the buffer manager is unable to evict enough unreferenced "
               "blocks to make room for a new allocation.");
-static const bool buffer_pool_slots_dummy
+static const volatile bool buffer_pool_slots_dummy
     = gflags::RegisterFlagValidator(&FLAGS_buffer_pool_slots, &SetOrValidateBufferPoolSlots);
 
 #ifdef QUICKSTEP_HAVE_FILE_MANAGER_HDFS


[20/24] incubator-quickstep git commit: Added JOIN ... ON ... operator and tests. (#171)

Posted by zu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/parser/preprocessed/SqlParser_gen.cpp
----------------------------------------------------------------------
diff --git a/parser/preprocessed/SqlParser_gen.cpp b/parser/preprocessed/SqlParser_gen.cpp
index 7ebb01f..d625dc7 100644
--- a/parser/preprocessed/SqlParser_gen.cpp
+++ b/parser/preprocessed/SqlParser_gen.cpp
@@ -1,8 +1,8 @@
-/* A Bison parser, made by GNU Bison 3.0.2.  */
+/* A Bison parser, made by GNU Bison 3.0.4.  */
 
 /* Bison implementation for Yacc-like parsers in C
 
-   Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
+   Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -44,7 +44,7 @@
 #define YYBISON 1
 
 /* Bison version.  */
-#define YYBISON_VERSION "3.0.2"
+#define YYBISON_VERSION "3.0.4"
 
 /* Skeleton name.  */
 #define YYSKELETON_NAME "yacc.c"
@@ -112,6 +112,7 @@ typedef struct YYLTYPE {
 #include "parser/ParseGeneratorTableReference.hpp"
 #include "parser/ParseGroupBy.hpp"
 #include "parser/ParseHaving.hpp"
+#include "parser/ParseJoinedTableReference.hpp"
 #include "parser/ParseKeyValue.hpp"
 #include "parser/ParseLimit.hpp"
 #include "parser/ParseLiteralValue.hpp"
@@ -149,7 +150,7 @@ typedef struct YYLTYPE {
 // Needed for Bison 2.6 and higher, which do not automatically provide this typedef.
 typedef void* yyscan_t;
 
-#line 153 "SqlParser_gen.cpp" /* yacc.c:339  */
+#line 154 "SqlParser_gen.cpp" /* yacc.c:339  */
 
 # ifndef YY_NULLPTR
 #  if defined __cplusplus && 201103L <= __cplusplus
@@ -303,10 +304,10 @@ extern int quickstep_yydebug;
 
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-typedef union YYSTYPE YYSTYPE;
+
 union YYSTYPE
 {
-#line 117 "../SqlParser.ypp" /* yacc.c:355  */
+#line 118 "../SqlParser.ypp" /* yacc.c:355  */
 
   quickstep::ParseString *string_value_;
 
@@ -342,6 +343,8 @@ union YYSTYPE
   quickstep::PtrList<quickstep::ParseTableReference> *table_reference_list_;
   quickstep::ParseTableReferenceSignature *table_reference_signature_;
 
+  quickstep::ParseJoinedTableReference::JoinType join_type_;
+
   quickstep::ParseDataType *data_type_;
   quickstep::ParseAttributeDefinition *attribute_definition_;
   quickstep::ParseColumnConstraint *column_constraint_;
@@ -396,8 +399,10 @@ union YYSTYPE
   quickstep::PtrVector<quickstep::ParseSubqueryTableReference> *with_list_;
   quickstep::ParseSubqueryTableReference *with_list_element_;
 
-#line 400 "SqlParser_gen.cpp" /* yacc.c:355  */
+#line 403 "SqlParser_gen.cpp" /* yacc.c:355  */
 };
+
+typedef union YYSTYPE YYSTYPE;
 # define YYSTYPE_IS_TRIVIAL 1
 # define YYSTYPE_IS_DECLARED 1
 #endif
@@ -423,13 +428,13 @@ int quickstep_yyparse (yyscan_t yyscanner, quickstep::ParseStatement **parsedSta
 #endif /* !YY_QUICKSTEP_YY_SQLPARSER_GEN_HPP_INCLUDED  */
 
 /* Copy the second part of user declarations.  */
-#line 207 "../SqlParser.ypp" /* yacc.c:358  */
+#line 210 "../SqlParser.ypp" /* yacc.c:358  */
 
 /* This header needs YYSTYPE, which is defined by the %union directive above */
 #include "SqlLexer_gen.hpp"
 void NotSupported(const YYLTYPE *location, yyscan_t yyscanner, const std::string &feature);
 
-#line 433 "SqlParser_gen.cpp" /* yacc.c:358  */
+#line 438 "SqlParser_gen.cpp" /* yacc.c:358  */
 
 #ifdef short
 # undef short
@@ -673,16 +678,16 @@ union yyalloc
 /* YYFINAL -- State number of the termination state.  */
 #define YYFINAL  47
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   1147
+#define YYLAST   975
 
 /* YYNTOKENS -- Number of terminals.  */
 #define YYNTOKENS  128
 /* YYNNTS -- Number of nonterminals.  */
-#define YYNNTS  95
+#define YYNNTS  94
 /* YYNRULES -- Number of rules.  */
-#define YYNRULES  255
+#define YYNRULES  254
 /* YYNSTATES -- Number of states.  */
-#define YYNSTATES  497
+#define YYNSTATES  470
 
 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
    by yylex, with out-of-bounds checking.  */
@@ -740,32 +745,32 @@ static const yytype_uint8 yytranslate[] =
   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
 static const yytype_uint16 yyrline[] =
 {
-       0,   570,   570,   574,   578,   582,   586,   589,   596,   599,
-     602,   605,   608,   611,   614,   617,   620,   623,   629,   635,
-     642,   648,   655,   664,   669,   678,   683,   688,   692,   698,
-     703,   706,   709,   714,   717,   720,   723,   726,   729,   732,
-     735,   738,   741,   753,   756,   759,   777,   797,   800,   803,
-     808,   813,   819,   825,   834,   838,   844,   847,   852,   857,
-     862,   869,   876,   880,   886,   889,   894,   897,   902,   905,
-     910,   913,   932,   936,   942,   946,   952,   955,   958,   963,
-     966,   973,   978,   989,   994,   998,  1002,  1008,  1011,  1017,
-    1025,  1028,  1031,  1037,  1042,  1045,  1050,  1054,  1058,  1062,
-    1068,  1073,  1078,  1082,  1088,  1094,  1097,  1102,  1107,  1111,
-    1117,  1123,  1129,  1132,  1136,  1142,  1145,  1150,  1154,  1160,
-    1163,  1166,  1171,  1176,  1179,  1185,  1189,  1195,  1201,  1207,
-    1213,  1219,  1225,  1231,  1237,  1245,  1250,  1253,  1256,  1261,
-    1265,  1269,  1272,  1276,  1281,  1284,  1289,  1292,  1297,  1301,
-    1307,  1310,  1315,  1318,  1323,  1326,  1331,  1334,  1353,  1357,
-    1363,  1370,  1373,  1376,  1381,  1384,  1387,  1393,  1396,  1401,
-    1406,  1415,  1420,  1429,  1434,  1437,  1442,  1445,  1450,  1456,
-    1462,  1465,  1468,  1471,  1474,  1477,  1483,  1492,  1495,  1500,
-    1503,  1508,  1511,  1516,  1519,  1522,  1525,  1528,  1531,  1536,
-    1540,  1544,  1547,  1552,  1557,  1560,  1565,  1569,  1575,  1580,
-    1584,  1590,  1595,  1598,  1603,  1607,  1613,  1616,  1619,  1622,
-    1634,  1638,  1657,  1672,  1676,  1682,  1685,  1690,  1694,  1701,
-    1704,  1707,  1710,  1713,  1716,  1719,  1722,  1725,  1728,  1733,
-    1744,  1747,  1752,  1755,  1758,  1764,  1768,  1774,  1777,  1785,
-    1788,  1791,  1794,  1800,  1805,  1810
+       0,   575,   575,   579,   583,   587,   591,   594,   601,   604,
+     607,   610,   613,   616,   619,   622,   625,   628,   634,   640,
+     647,   653,   660,   669,   674,   683,   688,   693,   697,   703,
+     708,   711,   714,   719,   722,   725,   728,   731,   734,   737,
+     740,   743,   746,   758,   761,   764,   782,   802,   805,   808,
+     813,   818,   824,   830,   839,   843,   849,   852,   857,   862,
+     867,   874,   881,   885,   891,   894,   899,   902,   907,   910,
+     915,   918,   937,   941,   947,   951,   957,   960,   963,   968,
+     971,   978,   983,   994,   999,  1003,  1007,  1013,  1016,  1022,
+    1030,  1033,  1036,  1042,  1047,  1050,  1055,  1059,  1063,  1067,
+    1073,  1078,  1083,  1087,  1093,  1099,  1102,  1107,  1112,  1116,
+    1122,  1128,  1134,  1137,  1141,  1147,  1150,  1155,  1159,  1165,
+    1168,  1171,  1176,  1181,  1186,  1189,  1192,  1197,  1200,  1203,
+    1206,  1209,  1212,  1215,  1218,  1223,  1226,  1231,  1235,  1239,
+    1242,  1246,  1249,  1254,  1257,  1262,  1265,  1270,  1274,  1280,
+    1283,  1288,  1291,  1296,  1299,  1304,  1307,  1326,  1330,  1336,
+    1343,  1346,  1349,  1354,  1357,  1360,  1366,  1369,  1374,  1379,
+    1388,  1393,  1402,  1407,  1410,  1415,  1418,  1423,  1429,  1435,
+    1438,  1441,  1444,  1447,  1450,  1456,  1465,  1468,  1473,  1476,
+    1481,  1484,  1489,  1492,  1495,  1498,  1501,  1504,  1509,  1513,
+    1517,  1520,  1525,  1530,  1533,  1538,  1542,  1548,  1553,  1557,
+    1563,  1568,  1571,  1576,  1580,  1586,  1589,  1592,  1595,  1607,
+    1611,  1630,  1645,  1649,  1655,  1658,  1663,  1667,  1674,  1677,
+    1680,  1683,  1686,  1689,  1692,  1695,  1698,  1701,  1706,  1717,
+    1720,  1725,  1728,  1731,  1737,  1741,  1747,  1750,  1758,  1761,
+    1764,  1767,  1773,  1778,  1783
 };
 #endif
 
@@ -818,9 +823,9 @@ static const char *const yytname[] =
   "assignment_list", "assignment_item", "select_statement", "with_clause",
   "with_list", "with_list_element", "select_query", "opt_all_distinct",
   "selection", "selection_item_commalist", "selection_item", "from_clause",
-  "opt_join_chain", "join_chain", "join", "subquery_expression",
-  "opt_sample_clause", "table_reference", "table_reference_signature",
-  "table_reference_signature_primary", "table_reference_commalist",
+  "subquery_expression", "opt_sample_clause", "join_type",
+  "joined_table_reference", "table_reference", "table_reference_signature",
+  "table_reference_signature_primary", "joined_table_reference_commalist",
   "opt_group_by_clause", "opt_having_clause", "opt_order_by_clause",
   "opt_limit_clause", "order_commalist", "order_item",
   "opt_order_direction", "opt_nulls_first", "opt_where_clause",
@@ -858,12 +863,12 @@ static const yytype_uint16 yytoknum[] =
 };
 # endif
 
-#define YYPACT_NINF -209
+#define YYPACT_NINF -223
 
 #define yypact_value_is_default(Yystate) \
-  (!!((Yystate) == (-209)))
+  (!!((Yystate) == (-223)))
 
-#define YYTABLE_NINF -1
+#define YYTABLE_NINF -128
 
 #define yytable_value_is_error(Yytable_value) \
   0
@@ -872,56 +877,53 @@ static const yytype_uint16 yytoknum[] =
      STATE-NUM.  */
 static const yytype_int16 yypact[] =
 {
-     394,  -209,  -209,   -35,   190,    72,   133,   120,    53,  -209,
-      69,   190,   190,  -209,    94,   127,  -209,  -209,  -209,  -209,
-    -209,  -209,  -209,  -209,  -209,  -209,    91,  -209,   -34,   207,
-     190,  -209,  -209,   166,   190,   190,   190,   190,   190,  -209,
-    -209,   602,   134,   113,  -209,   235,   144,  -209,  -209,  -209,
-     197,  -209,  -209,  -209,  -209,    62,   289,   208,   176,   192,
-    -209,   137,  -209,  -209,   308,   321,  -209,  -209,  -209,   635,
-     206,  -209,   255,  -209,  -209,   210,  -209,  -209,   331,  -209,
-    -209,  -209,  -209,  -209,  -209,   214,   272,   844,   346,   285,
-     227,  -209,   236,    -2,  -209,  -209,  -209,  -209,  -209,  -209,
-    -209,   877,    41,   190,   190,   230,   190,   190,   123,   220,
-     237,   190,   190,   514,  -209,  -209,   233,   190,  -209,  -209,
-    -209,   514,    23,   -33,  -209,   349,  -209,   190,  -209,   352,
-    -209,     7,  -209,     9,   192,   844,  -209,  -209,   190,   844,
-    -209,  -209,  -209,  -209,   844,   321,  -209,   190,   426,   126,
-    -209,   350,  -209,   261,  -209,   146,  -209,   261,   190,     3,
-     190,   190,   239,  -209,   241,  -209,   148,   960,   723,   230,
-     514,   358,   359,  -209,  -209,  1075,   354,   965,   152,    15,
-     844,   -20,  -209,   844,  -209,   311,   247,   309,   254,  -209,
-      81,  -209,   105,    81,   -32,   312,  -209,  -209,    -2,  -209,
-    -209,   260,   844,  -209,   258,   156,   190,  -209,   844,   262,
-    -209,   190,  -209,  -209,   256,   303,   313,   265,  -209,  -209,
-    -209,   184,   190,   278,     3,   190,  -209,   118,  -209,  -209,
-       1,    37,   514,   514,    98,  -209,  -209,  -209,  -209,  -209,
-    -209,  -209,  -209,   844,   268,   844,    26,  -209,   165,   280,
-     844,    52,  -209,   337,   258,  -209,  -209,   844,  -209,   190,
-    -209,  -209,   116,   319,   190,   129,   132,     9,  -209,   106,
-    -209,  -209,   395,   399,    81,   361,   336,  -209,   167,  -209,
-     844,  -209,   258,  -209,  -209,   514,   284,   286,   190,   404,
-      88,   173,  -209,   177,   385,    27,  -209,   287,   296,  -209,
-     330,   292,   965,  -209,   338,   190,  -209,  -209,   118,  -209,
-    -209,   359,  -209,  -209,  -209,   844,   293,    55,   756,  -209,
-     258,   334,  -209,  -209,   965,   297,   258,   844,  -209,    39,
-    -209,   190,   341,   190,   -47,   190,   343,   190,   344,  -209,
-    -209,   332,   333,  -209,   844,   514,   339,  -209,   258,    10,
-     190,   190,   180,  -209,  -209,  -209,  -209,  -209,  -209,  -209,
-     209,  -209,   190,  -209,  -209,  -209,  -209,   305,     3,   391,
-     345,  -209,   514,  -209,  -209,   310,  -209,   232,   756,  -209,
-     844,   182,  -209,  -209,   965,   258,  -209,   -45,   190,   -25,
-     514,   -16,   190,    18,   190,  -209,  -209,   316,   358,   403,
-     356,  -209,   185,   187,  -209,   430,    88,  -209,   190,  -209,
-    -209,   320,   410,  -209,    16,   190,   844,   191,   258,  -209,
-     193,   514,    64,   514,   358,   514,    67,   514,    75,   844,
-     445,  -209,   355,  -209,  -209,  -209,   195,  -209,  -209,  -209,
-    -209,    13,   190,   121,  -209,   329,   258,  -209,  -209,   358,
-     514,   358,   358,   514,   358,   514,   340,  -209,   202,  -209,
-     190,  -209,   190,  -209,  -209,   190,  -209,   198,  -209,  -209,
-     347,  -209,   358,   358,   358,   844,  -209,  -209,   369,   348,
-    -209,   200,  -209,   190,  -209,   117,  -209,   190,  -209,   217,
-    -209,  -209,   219,   365,  -209,   455,  -209
+      63,  -223,  -223,   -56,   229,   -15,     4,   -51,    14,  -223,
+      36,   229,   229,  -223,    96,   124,  -223,  -223,  -223,  -223,
+    -223,  -223,  -223,  -223,  -223,  -223,    97,  -223,    48,   101,
+     229,  -223,  -223,   133,   229,   229,   229,   229,   229,  -223,
+    -223,   493,    23,    79,  -223,   199,    60,  -223,  -223,  -223,
+     179,  -223,  -223,  -223,  -223,    27,   260,   181,   165,   158,
+    -223,   123,  -223,  -223,   289,   293,  -223,  -223,  -223,   526,
+     178,  -223,   232,  -223,  -223,   180,  -223,  -223,   306,  -223,
+    -223,  -223,  -223,  -223,  -223,   188,   242,   735,   320,   273,
+     248,  -223,   221,    22,  -223,  -223,  -223,  -223,  -223,  -223,
+    -223,   768,    -5,   229,   229,   223,   229,   229,   115,   194,
+     237,   229,   229,   405,  -223,  -223,   234,   229,  -223,  -223,
+    -223,   405,    51,   -22,  -223,   377,  -223,   229,  -223,   378,
+    -223,     7,  -223,    21,   158,   735,  -223,  -223,   229,   735,
+    -223,  -223,  -223,  -223,   735,   293,  -223,   229,   272,   -64,
+    -223,   375,  -223,   287,  -223,   138,  -223,   287,   229,    58,
+     229,   229,   265,  -223,   266,  -223,   148,   851,   614,   223,
+     405,   384,   385,  -223,  -223,   349,   379,   856,   155,    16,
+     735,    -2,  -223,   735,  -223,   336,   276,   331,   277,  -223,
+      15,   195,   111,  -223,   278,   195,    52,   334,  -223,  -223,
+      22,  -223,  -223,   280,   735,  -223,   261,   161,   229,  -223,
+     735,   281,  -223,   229,  -223,  -223,   283,   328,   333,   290,
+    -223,  -223,  -223,   117,   229,   303,    58,   229,  -223,   151,
+    -223,  -223,     5,    64,   405,   405,    25,  -223,  -223,  -223,
+    -223,  -223,  -223,  -223,  -223,   735,   298,   735,    13,  -223,
+     166,   309,   735,    38,  -223,   358,   261,  -223,  -223,   735,
+    -223,   129,   229,  -223,  -223,   335,  -223,   338,   339,   345,
+      21,  -223,   423,   424,   195,   393,   364,  -223,   173,  -223,
+     735,  -223,   261,  -223,  -223,   405,   312,   316,   229,   436,
+      24,   182,  -223,   190,   415,   157,  -223,   317,   326,  -223,
+     360,   324,   856,  -223,   369,   229,  -223,  -223,   151,  -223,
+    -223,   385,  -223,  -223,  -223,   735,   327,   246,   647,  -223,
+     261,   365,  -223,  -223,   856,   340,   261,   735,  -223,    26,
+    -223,  -223,  -223,  -223,  -223,    21,   111,   366,   367,  -223,
+     735,   405,   368,  -223,   261,    12,   229,   229,   192,  -223,
+    -223,  -223,  -223,  -223,  -223,  -223,   153,  -223,   229,  -223,
+    -223,  -223,  -223,   341,    58,   422,   371,  -223,   405,  -223,
+    -223,   344,  -223,   250,   647,  -223,   735,   198,  -223,  -223,
+     856,   261,  -223,   381,  -223,  -223,   337,   384,   431,   389,
+    -223,   204,   207,  -223,   468,    24,  -223,   229,  -223,  -223,
+     350,   435,  -223,    30,   229,   735,   210,   261,  -223,   213,
+     405,   735,   469,  -223,   380,  -223,  -223,  -223,   225,  -223,
+    -223,  -223,  -223,    11,   229,   118,  -223,   352,   261,  -223,
+    -223,   384,   353,  -223,   186,  -223,   229,  -223,   229,  -223,
+    -223,   229,  -223,   227,  -223,  -223,   356,  -223,   735,  -223,
+    -223,   397,   361,  -223,   247,  -223,   229,  -223,   -13,  -223,
+     229,  -223,   252,  -223,  -223,   257,   392,  -223,   479,  -223
 };
 
   /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
@@ -929,327 +931,290 @@ static const yytype_int16 yypact[] =
      means the default is an error.  */
 static const yytype_uint8 yydefact[] =
 {
-       0,     6,   255,     0,     0,     0,     0,     0,     0,    18,
+       0,     6,   254,     0,     0,     0,     0,     0,     0,    18,
      112,     0,     0,     7,     0,     0,    15,     8,    10,    11,
-      13,    14,     9,    17,    12,    16,     0,   105,     0,   253,
-       0,   247,   248,     0,     0,     0,     0,     0,     0,   113,
-     114,     0,     0,   107,   108,     0,   146,     1,     3,     2,
-       0,   106,     5,     4,   254,     0,     0,     0,     0,   167,
-      25,     0,   220,   217,     0,   239,   115,    40,    29,     0,
+      13,    14,     9,    17,    12,    16,     0,   105,     0,   252,
+       0,   246,   247,     0,     0,     0,     0,     0,     0,   113,
+     114,     0,     0,   107,   108,     0,   145,     1,     3,     2,
+       0,   106,     5,     4,   253,     0,     0,     0,     0,   166,
+      25,     0,   219,   216,     0,   238,   115,    40,    29,     0,
        0,    30,    31,    34,    36,     0,    37,    39,     0,    41,
-     216,    35,    38,    32,    33,     0,     0,     0,     0,     0,
-     116,   117,   121,   188,   190,   192,   195,   196,   197,   194,
-     193,     0,   225,     0,     0,     0,     0,     0,     0,     0,
-      94,     0,     0,     0,   101,   168,     0,     0,    91,   218,
-     219,     0,     0,   212,   209,     0,    43,     0,   221,     0,
-      44,     0,   222,     0,   167,     0,   240,   241,     0,     0,
-     120,   243,   244,   242,     0,     0,   191,     0,     0,   167,
-     103,     0,   109,     0,   110,     0,   245,     0,     0,     0,
+     215,    35,    38,    32,    33,     0,     0,     0,     0,     0,
+     116,   117,   121,   187,   189,   191,   194,   195,   196,   193,
+     192,     0,   224,     0,     0,     0,     0,     0,     0,     0,
+      94,     0,     0,     0,   101,   167,     0,     0,    91,   217,
+     218,     0,     0,   211,   208,     0,    43,     0,   220,     0,
+      44,     0,   221,     0,   166,     0,   239,   240,     0,     0,
+     120,   242,   243,   241,     0,     0,   190,     0,     0,   166,
+     103,     0,   109,     0,   110,     0,   244,     0,     0,     0,
        0,     0,     0,    93,    66,    27,     0,     0,     0,     0,
-       0,   169,   171,   173,   175,     0,   193,     0,     0,     0,
-       0,   212,   206,     0,   210,     0,     0,     0,     0,   198,
-       0,   148,   123,   143,   136,   150,   118,   119,   187,   189,
-     226,     0,     0,   199,   214,     0,     0,   100,     0,     0,
-     147,     0,    92,    19,     0,     0,     0,     0,    20,    21,
-      22,     0,     0,     0,    64,     0,    42,    56,   174,   182,
-       0,     0,     0,     0,     0,   229,   231,   232,   233,   234,
-     230,   235,   237,     0,     0,     0,     0,   223,     0,     0,
-       0,     0,   207,     0,   213,   205,    45,     0,    46,     0,
-     139,   144,     0,     0,     0,     0,     0,     0,   122,   124,
-     126,   142,     0,     0,   141,     0,   152,   200,     0,   201,
-       0,   102,   104,   135,   246,     0,     0,     0,     0,     0,
-       0,     0,   227,     0,   225,     0,    63,    65,    68,    28,
+       0,   168,   170,   172,   174,     0,   192,     0,     0,     0,
+       0,   211,   205,     0,   209,     0,     0,     0,     0,   197,
+       0,     0,   147,   136,   122,   141,   124,   149,   118,   119,
+     186,   188,   225,     0,     0,   198,   213,     0,     0,   100,
+       0,     0,   146,     0,    92,    19,     0,     0,     0,     0,
+      20,    21,    22,     0,     0,     0,    64,     0,    42,    56,
+     173,   181,     0,     0,     0,     0,     0,   228,   230,   231,
+     232,   233,   229,   234,   236,     0,     0,     0,     0,   222,
+       0,     0,     0,     0,   206,     0,   212,   204,    45,     0,
+      46,   127,     0,   137,   143,   133,   128,   129,   131,     0,
+       0,   140,     0,     0,   139,     0,   151,   199,     0,   200,
+       0,   102,   104,   123,   245,     0,     0,     0,     0,     0,
+       0,     0,   226,     0,   224,     0,    63,    65,    68,    28,
        0,     0,     0,    47,     0,     0,    49,    55,    57,    26,
-     181,   170,   172,   236,   238,     0,     0,     0,     0,   183,
-     180,     0,   179,    90,     0,     0,   211,     0,   204,     0,
-     145,     0,     0,     0,     0,     0,     0,     0,     0,   149,
-     125,     0,     0,   140,     0,     0,   154,   202,   215,     0,
-       0,     0,     0,    96,   251,   252,   250,   249,    97,    95,
-       0,    67,     0,    83,    84,    85,    86,    87,     0,     0,
-      70,    48,     0,    51,    50,     0,    54,     0,     0,   185,
-       0,     0,   178,   224,     0,   208,   203,     0,     0,     0,
-       0,     0,     0,     0,     0,   137,   138,   151,   153,     0,
-     156,    61,     0,     0,    58,     0,     0,   228,     0,    24,
-      62,     0,     0,    23,     0,     0,     0,     0,   176,   184,
-       0,     0,     0,     0,   128,     0,     0,     0,     0,     0,
-       0,   111,     0,    59,    98,    99,     0,    74,    76,    77,
-      78,     0,     0,     0,    52,     0,   177,   186,    89,   134,
-       0,   127,   130,     0,   132,     0,   155,   158,   161,   157,
-       0,    88,     0,    82,    80,     0,    79,     0,    72,    73,
-       0,    53,   133,   129,   131,     0,   162,   163,   164,     0,
-      75,     0,    69,     0,   159,     0,   160,     0,    81,     0,
-     165,   166,     0,     0,    60,     0,    71
+     180,   169,   171,   235,   237,     0,     0,     0,     0,   182,
+     179,     0,   178,    90,     0,     0,   210,     0,   203,     0,
+     142,   144,   134,   130,   132,     0,   148,     0,     0,   138,
+       0,     0,   153,   201,   214,     0,     0,     0,     0,    96,
+     250,   251,   249,   248,    97,    95,     0,    67,     0,    83,
+      84,    85,    86,    87,     0,     0,    70,    48,     0,    51,
+      50,     0,    54,     0,     0,   184,     0,     0,   177,   223,
+       0,   207,   202,     0,   125,   126,   150,   152,     0,   155,
+      61,     0,     0,    58,     0,     0,   227,     0,    24,    62,
+       0,     0,    23,     0,     0,     0,     0,   175,   183,     0,
+       0,     0,     0,   111,     0,    59,    98,    99,     0,    74,
+      76,    77,    78,     0,     0,     0,    52,     0,   176,   185,
+      89,   135,   154,   157,   160,   156,     0,    88,     0,    82,
+      80,     0,    79,     0,    72,    73,     0,    53,     0,   161,
+     162,   163,     0,    75,     0,    69,     0,   158,     0,   159,
+       0,    81,     0,   164,   165,     0,     0,    60,     0,    71
 };
 
   /* YYPGOTO[NTERM-NUM].  */
 static const yytype_int16 yypgoto[] =
 {
-    -209,  -209,  -209,  -209,  -209,  -209,  -209,  -209,  -121,  -209,
-     298,   155,  -209,  -209,  -208,  -209,  -209,  -209,  -209,  -209,
-    -209,    22,     8,  -209,  -209,  -209,  -209,  -209,  -209,  -209,
-    -209,  -209,  -209,  -209,  -209,   267,  -209,  -209,  -209,   373,
-      14,  -209,  -209,  -209,   351,  -209,  -209,  -209,   211,  -102,
-    -209,   218,  -183,   -11,  -209,  -209,  -209,  -209,  -209,  -209,
-      12,  -209,  -209,   -54,  -209,   -50,   246,   251,   322,   -30,
-     353,   357,   392,  -129,  -209,  -209,  -209,   315,  -209,   371,
-     317,  -196,  -175,   115,   -86,  -209,  -209,  -209,  -209,  -209,
-    -105,    -4,    99,  -209,  -209
+    -223,  -223,  -223,  -223,  -223,  -223,  -223,  -223,  -121,  -223,
+     321,   183,  -223,  -223,  -222,  -223,  -223,  -223,  -223,  -223,
+    -223,    68,    49,  -223,  -223,  -223,  -223,  -223,  -223,  -223,
+    -223,  -223,  -223,  -223,  -223,   285,  -223,  -223,  -223,   390,
+       9,  -223,  -223,  -223,   370,  -223,  -100,  -223,  -223,  -149,
+     160,  -143,    -9,  -223,  -223,  -223,  -223,  -223,  -223,    53,
+    -223,  -223,   107,  -223,  -120,   262,   268,   342,   -30,   372,
+     362,   403,  -123,  -223,  -223,  -223,   347,  -223,   394,   355,
+    -192,  -161,   127,  -107,  -223,  -223,  -223,  -223,  -223,  -115,
+      -4,   113,  -223,  -223
 };
 
   /* YYDEFGOTO[NTERM-NUM].  */
 static const yytype_int16 yydefgoto[] =
 {
       -1,    14,    15,    16,    17,    18,    19,    20,   165,   166,
-      88,   307,   308,   309,   218,   297,   298,   223,   370,   413,
-     470,   436,   437,   438,   439,   440,   367,   409,    21,    22,
+      88,   307,   308,   309,   220,   297,   298,   225,   366,   402,
+     446,   418,   419,   420,   421,   422,   363,   398,    21,    22,
      163,   291,    23,    24,   149,   150,    25,    26,    43,    44,
-     209,    41,    89,    90,    91,   134,   268,   269,   270,   190,
-     274,   191,   260,   261,   192,   276,   346,   400,   431,   456,
-     457,   478,   486,   114,   115,   171,   172,   173,   174,   175,
-      93,    94,    95,    96,    97,    98,   181,   182,   123,   124,
-     185,   205,    99,   248,   100,   293,   245,   101,   139,   144,
-     155,   102,   358,    28,    29
+     211,    41,    89,    90,    91,   134,   191,   274,   269,   192,
+     193,   263,   264,   194,   276,   342,   389,   413,   432,   433,
+     451,   459,   114,   115,   171,   172,   173,   174,   175,    93,
+      94,    95,    96,    97,    98,   181,   182,   123,   124,   185,
+     207,    99,   250,   100,   293,   247,   101,   139,   144,   155,
+     102,   354,    28,    29
 };
 
   /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
      positive, shift that token.  If negative, reduce the rule whose
      number is the opposite.  If YYTABLE_NINF, syntax error.  */
-static const yytype_uint16 yytable[] =
+static const yytype_int16 yytable[] =
 {
-      33,    45,   247,   154,   193,   272,   278,    42,    46,   232,
-     271,    92,   178,    31,    27,    32,   296,    31,   232,    32,
-     463,   141,   142,   232,   232,   183,    55,   176,   136,   137,
-      57,    58,    59,    60,    61,   176,   321,   213,   183,   122,
-      51,   390,   464,   421,   136,   137,   214,   234,   235,   236,
-     237,   238,   239,   240,   241,   242,   243,   131,   136,   137,
-     136,   137,   363,   423,   380,   364,   365,   229,   147,   215,
-      30,   179,   425,   136,   137,   118,   136,   137,   273,   211,
-     195,   211,   176,   121,   176,    31,    52,    32,   140,    53,
-     108,   343,   148,    45,    47,   207,   180,   216,    39,   151,
-      46,   211,   156,   157,   299,    92,   427,   164,   167,   244,
-     211,   322,   259,   156,   217,   313,   314,   315,   204,   109,
-     230,   250,   381,   187,    40,   143,   310,   373,   300,   194,
-     366,    38,   189,   153,   197,   401,   292,   465,   193,   180,
-     231,   444,   319,   200,   211,    34,   176,   176,   397,   383,
-     251,   354,   450,   254,   167,   453,   219,   220,   327,   334,
-     410,   301,   189,   455,   386,   148,    50,   158,   159,   302,
-     316,   212,   204,   262,   262,   355,   356,    35,   282,   263,
-     263,   490,   417,   352,   264,   264,    46,   265,   265,    46,
-     211,   468,    10,   211,    31,   331,    32,   357,   491,   176,
-      36,   211,   151,   303,   266,   266,   332,   284,   335,   247,
-      54,   337,   304,   317,   379,   320,   305,   469,   294,   336,
-     326,   167,   338,   136,   137,    37,   387,   329,   389,   306,
-     391,   267,   393,    56,   476,   349,   103,   289,    10,   104,
-      31,   416,    32,   113,   290,   402,   403,    48,   330,    49,
-     348,   116,   206,   136,   137,    46,   477,   136,   137,   176,
-     156,   117,   405,   194,   160,   161,   105,   138,   106,   406,
-      46,   210,   211,   224,   225,   107,   407,   249,   211,   136,
-     137,   279,   280,   422,   156,   377,   176,   426,   204,   428,
-     323,   324,   347,   280,   110,   398,   111,   385,   359,   360,
-     112,   375,   361,   362,   176,   404,   211,   419,   280,   113,
-     432,   211,   433,   211,   204,   119,   447,   280,   448,   324,
-     461,   462,   414,   482,   462,   488,   211,   156,   120,   156,
-     125,   156,   126,   156,   127,   176,   128,   176,   129,   176,
-     424,   176,   493,   211,   494,   211,   156,   156,   204,   130,
-     418,   132,   133,   135,   153,   162,   186,   177,   294,   188,
-     481,   208,    10,   221,   176,   222,   232,   176,   233,   176,
-     255,   449,   256,   451,   246,   452,   257,   454,   489,   258,
-     285,   275,   492,   286,   156,   277,   446,   283,   156,   288,
-     156,   295,   318,   287,   325,     1,   328,     2,   333,   458,
-     472,   344,   341,   473,   441,   474,   342,   345,   350,   353,
-     351,   445,   147,   368,   369,   371,   372,   378,   374,   382,
-     388,   384,   392,   394,     3,   395,   396,   411,   399,   408,
-      31,    62,    32,    63,   415,   434,   412,   466,   441,   430,
-       4,     5,   280,   429,   442,   458,     6,    64,    65,   201,
-     443,     7,   459,   460,   471,   485,   479,   495,   441,    67,
-      68,   156,   496,   376,   467,   227,   475,    69,    70,     8,
-     480,   483,   487,   281,    71,    72,    73,   152,   311,   156,
-     340,   202,    74,   156,   312,   339,   196,   484,    75,     9,
-     228,    76,   198,   146,   184,    10,   252,     0,   253,   420,
-       0,   199,    77,    78,     0,   435,    11,     0,     0,     0,
-      79,    80,    12,     0,    13,     0,     0,     0,    31,    62,
-      32,    63,     0,    81,   168,     0,     0,     0,     0,     0,
-      82,     0,     0,    83,    84,    64,    65,     0,     0,     0,
-       0,    85,     0,     0,     0,    86,     0,    67,    68,     0,
-      87,   203,     0,     0,     0,    69,    70,     0,     0,     0,
-       0,     0,    71,    72,    73,     0,     0,     0,     0,     0,
-      74,     0,     0,     0,     0,   169,    75,     0,     0,    76,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-      77,    78,     0,     0,     0,     0,     0,     0,    79,    80,
-       0,     0,     0,     0,     0,     0,    31,    62,    32,    63,
-       0,    81,     0,     0,     0,     0,     0,     0,    82,     0,
-       0,    83,    84,    64,    65,    66,     0,     0,     0,    85,
-       0,     0,     0,    86,     0,    67,    68,     0,   170,    31,
-      62,    32,    63,    69,    70,     0,     0,     0,     0,     0,
-      71,    72,    73,     0,     0,     0,    64,    65,    74,     0,
-       0,     0,     0,     0,    75,     0,     0,    76,    67,    68,
-       0,     0,     0,     0,     0,     0,    69,    70,    77,    78,
-       0,     0,     0,    71,    72,    73,    79,    80,     0,     0,
-       0,    74,     0,     0,     0,     0,     0,    75,     0,    81,
-      76,     0,     0,     0,     0,     0,    82,     0,     0,    83,
-      84,    77,    78,     0,     0,     0,     0,    85,     0,    79,
-      80,    86,     0,     0,     0,     0,    87,    31,    62,    32,
-      63,     0,    81,     0,     0,     0,     0,     0,     0,    82,
-       0,     0,    83,    84,    64,    65,     0,     0,     0,     0,
-      85,   121,     0,     0,    86,     0,    67,    68,     0,    87,
-      31,    62,    32,    63,    69,    70,     0,     0,     0,     0,
+      33,   179,   178,    45,   296,   154,   176,    42,    46,    27,
+     195,    92,   278,   234,   176,    31,   249,    32,   439,    31,
+     234,    32,   147,   321,   234,    31,    55,    32,   136,   137,
+      57,    58,    59,    60,    61,    51,   183,   215,   234,   122,
+     440,   261,   313,   314,   315,   141,   142,   136,   137,    30,
+     232,   463,   271,   113,    37,   108,   183,   131,    34,   136,
+     137,   176,   208,   176,     1,    39,     2,   195,   464,   231,
+     118,    36,   136,   137,   236,   237,   238,   239,   240,   241,
+     242,   243,   244,   245,   109,   136,   137,   350,   140,   272,
+      35,    40,    38,     3,   121,    45,    47,   316,   322,   151,
+      46,   216,   156,   157,    54,    92,   299,   164,   167,     4,
+       5,   351,   352,   156,   180,     6,    10,   292,   206,   148,
+       7,   336,   252,   187,   217,   103,   377,   176,   176,   196,
+     310,   339,   189,   353,   199,   441,   246,   390,     8,   190,
+     233,   369,   399,   202,   327,   190,   319,   195,   386,   143,
+     253,   382,   218,   256,   167,   426,   221,   222,     9,   158,
+     159,   300,   273,   379,    10,   345,   214,   180,    52,   219,
+     289,    53,    50,   348,   206,    11,   148,   290,   176,   265,
+     282,    12,   406,    13,   106,   266,   196,    46,   444,   189,
+    -127,    46,   359,   267,   301,   360,   361,   265,    10,    31,
+      56,    32,   302,   266,   151,   104,   394,   136,   137,   284,
+     268,   267,   195,   395,   445,   317,   375,   320,   449,   249,
+     294,   387,   326,   167,    10,    31,   262,    32,   268,   329,
+     105,   391,   392,    31,   176,    32,   303,   116,   160,   161,
+     450,   197,   136,   137,    48,   304,    49,   117,   403,   305,
+     344,   396,   138,   331,   330,   376,   209,   107,    46,   405,
+     362,   176,   306,   212,   213,   110,   196,   136,   137,   111,
+      46,   136,   137,   226,   227,   113,    31,    62,    32,    63,
+     251,   213,   136,   137,   156,   373,   279,   280,   206,   112,
+     431,   323,   324,    64,    65,   203,   119,   381,   343,   280,
+     120,   371,   125,   176,   127,    67,    68,   355,   356,   126,
+     206,   128,   129,    69,    70,   357,   358,   393,   213,   130,
+      71,    72,    73,   408,   280,   132,   454,   204,    74,   414,
+     213,   196,   415,   213,    75,   429,   280,    76,   430,   324,
+     133,   462,   156,   156,   206,   465,   407,   153,    77,    78,
+     437,   438,   455,   438,   294,   162,    79,    80,   177,   236,
+     237,   238,   239,   240,   241,   242,   243,   244,   245,    81,
+     136,   137,   461,   213,   135,   428,    82,   466,   213,    83,
+      84,   434,   467,   213,   186,   188,   210,    85,    10,   223,
+     224,    86,   234,   423,   235,   257,    87,   205,   259,   248,
+     427,   258,   260,   275,   270,   277,   283,   285,   286,    31,
+      62,    32,    63,   287,   288,   168,   295,   328,   434,   442,
+     423,   246,   318,   325,   335,   332,    64,    65,   333,   334,
+     337,   338,   452,   340,   423,   341,   346,   156,    67,    68,
+     347,   349,   147,   364,   365,   367,    69,    70,   368,   370,
+     378,   374,   156,    71,    72,    73,   156,   388,   400,   384,
+     385,    74,   401,   280,   380,   397,   169,    75,   404,   410,
+      76,   411,   412,   416,   424,   425,   435,   447,   436,   448,
+     456,    77,    78,   458,   468,   460,   469,   453,   229,    79,
+      80,   372,   443,   281,   152,   383,   311,    31,    62,    32,
+      63,   457,    81,   312,   146,   198,   201,   409,   417,    82,
+     230,   200,    83,    84,    64,    65,    66,   184,     0,     0,
+      85,     0,     0,     0,    86,     0,    67,    68,   254,   170,
+      31,    62,    32,    63,    69,    70,   255,     0,     0,     0,
        0,    71,    72,    73,     0,     0,     0,    64,    65,    74,
-       0,     0,     0,     0,   169,    75,     0,     0,    76,    67,
+       0,     0,     0,     0,     0,    75,     0,     0,    76,    67,
       68,     0,     0,     0,     0,     0,     0,    69,    70,    77,
       78,     0,     0,     0,    71,    72,    73,    79,    80,     0,
        0,     0,    74,     0,     0,     0,     0,     0,    75,     0,
       81,    76,     0,     0,     0,     0,     0,    82,     0,     0,
       83,    84,    77,    78,     0,     0,     0,     0,    85,     0,
-      79,    80,    86,     0,     0,     0,     0,   170,    31,    62,
-      32,    63,     0,    81,     0,     0,     0,    10,     0,     0,
+      79,    80,    86,     0,     0,     0,     0,    87,    31,    62,
+      32,    63,     0,    81,     0,     0,     0,     0,     0,     0,
       82,     0,     0,    83,    84,    64,    65,     0,     0,     0,
-       0,    85,     0,     0,     0,    86,     0,    67,    68,     0,
+       0,    85,   121,     0,     0,    86,     0,    67,    68,     0,
       87,    31,    62,    32,    63,    69,    70,     0,     0,     0,
-       0,     0,    71,    72,    73,     0,     0,     0,    64,   145,
-      74,     0,     0,     0,     0,     0,    75,     0,     0,    76,
+       0,     0,    71,    72,    73,     0,     0,     0,    64,    65,
+      74,     0,     0,     0,     0,   169,    75,     0,     0,    76,
       67,    68,     0,     0,     0,     0,     0,     0,    69,    70,
       77,    78,     0,     0,     0,    71,    72,    73,    79,    80,
        0,     0,     0,    74,     0,     0,     0,     0,     0,    75,
        0,    81,    76,     0,     0,     0,     0,     0,    82,     0,
        0,    83,    84,    77,    78,     0,     0,     0,     0,    85,
-       0,    79,    80,    86,     0,     0,     0,     0,    87,     0,
-      62,     0,    63,     0,    81,     0,     0,     0,     0,     0,
-       0,    82,     0,     0,    83,    84,    64,   145,     0,     0,
-       0,     0,    85,    67,    68,     0,    86,     0,    67,    68,
-       0,    87,    70,     0,     0,     0,     0,    70,    71,    72,
-      73,     0,     0,    71,    72,    73,    74,     0,     0,     0,
-       0,    74,     0,     0,     0,    76,     0,     0,     0,     0,
-      76,     0,     0,     0,     0,     0,    77,   226,     0,     0,
-       0,    77,    78,     0,    79,     0,     0,     0,     0,    79,
-      80,     0,     0,     0,     0,     0,     0,    81,     0,     0,
-       0,     0,    81,     0,    82,     0,     0,    83,    84,    82,
-       0,     0,    83,    84,     0,    85,     0,     0,     0,    86,
-      85,     0,     0,     0,    86,   234,   235,   236,   237,   238,
-     239,   240,   241,   242,   243,     0,   136,   137,     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,   244
+       0,    79,    80,    86,     0,     0,     0,     0,   170,    31,
+      62,    32,    63,     0,    81,     0,     0,     0,    10,     0,
+       0,    82,     0,     0,    83,    84,    64,    65,     0,     0,
+       0,     0,    85,     0,     0,     0,    86,     0,    67,    68,
+       0,    87,    31,    62,    32,    63,    69,    70,     0,     0,
+       0,     0,     0,    71,    72,    73,     0,     0,     0,    64,
+     145,    74,     0,     0,     0,     0,     0,    75,     0,     0,
+      76,    67,    68,     0,     0,     0,     0,     0,     0,    69,
+      70,    77,    78,     0,     0,     0,    71,    72,    73,    79,
+      80,     0,     0,     0,    74,     0,     0,     0,     0,     0,
+      75,     0,    81,    76,     0,     0,     0,     0,     0,    82,
+       0,     0,    83,    84,    77,    78,     0,     0,     0,     0,
+      85,     0,    79,    80,    86,     0,     0,     0,     0,    87,
+       0,    62,     0,    63,     0,    81,     0,     0,     0,     0,
+       0,     0,    82,     0,     0,    83,    84,    64,   145,     0,
+       0,     0,     0,    85,    67,    68,     0,    86,     0,    67,
+      68,     0,    87,    70,     0,     0,     0,     0,    70,    71,
+      72,    73,     0,     0,    71,    72,    73,    74,     0,     0,
+       0,     0,    74,     0,     0,     0,    76,     0,     0,     0,
+       0,    76,     0,     0,     0,     0,     0,    77,   228,     0,
+       0,     0,    77,    78,     0,    79,     0,     0,     0,     0,
+      79,    80,     0,     0,     0,     0,     0,     0,    81,     0,
+       0,     0,     0,    81,     0,    82,     0,     0,    83,    84,
+      82,     0,     0,    83,    84,     0,    85,     0,     0,     0,
+      86,    85,     0,     0,     0,    86
 };
 
 static const yytype_int16 yycheck[] =
 {
-       4,    12,   177,   105,   133,    37,   202,    11,    12,     8,
-     193,    41,   117,     4,     0,     6,   224,     4,     8,     6,
-       7,    23,    24,     8,     8,    58,    30,   113,    21,    22,
-      34,    35,    36,    37,    38,   121,    10,   158,    58,    69,
-      26,    88,    29,    88,    21,    22,    43,    10,    11,    12,
-      13,    14,    15,    16,    17,    18,    19,    87,    21,    22,
-      21,    22,    35,    88,     9,    38,    39,   169,    27,    66,
-     105,   121,    88,    21,    22,    61,    21,    22,   110,   126,
-     134,   126,   168,   116,   170,     4,   120,     6,    92,   123,
-      28,   274,   124,   104,     0,   149,   116,    94,    29,   103,
-     104,   126,   106,   107,   225,   135,    88,   111,   112,    72,
-     126,    85,    31,   117,   111,    17,    18,    19,   148,    57,
-     170,   106,   318,   127,    55,   127,   125,   302,    10,   133,
-     103,    78,   125,   124,   138,   125,   222,   124,   267,   116,
-     170,   125,   244,   147,   126,    73,   232,   233,   344,   324,
-     180,    63,    88,   183,   158,    88,   160,   161,   106,   264,
-     368,    43,   125,    88,   125,   124,    75,    44,    45,    51,
-      72,   157,   202,    68,    68,    87,    88,   105,   208,    74,
-      74,    64,   378,   288,    79,    79,   190,    82,    82,   193,
-     126,    70,   101,   126,     4,    79,     6,   109,    81,   285,
-      67,   126,   206,    85,    99,    99,    90,   211,    79,   384,
-       3,    79,    94,   243,   316,   245,    98,    96,   222,    90,
-     250,   225,    90,    21,    22,   105,   331,   257,   333,   111,
-     335,   126,   337,    67,    32,   285,   102,    53,   101,   126,
-       4,     9,     6,   117,    60,   350,   351,   120,   259,   122,
-     280,   114,   126,    21,    22,   259,    54,    21,    22,   345,
-     264,   124,    53,   267,    44,    45,    31,    31,   124,    60,
-     274,   125,   126,   125,   126,    78,   362,   125,   126,    21,
-      22,   125,   126,   388,   288,   315,   372,   392,   318,   394,
-     125,   126,   125,   126,     5,   345,    88,   327,   125,   126,
-     124,   305,   125,   126,   390,   125,   126,   125,   126,   117,
-     125,   126,   125,   126,   344,     7,   125,   126,   125,   126,
-     125,   126,   372,   125,   126,   125,   126,   331,     7,   333,
-     124,   335,    77,   337,   124,   421,     5,   423,   124,   425,
-     390,   427,   125,   126,   125,   126,   350,   351,   378,    77,
-     380,     5,    67,   126,   124,   118,     7,   124,   362,     7,
-     465,    11,   101,   124,   450,   124,     8,   453,     9,   455,
-      59,   421,   125,   423,    20,   425,    67,   427,   483,   125,
-     124,    69,   487,    80,   388,   125,   416,   125,   392,   124,
-     394,   113,   124,    80,   114,     1,    59,     3,    79,   429,
-     450,    40,     7,   453,   408,   455,     7,    71,   124,     5,
-     124,   415,    27,   126,   118,    85,   124,   124,    80,    85,
-      79,   124,    79,    79,    30,    93,    93,    36,    89,   124,
-       4,     5,     6,     7,   124,     5,    91,   441,   442,    83,
-      46,    47,   126,    40,   124,   475,    52,    21,    22,    23,
-      40,    57,     7,    98,   125,    86,   460,    92,   462,    33,
-      34,   465,     7,   308,   442,   167,   126,    41,    42,    75,
-     462,   124,   124,   206,    48,    49,    50,   104,   232,   483,
-     269,    55,    56,   487,   233,   267,   135,   475,    62,    95,
-     168,    65,   139,   101,   123,   101,   181,    -1,   181,   384,
-      -1,   144,    76,    77,    -1,   406,   112,    -1,    -1,    -1,
-      84,    85,   118,    -1,   120,    -1,    -1,    -1,     4,     5,
-       6,     7,    -1,    97,    10,    -1,    -1,    -1,    -1,    -1,
-     104,    -1,    -1,   107,   108,    21,    22,    -1,    -1,    -1,
-      -1,   115,    -1,    -1,    -1,   119,    -1,    33,    34,    -1,
-     124,   125,    -1,    -1,    -1,    41,    42,    -1,    -1,    -1,
-      -1,    -1,    48,    49,    50,    -1,    -1,    -1,    -1,    -1,
-      56,    -1,    -1,    -1,    -1,    61,    62,    -1,    -1,    65,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      76,    77,    -1,    -1,    -1,    -1,    -1,    -1,    84,    85,
-      -1,    -1,    -1,    -1,    -1,    -1,     4,     5,     6,     7,
-      -1,    97,    -1,    -1,    -1,    -1,    -1,    -1,   104,    -1,
-      -1,   107,   108,    21,    22,    23,    -1,    -1,    -1,   115,
-      -1,    -1,    -1,   119,    -1,    33,    34,    -1,   124,     4,
-       5,     6,     7,    41,    42,    -1,    -1,    -1,    -1,    -1,
-      48,    49,    50,    -1,    -1,    -1,    21,    22,    56,    -1,
-      -1,    -1,    -1,    -1,    62,    -1,    -1,    65,    33,    34,
-      -1,    -1,    -1,    -1,    -1,    -1,    41,    42,    76,    77,
-      -1,    -1,    -1,    48,    49,    50,    84,    85,    -1,    -1,
-      -1,    56,    -1,    -1,    -1,    -1,    -1,    62,    -1,    97,
-      65,    -1,    -1,    -1,    -1,    -1,   104,    -1,    -1,   107,
-     108,    76,    77,    -1,    -1,    -1,    -1,   115,    -1,    84,
-      85,   119,    -1,    -1,    -1,    -1,   124,     4,     5,     6,
-       7,    -1,    97,    -1,    -1,    -1,    -1,    -1,    -1,   104,
-      -1,    -1,   107,   108,    21,    22,    -1,    -1,    -1,    -1,
-     115,   116,    -1,    -1,   119,    -1,    33,    34,    -1,   124,
-       4,     5,     6,     7,    41,    42,    -1,    -1,    -1,    -1,
+       4,   121,   117,    12,   226,   105,   113,    11,    12,     0,
+     133,    41,   204,     8,   121,     4,   177,     6,     7,     4,
+       8,     6,    27,    10,     8,     4,    30,     6,    21,    22,
+      34,    35,    36,    37,    38,    26,    58,   158,     8,    69,
+      29,   190,    17,    18,    19,    23,    24,    21,    22,   105,
+     170,    64,   195,   117,   105,    28,    58,    87,    73,    21,
+      22,   168,   126,   170,     1,    29,     3,   190,    81,   169,
+      61,    67,    21,    22,    10,    11,    12,    13,    14,    15,
+      16,    17,    18,    19,    57,    21,    22,    63,    92,    37,
+     105,    55,    78,    30,   116,   104,     0,    72,    85,   103,
+     104,    43,   106,   107,     3,   135,   227,   111,   112,    46,
+      47,    87,    88,   117,   116,    52,   101,   224,   148,   124,
+      57,   270,   106,   127,    66,   102,   318,   234,   235,   133,
+     125,   274,   125,   109,   138,   124,    72,   125,    75,   124,
+     170,   302,   364,   147,   106,   124,   246,   270,   340,   127,
+     180,   125,    94,   183,   158,   125,   160,   161,    95,    44,
+      45,    10,   110,   324,   101,   285,   157,   116,   120,   111,
+      53,   123,    75,   288,   204,   112,   124,    60,   285,    68,
+     210,   118,   374,   120,   124,    74,   190,   191,    70,   125,
+      79,   195,    35,    82,    43,    38,    39,    68,   101,     4,
+      67,     6,    51,    74,   208,   126,    53,    21,    22,   213,
+      99,    82,   335,    60,    96,   245,   316,   247,    32,   380,
+     224,   341,   252,   227,   101,     4,    31,     6,    99,   259,
+      31,   346,   347,     4,   341,     6,    85,   114,    44,    45,
+      54,   134,    21,    22,   120,    94,   122,   124,   368,    98,
+     280,   358,    31,   262,   125,     9,   149,    78,   262,     9,
+     103,   368,   111,   125,   126,     5,   270,    21,    22,    88,
+     274,    21,    22,   125,   126,   117,     4,     5,     6,     7,
+     125,   126,    21,    22,   288,   315,   125,   126,   318,   124,
+     410,   125,   126,    21,    22,    23,     7,   327,   125,   126,
+       7,   305,   124,   410,   124,    33,    34,   125,   126,    77,
+     340,     5,   124,    41,    42,   125,   126,   125,   126,    77,
+      48,    49,    50,   125,   126,     5,   441,    55,    56,   125,
+     126,   335,   125,   126,    62,   125,   126,    65,   125,   126,
+      67,   456,   346,   347,   374,   460,   376,   124,    76,    77,
+     125,   126,   125,   126,   358,   118,    84,    85,   124,    10,
+      11,    12,    13,    14,    15,    16,    17,    18,    19,    97,
+      21,    22,   125,   126,   126,   405,   104,   125,   126,   107,
+     108,   411,   125,   126,     7,     7,    11,   115,   101,   124,
+     124,   119,     8,   397,     9,    59,   124,   125,    67,    20,
+     404,   125,   125,    69,   126,   125,   125,   124,    80,     4,
+       5,     6,     7,    80,   124,    10,   113,    59,   448,   423,
+     424,    72,   124,   114,    79,    90,    21,    22,    90,    90,
+       7,     7,   436,    40,   438,    71,   124,   441,    33,    34,
+     124,     5,    27,   126,   118,    85,    41,    42,   124,    80,
+      85,   124,   456,    48,    49,    50,   460,    89,    36,    93,
+      93,    56,    91,   126,   124,   124,    61,    62,   124,    88,
+      65,    40,    83,     5,   124,    40,     7,   125,    98,   126,
+     124,    76,    77,    86,    92,   124,     7,   438,   167,    84,
+      85,   308,   424,   208,   104,   335,   234,     4,     5,     6,
+       7,   448,    97,   235,   101,   135,   144,   380,   395,   104,
+     168,   139,   107,   108,    21,    22,    23,   123,    -1,    -1,
+     115,    -1,    -1,    -1,   119,    -1,    33,    34,   181,   124,
+       4,     5,     6,     7,    41,    42,   181,    -1,    -1,    -1,
       -1,    48,    49,    50,    -1,    -1,    -1,    21,    22,    56,
-      -1,    -1,    -1,    -1,    61,    62,    -1,    -1,    65,    33,
+      -1,    -1,    -1,    -1,    -1,    62,    -1,    -1,    65,    33,
       34,    -1,    -1,    -1,    -1,    -1,    -1,    41,    42,    76,
       77,    -1,    -1,    -1,    48,    49,    50,    84,    85,    -1,
       -1,    -1,    56,    -1,    -1,    -1,    -1,    -1,    62,    -1,
       97,    65,    -1,    -1,    -1,    -1,    -1,   104,    -1,    -1,
      107,   108,    76,    77,    -1,    -1,    -1,    -1,   115,    -1,
       84,    85,   119,    -1,    -1,    -1,    -1,   124,     4,     5,
-       6,     7,    -1,    97,    -1,    -1,    -1,   101,    -1,    -1,
+       6,     7,    -1,    97,    -1,    -1,    -1,    -1,    -1,    -1,
      104,    -1,    -1,   107,   108,    21,    22,    -1,    -1,    -1,
-      -1,   115,    -1,    -1,    -1,   119,    -1,    33,    34,    -1,
+      -1,   115,   116,    -1,    -1,   119,    -1,    33,    34,    -1,
      124,     4,     5,     6,     7,    41,    42,    -1,    -1,    -1,
       -1,    -1,    48,    49,    50,    -1,    -1,    -1,    21,    22,
-      56,    -1,    -1,    -1,    -1,    -1,    62,    -1,    -1,    65,
+      56,    -1,    -1,    -1,    -1,    61,    62,    -1,    -1,    65,
       33,    34,    -1,    -1,    -1,    -1,    -1,    -1,    41,    42,
       76,    77,    -1,    -1,    -1,    48,    49,    50,    84,    85,
       -1,    -1,    -1,    56,    -1,    -1,    -1,    -1,    -1,    62,
       -1,    97,    65,    -1,    -1,    -1,    -1,    -1,   104,    -1,
       -1,   107,   108,    76,    77,    -1,    -1,    -1,    -1,   115,
-      -1,    84,    85,   119,    -1,    -1,    -1,    -1,   124,    -1,
-       5,    -1,     7,    -1,    97,    -1,    -1,    -1,    -1,    -1,
+      -1,    84,    85,   119,    -1,    -1,    -1,    -1,   124,     4,
+       5,     6,     7,    -1,    97,    -1,    -1,    -1,   101,    -1,
       -1,   104,    -1,    -1,   107,   108,    21,    22,    -1,    -1,
-      -1,    -1,   115,    33,    34,    -1,   119,    -1,    33,    34,
-      -1,   124,    42,    -1,    -1,    -1,    -1,    42,    48,    49,
-      50,    -1,    -1,    48,    49,    50,    56,    -1,    -1,    -1,
-      -1,    56,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,
-      65,    -1,    -1,    -1,    -1,    -1,    76,    77,    -1,    -1,
-      -1,    76,    77,    -1,    84,    -1,    -1,    -1,    -1,    84,
-      85,    -1,    -1,    -1,    -1,    -1,    -1,    97,    -1,    -1,
-      -1,    -1,    97,    -1,   104,    -1,    -1,   107,   108,   104,
-      -1,    -1,   107,   108,    -1,   115,    -1,    -1,    -1,   119,
-     115,    -1,    -1,    -1,   119,    10,    11,    12,    13,    14,
-      15,    16,    17,    18,    19,    -1,    21,    22,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    72
+      -1,    -1,   115,    -1,    -1,    -1,   119,    -1,    33,    34,
+      -1,   124,     4,     5,     6,     7,    41,    42,    -1,    -1,
+      -1,    -1,    -1,    48,    49,    50,    -1,    -1,    -1,    21,
+      22,    56,    -1,    -1,    -1,    -1,    -1,    62,    -1,    -1,
+      65,    33,    34,    -1,    -1,    -1,    -1,    -1,    -1,    41,
+      42,    76,    77,    -1,    -1,    -1,    48,    49,    50,    84,
+      85,    -1,    -1,    -1,    56,    -1,    -1,    -1,    -1,    -1,
+      62,    -1,    97,    65,    -1,    -1,    -1,    -1,    -1,   104,
+      -1,    -1,   107,   108,    76,    77,    -1,    -1,    -1,    -1,
+     115,    -1,    84,    85,   119,    -1,    -1,    -1,    -1,   124,
+      -1,     5,    -1,     7,    -1,    97,    -1,    -1,    -1,    -1,
+      -1,    -1,   104,    -1,    -1,   107,   108,    21,    22,    -1,
+      -1,    -1,    -1,   115,    33,    34,    -1,   119,    -1,    33,
+      34,    -1,   124,    42,    -1,    -1,    -1,    -1,    42,    48,
+      49,    50,    -1,    -1,    48,    49,    50,    56,    -1,    -1,
+      -1,    -1,    56,    -1,    -1,    -1,    65,    -1,    -1,    -1,
+      -1,    65,    -1,    -1,    -1,    -1,    -1,    76,    77,    -1,
+      -1,    -1,    76,    77,    -1,    84,    -1,    -1,    -1,    -1,
+      84,    85,    -1,    -1,    -1,    -1,    -1,    -1,    97,    -1,
+      -1,    -1,    -1,    97,    -1,   104,    -1,    -1,   107,   108,
+     104,    -1,    -1,   107,   108,    -1,   115,    -1,    -1,    -1,
+     119,   115,    -1,    -1,    -1,   119
 };
 
   /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
@@ -1258,54 +1223,51 @@ static const yytype_uint8 yystos[] =
 {
        0,     1,     3,    30,    46,    47,    52,    57,    75,    95,
      101,   112,   118,   120,   129,   130,   131,   132,   133,   134,
-     135,   156,   157,   160,   161,   164,   165,   168,   221,   222,
-     105,     4,     6,   219,    73,   105,    67,   105,    78,    29,
-      55,   169,   219,   166,   167,   181,   219,     0,   120,   122,
-      75,   168,   120,   123,     3,   219,    67,   219,   219,   219,
-     219,   219,     5,     7,    21,    22,    23,    33,    34,    41,
+     135,   156,   157,   160,   161,   164,   165,   168,   220,   221,
+     105,     4,     6,   218,    73,   105,    67,   105,    78,    29,
+      55,   169,   218,   166,   167,   180,   218,     0,   120,   122,
+      75,   168,   120,   123,     3,   218,    67,   218,   218,   218,
+     218,   218,     5,     7,    21,    22,    23,    33,    34,    41,
       42,    48,    49,    50,    56,    62,    65,    76,    77,    84,
       85,    97,   104,   107,   108,   115,   119,   124,   138,   170,
-     171,   172,   197,   198,   199,   200,   201,   202,   203,   210,
-     212,   215,   219,   102,   126,    31,   124,    78,    28,    57,
-       5,    88,   124,   117,   191,   192,   114,   124,   168,     7,
-       7,   116,   197,   206,   207,   124,    77,   124,     5,   124,
-      77,   197,     5,    67,   173,   126,    21,    22,    31,   216,
-     219,    23,    24,   127,   217,    22,   200,    27,   124,   162,
-     163,   219,   167,   124,   177,   218,   219,   219,    44,    45,
-      44,    45,   118,   158,   219,   136,   137,   219,    10,    61,
-     124,   193,   194,   195,   196,   197,   212,   124,   218,   193,
-     116,   204,   205,    58,   207,   208,     7,   219,     7,   125,
-     177,   179,   182,   201,   219,   191,   172,   219,   198,   199,
-     219,    23,    55,   125,   197,   209,   126,   191,    11,   168,
-     125,   126,   168,   136,    43,    66,    94,   111,   142,   219,
-     219,   124,   124,   145,   125,   126,    77,   138,   196,   177,
-     193,   197,     8,     9,    10,    11,    12,    13,    14,    15,
-      16,    17,    18,    19,    72,   214,    20,   210,   211,   125,
-     106,   197,   205,   208,   197,    59,   125,    67,   125,    31,
-     180,   181,    68,    74,    79,    82,    99,   126,   174,   175,
-     176,   180,    37,   110,   178,    69,   183,   125,   209,   125,
-     126,   163,   197,   125,   219,   124,    80,    80,   124,    53,
-      60,   159,   212,   213,   219,   113,   142,   143,   144,   136,
+     171,   172,   196,   197,   198,   199,   200,   201,   202,   209,
+     211,   214,   218,   102,   126,    31,   124,    78,    28,    57,
+       5,    88,   124,   117,   190,   191,   114,   124,   168,     7,
+       7,   116,   196,   205,   206,   124,    77,   124,     5,   124,
+      77,   196,     5,    67,   173,   126,    21,    22,    31,   215,
+     218,    23,    24,   127,   216,    22,   199,    27,   124,   162,
+     163,   218,   167,   124,   174,   217,   218,   218,    44,    45,
+      44,    45,   118,   158,   218,   136,   137,   218,    10,    61,
+     124,   192,   193,   194,   195,   196,   211,   124,   217,   192,
+     116,   203,   204,    58,   206,   207,     7,   218,     7,   125,
+     124,   174,   177,   178,   181,   200,   218,   190,   172,   218,
+     197,   198,   218,    23,    55,   125,   196,   208,   126,   190,
+      11,   168,   125,   126,   168,   136,    43,    66,    94,   111,
+     142,   218,   218,   124,   124,   145,   125,   126,    77,   138,
+     195,   174,   192,   196,     8,     9,    10,    11,    12,    13,
+      14,    15,    16,    17,    18,    19,    72,   213,    20,   209,
+     210,   125,   106,   196,   204,   207,   196,    59,   125,    67,
+     125,   177,    31,   179,   180,    68,    74,    82,    99,   176,
+     126,   179,    37,   110,   175,    69,   182,   125,   208,   125,
+     126,   163,   196,   125,   218,   124,    80,    80,   124,    53,
+      60,   159,   211,   212,   218,   113,   142,   143,   144,   136,
       10,    43,    51,    85,    94,    98,   111,   139,   140,   141,
-     125,   194,   195,    17,    18,    19,    72,   197,   124,   177,
-     197,    10,    85,   125,   126,   114,   197,   106,    59,   197,
-     181,    79,    90,    79,   218,    79,    90,    79,    90,   179,
-     176,     7,     7,   180,    40,    71,   184,   125,   197,   193,
-     124,   124,   218,     5,    63,    87,    88,   109,   220,   125,
-     126,   125,   126,    35,    38,    39,   103,   154,   126,   118,
-     146,    85,   124,   210,    80,   219,   139,   197,   124,   177,
-       9,   209,    85,   210,   124,   197,   125,   218,    79,   218,
-      88,   218,    79,   218,    79,    93,    93,   209,   193,    89,
-     185,   125,   218,   218,   125,    53,    60,   212,   124,   155,
-     142,    36,    91,   147,   193,   124,     9,   209,   197,   125,
-     211,    88,   218,    88,   193,    88,   218,    88,   218,    40,
-      83,   186,   125,   125,     5,   220,   149,   150,   151,   152,
-     153,   219,   124,    40,   125,   219,   197,   125,   125,   193,
-      88,   193,   193,    88,   193,    88,   187,   188,   197,     7,
-      98,   125,   126,     7,    29,   124,   219,   149,    70,    96,
-     148,   125,   193,   193,   193,   126,    32,    54,   189,   219,
-     150,   218,   125,   124,   188,    86,   190,   124,   125,   218,
-      64,    81,   218,   125,   125,    92,     7
+     125,   193,   194,    17,    18,    19,    72,   196,   124,   174,
+     196,    10,    85,   125,   126,   114,   196,   106,    59,   196,
+     125,   180,    90,    90,    90,    79,   177,     7,     7,   179,
+      40,    71,   183,   125,   196,   192,   124,   124,   217,     5,
+      63,    87,    88,   109,   219,   125,   126,   125,   126,    35,
+      38,    39,   103,   154,   126,   118,   146,    85,   124,   209,
+      80,   218,   139,   196,   124,   174,     9,   208,    85,   209,
+     124,   196,   125,   178,    93,    93,   208,   192,    89,   184,
+     125,   217,   217,   125,    53,    60,   211,   124,   155,   142,
+      36,    91,   147,   192,   124,     9,   208,   196,   125,   210,
+      88,    40,    83,   185,   125,   125,     5,   219,   149,   150,
+     151,   152,   153,   218,   124,    40,   125,   218,   196,   125,
+     125,   192,   186,   187,   196,     7,    98,   125,   126,     7,
+      29,   124,   218,   149,    70,    96,   148,   125,   126,    32,
+      54,   188,   218,   150,   217,   125,   124,   187,    86,   189,
+     124,   125,   217,    64,    81,   217,   125,   125,    92,     7
 };
 
   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
@@ -1323,20 +1285,20 @@ static const yytype_uint8 yyr1[] =
      156,   156,   156,   157,   158,   158,   159,   159,   159,   159,
      160,   161,   162,   162,   163,   164,   164,   165,   166,   166,
      167,   168,   169,   169,   169,   170,   170,   171,   171,   172,
-     172,   172,   173,   174,   174,   175,   175,   176,   176,   176,
-     176,   176,   176,   176,   176,   177,   178,   178,   178,   179,
-     179,   179,   179,   179,   180,   180,   181,   181,   182,   182,
-     183,   183,   184,   184,   185,   185,   186,   186,   187,   187,
-     188,   189,   189,   189,   190,   190,   190,   191,   191,   192,
-     193,   193,   194,   194,   195,   195,   196,   196,   196,   196,
-     196,   196,   196,   196,   196,   196,   196,   197,   197,   198,
-     198,   199,   199,   200,   200,   200,   200,   200,   200,   201,
-     201,   201,   201,   202,   203,   203,   204,   204,   205,   206,
-     206,   207,   208,   208,   209,   209,   210,   210,   210,   210,
-     210,   210,   210,   211,   211,   212,   212,   213,   213,   214,
-     214,   214,   214,   214,   214,   214,   214,   214,   214,   215,
-     216,   216,   217,   217,   217,   218,   218,   219,   219,   220,
-     220,   220,   220,   221,   222,   222
+     172,   172,   173,   174,   175,   175,   175,   176,   176,   176,
+     176,   176,   176,   176,   176,   177,   177,   178,   178,   178,
+     178,   178,   178,   179,   179,   180,   180,   181,   181,   182,
+     182,   183,   183,   184,   184,   185,   185,   186,   186,   187,
+     188,   188,   188,   189,   189,   189,   190,   190,   191,   192,
+     192,   193,   193,   194,   194,   195,   195,   195,   195,   195,
+     195,   195,   195,   195,   195,   195,   196,   196,   197,   197,
+     198,   198,   199,   199,   199,   199,   199,   199,   200,   200,
+     200,   200,   201,   202,   202,   203,   203,   204,   205,   205,
+     206,   207,   207,   208,   208,   209,   209,   209,   209,   209,
+     209,   209,   210,   210,   211,   211,   212,   212,   213,   213,
+     213,   213,   213,   213,   213,   213,   213,   213,   214,   215,
+     215,   216,   216,   216,   217,   217,   218,   218,   219,   219,
+     219,   219,   220,   221,   221
 };
 
   /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
@@ -1354,20 +1316,20 @@ static const yytype_uint8 yyr2[] =
        7,     4,     5,     5,     0,     4,     2,     2,     4,     4,
        5,     4,     3,     1,     3,     1,     2,     2,     1,     3,
        3,     9,     0,     1,     1,     1,     1,     1,     3,     3,
-       2,     1,     3,     0,     1,     2,     1,     5,     4,     6,
-       5,     6,     5,     6,     5,     3,     0,     3,     3,     2,
-       3,     2,     2,     1,     1,     2,     1,     4,     1,     3,
-       0,     3,     0,     2,     0,     3,     0,     2,     1,     3,
-       3,     0,     1,     1,     0,     2,     2,     0,     1,     2,
-       3,     1,     3,     1,     2,     1,     5,     6,     4,     3,
-       3,     3,     2,     3,     5,     4,     6,     3,     1,     3,
-       1,     2,     1,     1,     1,     1,     1,     1,     3,     3,
-       4,     4,     5,     6,     5,     4,     1,     2,     4,     1,
-       2,     4,     0,     2,     1,     3,     1,     1,     2,     2,
-       1,     2,     2,     1,     3,     1,     3,     1,     3,     1,
-       1,     1,     1,     1,     1,     1,     2,     1,     2,     1,
-       1,     1,     1,     1,     1,     1,     3,     1,     1,     1,
-       1,     1,     1,     2,     2,     0
+       2,     1,     2,     3,     0,     3,     3,     0,     1,     1,
+       2,     1,     2,     1,     2,     6,     1,     2,     3,     2,
+       2,     1,     3,     1,     2,     1,     4,     1,     3,     0,
+       3,     0,     2,     0,     3,     0,     2,     1,     3,     3,
+       0,     1,     1,     0,     2,     2,     0,     1,     2,     3,
+       1,     3,     1,     2,     1,     5,     6,     4,     3,     3,
+       3,     2,     3,     5,     4,     6,     3,     1,     3,     1,
+       2,     1,     1,     1,     1,     1,     1,     3,     3,     4,
+       4,     5,     6,     5,     4,     1,     2,     4,     1,     2,
+       4,     0,     2,     1,     3,     1,     1,     2,     2,     1,
+       2,     2,     1,     3,     1,     3,     1,     3,     1,     1,
+       1,     1,     1,     1,     1,     2,     1,     2,     1,     1,
+       1,     1,     1,     1,     1,     3,     1,     1,     1,     1,
+       1,     1,     2,     2,     0
 };
 
 
@@ -1864,893 +1826,909 @@ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocatio
   switch (yytype)
     {
           case 3: /* TOKEN_COMMAND  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 1874 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1836 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 4: /* TOKEN_NAME  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 1884 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1846 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 5: /* TOKEN_STRING_SINGLE_QUOTED  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 1894 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1856 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 6: /* TOKEN_STRING_DOUBLE_QUOTED  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 1904 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1866 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 7: /* TOKEN_UNSIGNED_NUMVAL  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).numeric_literal_value_) != nullptr) {
     delete ((*yyvaluep).numeric_literal_value_);
   }
 }
-#line 1914 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1876 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 130: /* sql_statement  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).statement_) != nullptr) {
     delete ((*yyvaluep).statement_);
   }
 }
-#line 1924 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1886 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 131: /* quit_statement  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).quit_statement_) != nullptr) {
     delete ((*yyvaluep).quit_statement_);
   }
 }
-#line 1934 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1896 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 132: /* alter_table_statement  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).statement_) != nullptr) {
     delete ((*yyvaluep).statement_);
   }
 }
-#line 1944 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1906 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 133: /* create_table_statement  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).create_table_statement_) != nullptr) {
     delete ((*yyvaluep).create_table_statement_);
   }
 }
-#line 1954 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1916 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 134: /* create_index_statement  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).statement_) != nullptr) {
     delete ((*yyvaluep).statement_);
   }
 }
-#line 1964 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1926 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 135: /* drop_table_statement  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).drop_table_statement_) != nullptr) {
     delete ((*yyvaluep).drop_table_statement_);
   }
 }
-#line 1974 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1936 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 136: /* column_def  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).attribute_definition_) != nullptr) {
     delete ((*yyvaluep).attribute_definition_);
   }
 }
-#line 1984 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1946 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 137: /* column_def_commalist  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).attribute_definition_list_) != nullptr) {
     delete ((*yyvaluep).attribute_definition_list_);
   }
 }
-#line 1994 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1956 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 138: /* data_type  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).data_type_) != nullptr) {
     delete ((*yyvaluep).data_type_);
   }
 }
-#line 2004 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1966 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 139: /* column_constraint_def  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).column_constraint_) != nullptr) {
     delete ((*yyvaluep).column_constraint_);
   }
 }
-#line 2014 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1976 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 140: /* column_constraint_def_list  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).column_constraint_list_) != nullptr) {
     delete ((*yyvaluep).column_constraint_list_);
   }
 }
-#line 2024 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1986 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 141: /* opt_column_constraint_def_list  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).column_constraint_list_) != nullptr) {
     delete ((*yyvaluep).column_constraint_list_);
   }
 }
-#line 2034 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1996 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 145: /* opt_column_list  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).attribute_list_) != nullptr) {
     delete ((*yyvaluep).attribute_list_);
   }
 }
-#line 2044 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2006 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 146: /* opt_block_properties  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).block_properties_) != nullptr) {
     delete ((*yyvaluep).block_properties_);
   }
 }
-#line 2054 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2016 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 147: /* opt_partition_clause  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).partition_clause_) != nullptr) {
     delete ((*yyvaluep).partition_clause_);
   }
 }
-#line 2064 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2026 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 148: /* partition_type  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 2074 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2036 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 149: /* key_value_list  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_value_list_) != nullptr) {
     delete ((*yyvaluep).key_value_list_);
   }
 }
-#line 2084 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2046 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 150: /* key_value  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_value_) != nullptr) {
     delete ((*yyvaluep).key_value_);
   }
 }
-#line 2094 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2056 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 151: /* key_string_value  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_string_value_) != nullptr) {
     delete ((*yyvaluep).key_string_value_);
   }
 }
-#line 2104 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2066 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 152: /* key_string_list  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_string_list_) != nullptr) {
     delete ((*yyvaluep).key_string_list_);
   }
 }
-#line 2114 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2076 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 153: /* key_integer_value  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_integer_value_) != nullptr) {
     delete ((*yyvaluep).key_integer_value_);
   }
 }
-#line 2124 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2086 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 154: /* index_type  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 2134 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2096 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 155: /* opt_index_properties  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_value_list_) != nullptr) {
     delete ((*yyvaluep).key_value_list_);
   }
 }
-#line 2144 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2106 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 156: /* insert_statement  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).insert_statement_) != nullptr) {
     delete ((*yyvaluep).insert_statement_);
   }
 }
-#line 2154 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2116 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 157: /* copy_from_statement  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).copy_from_statement_) != nullptr) {
     delete ((*yyvaluep).copy_from_statement_);
   }
 }
-#line 2164 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2126 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 158: /* opt_copy_from_params  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).copy_from_params_) != nullptr) {
     delete ((*yyvaluep).copy_from_params_);
   }
 }
-#line 2174 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2136 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 159: /* copy_from_params  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).copy_from_params_) != nullptr) {
     delete ((*yyvaluep).copy_from_params_);
   }
 }
-#line 2184 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2146 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 160: /* update_statement  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).update_statement_) != nullptr) {
     delete ((*yyvaluep).update_statement_);
   }
 }
-#line 2194 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2156 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 161: /* delete_statement  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).delete_statement_) != nullptr) {
     delete ((*yyvaluep).delete_statement_);
   }
 }
-#line 2204 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2166 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 162: /* assignment_list  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).assignment_list_) != nullptr) {
     delete ((*yyvaluep).assignment_list_);
   }
 }
-#line 2214 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2176 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 163: /* assignment_item  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).assignment_) != nullptr) {
     delete ((*yyvaluep).assignment_);
   }
 }
-#line 2224 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2186 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 164: /* select_statement  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).select_statement_) != nullptr) {
     delete ((*yyvaluep).select_statement_);
   }
 }
-#line 2234 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2196 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 165: /* with_clause  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).with_list_) != nullptr) {
     delete ((*yyvaluep).with_list_);
   }
 }
-#line 2244 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2206 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 166: /* with_list  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).with_list_) != nullptr) {
     delete ((*yyvaluep).with_list_);
   }
 }
-#line 2254 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2216 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 167: /* with_list_element  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).with_list_element_) != nullptr) {
     delete ((*yyvaluep).with_list_element_);
   }
 }
-#line 2264 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2226 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 168: /* select_query  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).select_query_) != nullptr) {
     delete ((*yyvaluep).select_query_);
   }
 }
-#line 2274 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2236 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 170: /* selection  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).selection_) != nullptr) {
     delete ((*yyvaluep).selection_);
   }
 }
-#line 2284 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2246 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 171: /* selection_item_commalist  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).selection_list_) != nullptr) {
     delete ((*yyvaluep).selection_list_);
   }
 }
-#line 2294 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2256 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 172: /* selection_item  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).selection_item_) != nullptr) {
     delete ((*yyvaluep).selection_item_);
   }
 }
-#line 2304 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2266 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 173: /* from_clause  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).table_reference_list_) != nullptr) {
     delete ((*yyvaluep).table_reference_list_);
   }
 }
-#line 2314 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2276 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 177: /* subquery_expression  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 174: /* subquery_expression  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).subquery_expression_) != nullptr) {
     delete ((*yyvaluep).subquery_expression_);
   }
 }
-#line 2324 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2286 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 178: /* opt_sample_clause  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 175: /* opt_sample_clause  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).opt_sample_clause_) != nullptr) {
     delete ((*yyvaluep).opt_sample_clause_);
   }
 }
-#line 2334 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2296 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 179: /* table_reference  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 176: /* join_type  */
+#line 564 "../SqlParser.ypp" /* yacc.c:1257  */
+      { }
+#line 2302 "SqlParser_gen.cpp" /* yacc.c:1257  */
+        break;
+
+    case 177: /* joined_table_reference  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).table_reference_) != nullptr) {
     delete ((*yyvaluep).table_reference_);
   }
 }
-#line 2344 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2312 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 180: /* table_reference_signature  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 178: /* table_reference  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
+      {
+  if (((*yyvaluep).table_reference_) != nullptr) {
+    delete ((*yyvaluep).table_reference_);
+  }
+}
+#line 2322 "SqlParser_gen.cpp" /* yacc.c:1257  */
+        break;
+
+    case 179: /* table_reference_signature  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).table_reference_signature_) != nullptr) {
     delete ((*yyvaluep).table_reference_signature_);
   }
 }
-#line 2354 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2332 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 181: /* table_reference_signature_primary  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 180: /* table_reference_signature_primary  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).table_reference_signature_) != nullptr) {
     delete ((*yyvaluep).table_reference_signature_);
   }
 }
-#line 2364 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2342 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 182: /* table_reference_commalist  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 181: /* joined_table_reference_commalist  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).table_reference_list_) != nullptr) {
     delete ((*yyvaluep).table_reference_list_);
   }
 }
-#line 2374 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2352 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 183: /* opt_group_by_clause  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 182: /* opt_group_by_clause  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).opt_group_by_clause_) != nullptr) {
     delete ((*yyvaluep).opt_group_by_clause_);
   }
 }
-#line 2384 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2362 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 184: /* opt_having_clause  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 183: /* opt_having_clause  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).opt_having_clause_) != nullptr) {
     delete ((*yyvaluep).opt_having_clause_);
   }
 }
-#line 2394 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2372 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 185: /* opt_order_by_clause  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 184: /* opt_order_by_clause  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).opt_order_by_clause_) != nullptr) {
     delete ((*yyvaluep).opt_order_by_clause_);
   }
 }
-#line 2404 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2382 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 186: /* opt_limit_clause  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 185: /* opt_limit_clause  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).opt_limit_clause_) != nullptr) {
     delete ((*yyvaluep).opt_limit_clause_);
   }
 }
-#line 2414 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2392 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 187: /* order_commalist  */
-#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 186: /* order_commalist  */
+#line 566 "../SqlParser.ypp" /* yacc.c:1257  */
       {
  

<TRUNCATED>


[23/24] incubator-quickstep git commit: Better error messages for failed unix glob. (#174)

Posted by zu...@apache.org.
Better error messages for failed unix glob. (#174)

Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/19e74ab8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/19e74ab8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/19e74ab8

Branch: refs/heads/master
Commit: 19e74ab84a9bc28fc722c7f3b9ee834ed88cd595
Parents: a5e7d09
Author: Marc S <cr...@users.noreply.github.com>
Authored: Sun Apr 17 23:38:43 2016 -0500
Committer: Jignesh Patel <pa...@users.noreply.github.com>
Committed: Sun Apr 17 23:38:43 2016 -0500

----------------------------------------------------------------------
 relational_operators/TextScanOperator.cpp |  4 ++++
 utility/Glob.cpp                          | 18 ++++++++++++++----
 2 files changed, 18 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/19e74ab8/relational_operators/TextScanOperator.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/TextScanOperator.cpp b/relational_operators/TextScanOperator.cpp
index a311a81..80cf953 100644
--- a/relational_operators/TextScanOperator.cpp
+++ b/relational_operators/TextScanOperator.cpp
@@ -148,6 +148,10 @@ bool TextScanOperator::getAllWorkOrders(
 
   const std::vector<std::string> files = utility::file::GlobExpand(file_pattern_);
 
+  if (files.size() == 0) {
+    LOG(FATAL) << "No files matched '" << file_pattern_ << "'. Exiting.";
+  }
+
   InsertDestination *output_destination =
       query_context->getInsertDestination(output_destination_index_);
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/19e74ab8/utility/Glob.cpp
----------------------------------------------------------------------
diff --git a/utility/Glob.cpp b/utility/Glob.cpp
index 98f5615..7e49c13 100644
--- a/utility/Glob.cpp
+++ b/utility/Glob.cpp
@@ -42,11 +42,21 @@ std::size_t GlobForEach(const std::string &pattern,
 #if defined(QUICKSTEP_HAVE_GLOB)
   glob_t glob_result;
 
-  int ret = glob(pattern.c_str(), 0, nullptr, &glob_result);
-  LOG_IF(ERROR, ret != 0) << "glob() returned non-zero";
-  std::size_t num_matches = glob_result.gl_pathc;
+  const int ret = glob(pattern.c_str(), 0, nullptr, &glob_result);
+  std::size_t num_matches = 0;
+  if (ret == GLOB_ABORTED) {
+    LOG(ERROR) << "An error occurred during glob.";
+  } else if (ret == GLOB_NOMATCH) {
+    LOG(WARNING) << "Glob function made zero matches.";
+  } else if (ret == GLOB_NOSPACE) {
+    LOG(ERROR) << "Glob function failed to allocate memory.";
+  } else {
+    // There should be no errors at this point.
+    DCHECK_EQ(ret, 0);
+    num_matches = glob_result.gl_pathc;
+  }
 
-  for (std::size_t i = 0; i < glob_result.gl_pathc; ++i) {
+  for (std::size_t i = 0; i < num_matches; ++i) {
     functor(glob_result.gl_pathv[i]);
   }
 


[22/24] incubator-quickstep git commit: Use the pre-built gtest in Travis. (#163)

Posted by zu...@apache.org.
Use the pre-built gtest in Travis. (#163)

Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/a5e7d098
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/a5e7d098
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/a5e7d098

Branch: refs/heads/master
Commit: a5e7d098136df430dc249fefc373cc86c97dee42
Parents: e87cabf
Author: Zuyu ZHANG <zu...@users.noreply.github.com>
Authored: Sat Apr 16 23:33:42 2016 -0500
Committer: Jignesh Patel <pa...@users.noreply.github.com>
Committed: Sat Apr 16 23:33:42 2016 -0500

----------------------------------------------------------------------
 .travis.yml | 1 +
 1 file changed, 1 insertion(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a5e7d098/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 4e10e2a..e1a9cba 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -83,6 +83,7 @@ addons:
       - binutils-gold
       - libprotobuf-dev
       - protobuf-compiler
+      - libgtest-dev
       - python-networkx
       - libnuma-dev
 


[14/24] incubator-quickstep git commit: Adds support for IN predicate (#167)

Posted by zu...@apache.org.
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 <ji...@cs.wisc.edu>
Authored: Fri Apr 15 14:20:47 2016 -0500
Committer: Zuyu ZHANG <zu...@users.noreply.github.com>
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"



[07/24] incubator-quickstep git commit: Reordered the build sequences in Travis to reduce the total CI time. (#162)

Posted by zu...@apache.org.
Reordered the build sequences in Travis to reduce the total CI time. (#162)

Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/aee53ee5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/aee53ee5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/aee53ee5

Branch: refs/heads/master
Commit: aee53ee5332579f60aef7914b3a1ec01a929aedb
Parents: a39ad96
Author: Zuyu ZHANG <zu...@users.noreply.github.com>
Authored: Thu Apr 14 14:29:37 2016 -0700
Committer: Jignesh Patel <pa...@users.noreply.github.com>
Committed: Thu Apr 14 16:29:37 2016 -0500

----------------------------------------------------------------------
 .travis.yml | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/aee53ee5/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index d347333..9c5eacf 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -3,18 +3,20 @@
 # speed up compilation in release build. Also, jobs can only use upto 20GB of
 # disk space. Hence, we minimize the amount of debug symbol using -g0 (DEBUG
 # builds were taking > 20GB of space with clang).
+# Also, to reduce the total CI time, we explicitly run the most time-consuming
+# build first, using gcc in debug build with joinwithbinaryexpressions.
 
 language: cpp
 
 compiler:
-  - clang
   - gcc
+  - clang
 
 env:
-  - BUILD_TYPE=Debug VECTOR_COPY_ELISION_LEVEL=none
-  - BUILD_TYPE=Release VECTOR_COPY_ELISION_LEVEL=none
   - BUILD_TYPE=Debug VECTOR_COPY_ELISION_LEVEL=joinwithbinaryexpressions
   - BUILD_TYPE=Release VECTOR_COPY_ELISION_LEVEL=joinwithbinaryexpressions
+  - BUILD_TYPE=Debug VECTOR_COPY_ELISION_LEVEL=none
+  - BUILD_TYPE=Release VECTOR_COPY_ELISION_LEVEL=none
 
 install:
   - if [ "$VECTOR_COPY_ELISION_LEVEL" = "joinwithbinaryexpressions" ] && [ "$CC" = "gcc" ]; then


[21/24] incubator-quickstep git commit: Added JOIN ... ON ... operator and tests. (#171)

Posted by zu...@apache.org.
Added JOIN ... ON ... operator and tests. (#171)

Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/e87cabf4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/e87cabf4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/e87cabf4

Branch: refs/heads/master
Commit: e87cabf4995de58ff2677a2c4bc1118a1048667c
Parents: cbd169e
Author: Jianqiao Zhu <ji...@cs.wisc.edu>
Authored: Sat Apr 16 23:32:34 2016 -0500
Committer: Jignesh Patel <pa...@users.noreply.github.com>
Committed: Sat Apr 16 23:32:34 2016 -0500

----------------------------------------------------------------------
 parser/CMakeLists.txt                           |    9 +
 parser/ParseJoinedTableReference.cpp            |   71 +
 parser/ParseJoinedTableReference.hpp            |  128 +
 parser/ParseTableReference.hpp                  |    3 +-
 parser/SqlLexer.lpp                             |    1 +
 parser/SqlParser.ypp                            |  125 +-
 parser/SqlParserWrapper.cpp                     |    1 +
 parser/preprocessed/SqlLexer_gen.cpp            |  303 +-
 parser/preprocessed/SqlLexer_gen.hpp            |    2 +-
 parser/preprocessed/SqlParser_gen.cpp           | 2619 +++++++++---------
 parser/preprocessed/SqlParser_gen.hpp           |   14 +-
 parser/tests/CMakeLists.txt                     |    4 +
 parser/tests/Join.test                          |  160 ++
 parser/tests/TPCH.test                          |   43 +-
 query_optimizer/resolver/CMakeLists.txt         |    1 +
 query_optimizer/resolver/NameResolver.cpp       |   17 +
 query_optimizer/resolver/NameResolver.hpp       |    9 +
 query_optimizer/resolver/Resolver.cpp           |   34 +
 query_optimizer/resolver/Resolver.hpp           |   14 +
 .../tests/OptimizerTextTestRunner.hpp           |    1 +
 query_optimizer/tests/TestDatabaseLoader.cpp    |   30 +
 query_optimizer/tests/TestDatabaseLoader.hpp    |    8 +
 .../tests/execution_generator/CMakeLists.txt    |    6 +
 .../tests/execution_generator/Join.test         |  132 +
 .../tests/logical_generator/CMakeLists.txt      |   14 +-
 .../tests/logical_generator/Join.test           |  217 ++
 .../tests/physical_generator/CMakeLists.txt     |    4 +
 .../tests/physical_generator/Join.test          |  237 ++
 query_optimizer/tests/resolver/CMakeLists.txt   |    4 +
 query_optimizer/tests/resolver/Join.test        |  172 ++
 30 files changed, 2802 insertions(+), 1581 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/parser/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/parser/CMakeLists.txt b/parser/CMakeLists.txt
index 8f4bae9..d35f3be 100644
--- a/parser/CMakeLists.txt
+++ b/parser/CMakeLists.txt
@@ -94,6 +94,7 @@ add_library(quickstep_parser_ParseGeneratorTableReference ParseGeneratorTableRef
 add_library(quickstep_parser_ParseGroupBy ParseGroupBy.cpp ParseGroupBy.hpp)
 add_library(quickstep_parser_ParseHaving ParseHaving.cpp ParseHaving.hpp)
 add_library(quickstep_parser_ParseIndexProperties ParseIndexProperties.cpp ParseIndexProperties.hpp)
+add_library(quickstep_parser_ParseJoinedTableReference ParseJoinedTableReference.cpp ParseJoinedTableReference.hpp)
 add_library(quickstep_parser_ParseKeyValue ../empty_src.cpp ParseKeyValue.hpp)
 add_library(quickstep_parser_ParseLimit ParseLimit.cpp ParseLimit.hpp)
 add_library(quickstep_parser_ParseLiteralValue ParseLiteralValue.cpp ParseLiteralValue.hpp)
@@ -177,6 +178,10 @@ target_link_libraries(quickstep_parser_ParseIndexProperties
                       quickstep_utility_Macros
                       quickstep_utility_PtrList
                       quickstep_utility_StringUtil)
+target_link_libraries(quickstep_parser_ParseJoinedTableReference
+                      quickstep_parser_ParsePredicate
+                      quickstep_parser_ParseTableReference
+                      quickstep_utility_Macros)
 target_link_libraries(quickstep_parser_ParseLimit
                       quickstep_parser_ParseLiteralValue
                       quickstep_parser_ParseTreeNode
@@ -295,6 +300,7 @@ target_link_libraries(quickstep_parser_ParseTreeNode
 target_link_libraries(quickstep_parser_ParserUtil
                       quickstep_utility_SqlError)
 target_link_libraries(quickstep_parser_SqlLexer
+                      quickstep_parser_ParseJoinedTableReference
                       quickstep_parser_ParseLiteralValue
                       quickstep_parser_ParserUtil
                       quickstep_parser_ParseString
@@ -312,6 +318,7 @@ target_link_libraries(quickstep_parser_SqlParser
                       quickstep_parser_ParseGeneratorTableReference
                       quickstep_parser_ParseGroupBy
                       quickstep_parser_ParseHaving
+                      quickstep_parser_ParseJoinedTableReference
                       quickstep_parser_ParseKeyValue
                       quickstep_parser_ParseLimit
                       quickstep_parser_ParseLiteralValue
@@ -347,6 +354,7 @@ target_link_libraries(quickstep_parser_SqlParser
                       quickstep_utility_PtrVector)
 target_link_libraries(quickstep_parser_SqlParserWrapper
                       glog
+                      quickstep_parser_ParseJoinedTableReference
                       quickstep_parser_ParseStatement
                       quickstep_parser_SqlLexer
                       quickstep_parser_SqlParser
@@ -387,6 +395,7 @@ target_link_libraries(quickstep_parser
                       quickstep_parser_ParseGroupBy
                       quickstep_parser_ParseHaving
                       quickstep_parser_ParseIndexProperties
+                      quickstep_parser_ParseJoinedTableReference
                       quickstep_parser_ParseLimit
                       quickstep_parser_ParseLiteralValue
                       quickstep_parser_ParseOrderBy

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/parser/ParseJoinedTableReference.cpp
----------------------------------------------------------------------
diff --git a/parser/ParseJoinedTableReference.cpp b/parser/ParseJoinedTableReference.cpp
new file mode 100644
index 0000000..c1bc956
--- /dev/null
+++ b/parser/ParseJoinedTableReference.cpp
@@ -0,0 +1,71 @@
+/**
+ *   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.
+ **/
+
+#include "parser/ParseJoinedTableReference.hpp"
+
+#include <string>
+#include <type_traits>
+#include <vector>
+
+#include "glog/logging.h"
+
+namespace quickstep {
+
+void ParseJoinedTableReference::getFieldStringItems(
+    std::vector<std::string> *inline_field_names,
+    std::vector<std::string> *inline_field_values,
+    std::vector<std::string> *non_container_child_field_names,
+    std::vector<const ParseTreeNode*> *non_container_child_fields,
+    std::vector<std::string> *container_child_field_names,
+    std::vector<std::vector<const ParseTreeNode*>> *container_child_fields) const {
+  ParseTableReference::getFieldStringItems(inline_field_names,
+                                           inline_field_values,
+                                           non_container_child_field_names,
+                                           non_container_child_fields,
+                                           container_child_field_names,
+                                           container_child_fields);
+
+  inline_field_names->push_back("join_type");
+  switch (join_type_) {
+    case JoinType::kInnerJoin:
+      inline_field_values->push_back("InnerJoin");
+      break;
+    case JoinType::kLeftOuterJoin:
+      inline_field_values->push_back("LeftOuterJoin");
+      break;
+    case JoinType::kRightOuterJoin:
+      inline_field_values->push_back("RightOuterJoin");
+      break;
+    case JoinType::kFullOuterJoin:
+      inline_field_values->push_back("FullOuterJoin");
+      break;
+    default:
+      LOG(FATAL) << "Invalid JoinType: "
+                 << static_cast<typename std::underlying_type<JoinType>::type>(join_type_);
+  }
+
+  non_container_child_field_names->push_back("left_table");
+  non_container_child_fields->push_back(left_table_.get());
+
+  non_container_child_field_names->push_back("right_table");
+  non_container_child_fields->push_back(right_table_.get());
+
+  non_container_child_field_names->push_back("join_predicate");
+  non_container_child_fields->push_back(join_predicate_.get());
+}
+
+}  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/parser/ParseJoinedTableReference.hpp
----------------------------------------------------------------------
diff --git a/parser/ParseJoinedTableReference.hpp b/parser/ParseJoinedTableReference.hpp
new file mode 100644
index 0000000..182f472
--- /dev/null
+++ b/parser/ParseJoinedTableReference.hpp
@@ -0,0 +1,128 @@
+/**
+ *   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_JOINED_TABLE_REFERENCE_HPP_
+#define QUICKSTEP_PARSER_PARSE_JOINED_TABLE_REFERENCE_HPP_
+
+#include <memory>
+#include <string>
+#include <vector>
+
+#include "parser/ParsePredicate.hpp"
+#include "parser/ParseTableReference.hpp"
+#include "utility/Macros.hpp"
+
+namespace quickstep {
+
+class ParseTreeNode;
+
+/** \addtogroup Parser
+ *  @{
+ */
+
+/**
+ * @brief Parsed representation of a joined table.
+ */
+class ParseJoinedTableReference : public ParseTableReference {
+ public:
+  enum class JoinType {
+    kInnerJoin = 0,
+    kLeftOuterJoin,
+    kRightOuterJoin,
+    kFullOuterJoin
+  };
+
+  /**
+   * @brief Constructor.
+   *
+   * @param line_number The line number of the token "JOIN" in the SQL statement.
+   * @param column_number The column number of the token "JOIN" in the SQL statement.
+   * @param join_type The join type.
+   * @param left_table The left-hand side table.
+   * @param right_table The right-hand side table.
+   * @param join_predicate The join predicate.
+   */
+  ParseJoinedTableReference(const int line_number,
+                            const int column_number,
+                            const JoinType join_type,
+                            ParseTableReference *left_table,
+                            ParseTableReference *right_table,
+                            ParsePredicate *join_predicate)
+    : ParseTableReference(line_number, column_number),
+      join_type_(join_type),
+      left_table_(left_table),
+      right_table_(right_table),
+      join_predicate_(join_predicate) {
+  }
+
+  TableReferenceType getTableReferenceType() const override {
+    return kJoinedTableReference;
+  }
+
+  std::string getName() const override { return "JoinedTable"; }
+
+  /**
+   * @return The join type.
+   */
+  JoinType join_type() const {
+    return join_type_;
+  }
+
+  /**
+   * @return The left-side table.
+   */
+  const ParseTableReference* left_table() const {
+    return left_table_.get();
+  }
+
+  /**
+   * @return The right-side table.
+   */
+  const ParseTableReference* right_table() const {
+    return right_table_.get();
+  }
+
+  /**
+   * @return The join predicate.
+   */
+  const ParsePredicate* join_predicate() const {
+    return join_predicate_.get();
+  }
+
+ protected:
+  void getFieldStringItems(
+      std::vector<std::string> *inline_field_names,
+      std::vector<std::string> *inline_field_values,
+      std::vector<std::string> *non_container_child_field_names,
+      std::vector<const ParseTreeNode*> *non_container_child_fields,
+      std::vector<std::string> *container_child_field_names,
+      std::vector<std::vector<const ParseTreeNode*>> *container_child_fields) const override;
+
+ private:
+  const JoinType join_type_;
+  std::unique_ptr<ParseTableReference> left_table_;
+  std::unique_ptr<ParseTableReference> right_table_;
+  std::unique_ptr<ParsePredicate> join_predicate_;
+
+  DISALLOW_COPY_AND_ASSIGN(ParseJoinedTableReference);
+};
+
+/** @} */
+
+}  // namespace quickstep
+
+#endif /* QUICKSTEP_PARSER_PARSE_JOINED_TABLE_REFERENCE_HPP_ */

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/parser/ParseTableReference.hpp
----------------------------------------------------------------------
diff --git a/parser/ParseTableReference.hpp b/parser/ParseTableReference.hpp
index ff68dd8..c3500b0 100644
--- a/parser/ParseTableReference.hpp
+++ b/parser/ParseTableReference.hpp
@@ -96,8 +96,9 @@ class ParseTableReferenceSignature : public ParseTreeNode {
 class ParseTableReference : public ParseTreeNode {
  public:
   enum TableReferenceType {
-    kSimpleTableReference,
     kGeneratorTableReference,
+    kJoinedTableReference,
+    kSimpleTableReference,
     kSubqueryTableReference
   };
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/parser/SqlLexer.lpp
----------------------------------------------------------------------
diff --git a/parser/SqlLexer.lpp b/parser/SqlLexer.lpp
index 5c2e221..3043322 100644
--- a/parser/SqlLexer.lpp
+++ b/parser/SqlLexer.lpp
@@ -30,6 +30,7 @@
 #include <string>
 #include <vector>
 
+#include "parser/ParseJoinedTableReference.hpp"
 #include "parser/ParseLiteralValue.hpp"
 #include "utility/PtrList.hpp"
 #include "utility/PtrVector.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/parser/SqlParser.ypp
----------------------------------------------------------------------
diff --git a/parser/SqlParser.ypp b/parser/SqlParser.ypp
index 0cf4590..bb19d8b 100644
--- a/parser/SqlParser.ypp
+++ b/parser/SqlParser.ypp
@@ -76,6 +76,7 @@ typedef struct YYLTYPE {
 #include "parser/ParseGeneratorTableReference.hpp"
 #include "parser/ParseGroupBy.hpp"
 #include "parser/ParseHaving.hpp"
+#include "parser/ParseJoinedTableReference.hpp"
 #include "parser/ParseKeyValue.hpp"
 #include "parser/ParseLimit.hpp"
 #include "parser/ParseLiteralValue.hpp"
@@ -149,6 +150,8 @@ typedef void* yyscan_t;
   quickstep::PtrList<quickstep::ParseTableReference> *table_reference_list_;
   quickstep::ParseTableReferenceSignature *table_reference_signature_;
 
+  quickstep::ParseJoinedTableReference::JoinType join_type_;
+
   quickstep::ParseDataType *data_type_;
   quickstep::ParseAttributeDefinition *attribute_definition_;
   quickstep::ParseColumnConstraint *column_constraint_;
@@ -393,15 +396,19 @@ void NotSupported(const YYLTYPE *location, yyscan_t yyscanner, const std::string
 
 %type <table_reference_>
   table_reference
+  joined_table_reference
 
 %type <table_reference_list_>
-  table_reference_commalist
+  joined_table_reference_commalist
   from_clause
 
 %type <table_reference_signature_>
   table_reference_signature
   table_reference_signature_primary
 
+%type <join_type_>
+  join_type
+
 %type <data_type_>
   data_type
 
@@ -544,9 +551,6 @@ void NotSupported(const YYLTYPE *location, yyscan_t yyscanner, const std::string
 
 /*
 %type <int_val>
-  join                  // unimplemented
-  join_chain            // unimplemented
-  opt_join_chain        // unimplemented
   opt_all_distinct      // unimplemented
   table_constraint_def  // unimplemented
   table_constraint_def_commalist        // unimplemented
@@ -557,6 +561,7 @@ void NotSupported(const YYLTYPE *location, yyscan_t yyscanner, const std::string
 %destructor { } <comparison_>
 %destructor { } <unary_operation_>
 %destructor { } <binary_operation_>
+%destructor { } <join_type_>
 
 %destructor {
   if ($$ != nullptr) {
@@ -1168,93 +1173,58 @@ selection_item:
   };
 
 from_clause:
-  TOKEN_FROM table_reference_commalist opt_join_chain {
+  TOKEN_FROM joined_table_reference_commalist {
     $$ = $2;
   };
 
-opt_join_chain:
-  {
-    /* $$ = nullptr; */
-  }
-  | join_chain {
-    NotSupported(&@1, yyscanner, "alternate JOIN syntax (specify in WHERE clause instead)");
-    YYERROR;
+subquery_expression:
+  '(' select_query ')' {
+    $$ = new quickstep::ParseSubqueryExpression(@1.first_line, @1.first_column, $2);
   };
 
-join_chain:
-  join_chain join {
-    NotSupported(&@1, yyscanner, "alternate JOIN syntax (specify in WHERE clause instead)");
-    YYERROR;
+opt_sample_clause:
+  {
+    $$ = NULL;
   }
-  | join {
-    NotSupported(&@1, yyscanner, "alternate JOIN syntax (specify in WHERE clause instead)");
-    YYERROR;
+  | TOKEN_BLOCKSAMPLE TOKEN_UNSIGNED_NUMVAL TOKEN_PERCENT {
+    $$ = new quickstep::ParseSample(@1.first_line, @1.first_column, true, $2);
+  }
+  | TOKEN_TUPLESAMPLE TOKEN_UNSIGNED_NUMVAL TOKEN_PERCENT {
+    $$ = new quickstep::ParseSample(@1.first_line, @1.first_column, false, $2);
   };
 
-join:
-  TOKEN_INNER TOKEN_JOIN name_commalist TOKEN_ON or_expression {
-    delete $3;
-    delete $5;
-    NotSupported(&@1, yyscanner, "alternate JOIN syntax (specify in WHERE clause instead)");
-    YYERROR;
+join_type:
+  {
+    $$ = quickstep::ParseJoinedTableReference::JoinType::kInnerJoin;
   }
-  | TOKEN_JOIN name_commalist TOKEN_ON or_expression {
-    delete $2;
-    delete $4;
-    NotSupported(&@1, yyscanner, "alternate JOIN syntax (specify in WHERE clause instead)");
-    YYERROR;
+  | TOKEN_INNER {
+    $$ = quickstep::ParseJoinedTableReference::JoinType::kInnerJoin;
   }
-  | TOKEN_LEFT TOKEN_OUTER TOKEN_JOIN name_commalist TOKEN_ON or_expression {
-    delete $4;
-    delete $6;
-    NotSupported(&@1, yyscanner, "OUTER JOIN");
-    YYERROR;
+  | TOKEN_LEFT {
+    $$ = quickstep::ParseJoinedTableReference::JoinType::kLeftOuterJoin;
   }
-  | TOKEN_LEFT TOKEN_JOIN name_commalist TOKEN_ON or_expression {
-    delete $3;
-    delete $5;
-    NotSupported(&@1, yyscanner, "OUTER JOIN");
-    YYERROR;
+  | TOKEN_LEFT TOKEN_OUTER {
+    $$ = quickstep::ParseJoinedTableReference::JoinType::kLeftOuterJoin;
   }
-  | TOKEN_RIGHT TOKEN_OUTER TOKEN_JOIN name_commalist TOKEN_ON or_expression {
-    delete $4;
-    delete $6;
-    NotSupported(&@1, yyscanner, "OUTER JOIN");
-    YYERROR;
+  | TOKEN_RIGHT {
+    $$ = quickstep::ParseJoinedTableReference::JoinType::kRightOuterJoin;
   }
-  | TOKEN_RIGHT TOKEN_JOIN name_commalist TOKEN_ON or_expression {
-    delete $3;
-    delete $5;
-    NotSupported(&@1, yyscanner, "OUTER JOIN");
-    YYERROR;
+  | TOKEN_RIGHT TOKEN_OUTER {
+    $$ = quickstep::ParseJoinedTableReference::JoinType::kRightOuterJoin;
   }
-  | TOKEN_FULL TOKEN_OUTER TOKEN_JOIN name_commalist TOKEN_ON or_expression {
-    delete $4;
-    delete $6;
-    NotSupported(&@1, yyscanner, "OUTER JOIN");
-    YYERROR;
+  | TOKEN_FULL {
+    $$ = quickstep::ParseJoinedTableReference::JoinType::kFullOuterJoin;
   }
-  | TOKEN_FULL TOKEN_JOIN name_commalist TOKEN_ON or_expression {
-    delete $3;
-    delete $5;
-    NotSupported(&@1, yyscanner, "OUTER JOIN");
-    YYERROR;
-  };
-
-subquery_expression:
-  '(' select_query ')' {
-    $$ = new quickstep::ParseSubqueryExpression(@1.first_line, @1.first_column, $2);
+  | TOKEN_FULL TOKEN_OUTER {
+    $$ = quickstep::ParseJoinedTableReference::JoinType::kFullOuterJoin;
   };
 
-opt_sample_clause:
-  {
-    $$ = NULL;
+joined_table_reference:
+  joined_table_reference join_type TOKEN_JOIN table_reference TOKEN_ON or_expression {
+    $$ = new quickstep::ParseJoinedTableReference(@3.first_line, @3.first_column, $2, $1, $4, $6);
   }
-  | TOKEN_BLOCKSAMPLE TOKEN_UNSIGNED_NUMVAL TOKEN_PERCENT {
-    $$ = new quickstep::ParseSample(@1.first_line, @1.first_column, true, $2);
-  }
-  | TOKEN_TUPLESAMPLE TOKEN_UNSIGNED_NUMVAL TOKEN_PERCENT {
-    $$ = new quickstep::ParseSample(@1.first_line, @1.first_column, false, $2);
+  | table_reference {
+    $$ = $1;
   };
 
 table_reference:
@@ -1275,6 +1245,9 @@ table_reference:
   }
   | function_call {
     $$ = new quickstep::ParseGeneratorTableReference(@1.first_line, @1.first_column, $1);
+  }
+  | '(' joined_table_reference ')' {
+    $$ = $2;
   };
 
 table_reference_signature:
@@ -1293,12 +1266,12 @@ table_reference_signature_primary:
     $$ = new ::quickstep::ParseTableReferenceSignature(@1.first_line, @1.first_column, $1, $3);
   };
 
-table_reference_commalist:
-  table_reference {
+joined_table_reference_commalist:
+  joined_table_reference {
     $$ = new quickstep::PtrList<quickstep::ParseTableReference>();
     $$->push_back($1);
   }
-  | table_reference_commalist ',' table_reference {
+  | joined_table_reference_commalist ',' joined_table_reference {
     $$ = $1;
     $$->push_back($3);
   };

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/parser/SqlParserWrapper.cpp
----------------------------------------------------------------------
diff --git a/parser/SqlParserWrapper.cpp b/parser/SqlParserWrapper.cpp
index c6e6bcc..bc9d87e 100644
--- a/parser/SqlParserWrapper.cpp
+++ b/parser/SqlParserWrapper.cpp
@@ -19,6 +19,7 @@
 
 #include <string>
 
+#include "parser/ParseJoinedTableReference.hpp"
 #include "parser/ParseStatement.hpp"
 #include "utility/Macros.hpp"
 #include "utility/SqlError.hpp"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/parser/preprocessed/SqlLexer_gen.cpp
----------------------------------------------------------------------
diff --git a/parser/preprocessed/SqlLexer_gen.cpp b/parser/preprocessed/SqlLexer_gen.cpp
index d00d51f..553a7d9 100644
--- a/parser/preprocessed/SqlLexer_gen.cpp
+++ b/parser/preprocessed/SqlLexer_gen.cpp
@@ -951,6 +951,7 @@ static yyconst flex_int32_t yy_rule_can_match_eol[145] =
 #include <string>
 #include <vector>
 
+#include "parser/ParseJoinedTableReference.hpp"
 #include "parser/ParseLiteralValue.hpp"
 #include "utility/PtrList.hpp"
 #include "utility/PtrVector.hpp"
@@ -1032,7 +1033,7 @@ class UnaryOperation;
 
 
 
-#line 1036 "SqlLexer_gen.cpp"
+#line 1037 "SqlLexer_gen.cpp"
 
 #define INITIAL 0
 #define CONDITION_SQL 1
@@ -1320,10 +1321,10 @@ YY_DECL
 		}
 
 	{
-#line 127 "../SqlLexer.lpp"
+#line 128 "../SqlLexer.lpp"
 
 
-#line 1327 "SqlLexer_gen.cpp"
+#line 1328 "SqlLexer_gen.cpp"
 
 	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
 		{
@@ -1390,7 +1391,7 @@ do_action:	/* This label is used only to access EOF actions. */
 
 case 1:
 YY_RULE_SETUP
-#line 130 "../SqlLexer.lpp"
+#line 131 "../SqlLexer.lpp"
 {
     /* A forward slash character represents a system command. */
     BEGIN(CONDITION_COMMAND);
@@ -1402,7 +1403,7 @@ YY_RULE_SETUP
 case 2:
 /* rule 2 can match eol */
 YY_RULE_SETUP
-#line 138 "../SqlLexer.lpp"
+#line 139 "../SqlLexer.lpp"
 {
     /* This is a SQL command. Place the char back and process normally. */
     yyless(0);
@@ -1414,7 +1415,7 @@ YY_RULE_SETUP
 
 case 3:
 YY_RULE_SETUP
-#line 147 "../SqlLexer.lpp"
+#line 148 "../SqlLexer.lpp"
 {
     /* This is a command argument. */
     yylval->string_value_ = new quickstep::ParseString(
@@ -1424,7 +1425,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 4:
 YY_RULE_SETUP
-#line 154 "../SqlLexer.lpp"
+#line 155 "../SqlLexer.lpp"
 {
     /* Ignore whitespace. */
   }
@@ -1432,7 +1433,7 @@ YY_RULE_SETUP
 case 5:
 /* rule 5 can match eol */
 YY_RULE_SETUP
-#line 158 "../SqlLexer.lpp"
+#line 159 "../SqlLexer.lpp"
 {
     /* Newline reverts the lexer to the initial state. */
     yycolumn = 0;
@@ -1444,562 +1445,562 @@ YY_RULE_SETUP
 
 case 6:
 YY_RULE_SETUP
-#line 167 "../SqlLexer.lpp"
+#line 168 "../SqlLexer.lpp"
 return TOKEN_ADD;
 	YY_BREAK
 case 7:
 YY_RULE_SETUP
-#line 168 "../SqlLexer.lpp"
+#line 169 "../SqlLexer.lpp"
 return TOKEN_ALL;
 	YY_BREAK
 case 8:
 YY_RULE_SETUP
-#line 169 "../SqlLexer.lpp"
+#line 170 "../SqlLexer.lpp"
 return TOKEN_ALTER;
 	YY_BREAK
 case 9:
 YY_RULE_SETUP
-#line 170 "../SqlLexer.lpp"
+#line 171 "../SqlLexer.lpp"
 return TOKEN_AND;
 	YY_BREAK
 case 10:
 YY_RULE_SETUP
-#line 171 "../SqlLexer.lpp"
+#line 172 "../SqlLexer.lpp"
 return TOKEN_AS;
 	YY_BREAK
 case 11:
 YY_RULE_SETUP
-#line 172 "../SqlLexer.lpp"
+#line 173 "../SqlLexer.lpp"
 return TOKEN_ASC;
 	YY_BREAK
 case 12:
 YY_RULE_SETUP
-#line 173 "../SqlLexer.lpp"
+#line 174 "../SqlLexer.lpp"
 return TOKEN_ASC;
 	YY_BREAK
 case 13:
 YY_RULE_SETUP
-#line 174 "../SqlLexer.lpp"
+#line 175 "../SqlLexer.lpp"
 return TOKEN_BETWEEN;
 	YY_BREAK
 case 14:
 YY_RULE_SETUP
-#line 175 "../SqlLexer.lpp"
+#line 176 "../SqlLexer.lpp"
 return TOKEN_BIGINT;
 	YY_BREAK
 case 15:
 YY_RULE_SETUP
-#line 176 "../SqlLexer.lpp"
+#line 177 "../SqlLexer.lpp"
 return TOKEN_BIT;
 	YY_BREAK
 case 16:
 YY_RULE_SETUP
-#line 177 "../SqlLexer.lpp"
+#line 178 "../SqlLexer.lpp"
 return TOKEN_BITWEAVING;
 	YY_BREAK
 case 17:
 YY_RULE_SETUP
-#line 178 "../SqlLexer.lpp"
+#line 179 "../SqlLexer.lpp"
 return TOKEN_BLOCKPROPERTIES;
 	YY_BREAK
 case 18:
 YY_RULE_SETUP
-#line 179 "../SqlLexer.lpp"
+#line 180 "../SqlLexer.lpp"
 return TOKEN_BLOCKSAMPLE;
 	YY_BREAK
 case 19:
 YY_RULE_SETUP
-#line 180 "../SqlLexer.lpp"
+#line 181 "../SqlLexer.lpp"
 return TOKEN_BLOOM_FILTER;
 	YY_BREAK
 case 20:
 YY_RULE_SETUP
-#line 181 "../SqlLexer.lpp"
+#line 182 "../SqlLexer.lpp"
 return TOKEN_CASE;
 	YY_BREAK
 case 21:
 YY_RULE_SETUP
-#line 182 "../SqlLexer.lpp"
+#line 183 "../SqlLexer.lpp"
 return TOKEN_CSB_TREE;
 	YY_BREAK
 case 22:
 YY_RULE_SETUP
-#line 183 "../SqlLexer.lpp"
+#line 184 "../SqlLexer.lpp"
 return TOKEN_BY;
 	YY_BREAK
 case 23:
 YY_RULE_SETUP
-#line 184 "../SqlLexer.lpp"
+#line 185 "../SqlLexer.lpp"
 return TOKEN_CHARACTER;
 	YY_BREAK
 case 24:
 YY_RULE_SETUP
-#line 185 "../SqlLexer.lpp"
+#line 186 "../SqlLexer.lpp"
 return TOKEN_CHARACTER;
 	YY_BREAK
 case 25:
 YY_RULE_SETUP
-#line 186 "../SqlLexer.lpp"
+#line 187 "../SqlLexer.lpp"
 return TOKEN_CHECK;
 	YY_BREAK
 case 26:
 YY_RULE_SETUP
-#line 187 "../SqlLexer.lpp"
+#line 188 "../SqlLexer.lpp"
 return TOKEN_COLUMN;
 	YY_BREAK
 case 27:
 YY_RULE_SETUP
-#line 188 "../SqlLexer.lpp"
+#line 189 "../SqlLexer.lpp"
 return TOKEN_CONSTRAINT;
 	YY_BREAK
 case 28:
 YY_RULE_SETUP
-#line 189 "../SqlLexer.lpp"
+#line 190 "../SqlLexer.lpp"
 return TOKEN_COPY;
 	YY_BREAK
 case 29:
 YY_RULE_SETUP
-#line 190 "../SqlLexer.lpp"
+#line 191 "../SqlLexer.lpp"
 return TOKEN_CREATE;
 	YY_BREAK
 case 30:
 YY_RULE_SETUP
-#line 191 "../SqlLexer.lpp"
+#line 192 "../SqlLexer.lpp"
 return TOKEN_DATE;
 	YY_BREAK
 case 31:
 YY_RULE_SETUP
-#line 192 "../SqlLexer.lpp"
+#line 193 "../SqlLexer.lpp"
 return TOKEN_DATETIME;
 	YY_BREAK
 case 32:
 YY_RULE_SETUP
-#line 193 "../SqlLexer.lpp"
+#line 194 "../SqlLexer.lpp"
 return TOKEN_DECIMAL;
 	YY_BREAK
 case 33:
 YY_RULE_SETUP
-#line 194 "../SqlLexer.lpp"
+#line 195 "../SqlLexer.lpp"
 return TOKEN_DEFAULT;
 	YY_BREAK
 case 34:
 YY_RULE_SETUP
-#line 195 "../SqlLexer.lpp"
+#line 196 "../SqlLexer.lpp"
 return TOKEN_DELETE;
 	YY_BREAK
 case 35:
 YY_RULE_SETUP
-#line 196 "../SqlLexer.lpp"
+#line 197 "../SqlLexer.lpp"
 return TOKEN_DELIMITER;
 	YY_BREAK
 case 36:
 YY_RULE_SETUP
-#line 197 "../SqlLexer.lpp"
+#line 198 "../SqlLexer.lpp"
 return TOKEN_DESC;
 	YY_BREAK
 case 37:
 YY_RULE_SETUP
-#line 198 "../SqlLexer.lpp"
+#line 199 "../SqlLexer.lpp"
 return TOKEN_DESC;
 	YY_BREAK
 case 38:
 YY_RULE_SETUP
-#line 199 "../SqlLexer.lpp"
+#line 200 "../SqlLexer.lpp"
 return TOKEN_DISTINCT;
 	YY_BREAK
 case 39:
 YY_RULE_SETUP
-#line 200 "../SqlLexer.lpp"
+#line 201 "../SqlLexer.lpp"
 return TOKEN_DOUBLE;
 	YY_BREAK
 case 40:
 YY_RULE_SETUP
-#line 201 "../SqlLexer.lpp"
+#line 202 "../SqlLexer.lpp"
 return TOKEN_DROP;
 	YY_BREAK
 case 41:
 YY_RULE_SETUP
-#line 202 "../SqlLexer.lpp"
+#line 203 "../SqlLexer.lpp"
 return TOKEN_ELSE;
 	YY_BREAK
 case 42:
 YY_RULE_SETUP
-#line 203 "../SqlLexer.lpp"
+#line 204 "../SqlLexer.lpp"
 return TOKEN_END;
 	YY_BREAK
 case 43:
 YY_RULE_SETUP
-#line 204 "../SqlLexer.lpp"
+#line 205 "../SqlLexer.lpp"
 return TOKEN_ESCAPE_STRINGS;
 	YY_BREAK
 case 44:
 YY_RULE_SETUP
-#line 205 "../SqlLexer.lpp"
+#line 206 "../SqlLexer.lpp"
 return TOKEN_EXISTS;
 	YY_BREAK
 case 45:
 YY_RULE_SETUP
-#line 206 "../SqlLexer.lpp"
+#line 207 "../SqlLexer.lpp"
 return TOKEN_EXTRACT;
 	YY_BREAK
 case 46:
 YY_RULE_SETUP
-#line 207 "../SqlLexer.lpp"
+#line 208 "../SqlLexer.lpp"
 return TOKEN_FALSE;
 	YY_BREAK
 case 47:
 YY_RULE_SETUP
-#line 208 "../SqlLexer.lpp"
+#line 209 "../SqlLexer.lpp"
 return TOKEN_FIRST;
 	YY_BREAK
 case 48:
 YY_RULE_SETUP
-#line 209 "../SqlLexer.lpp"
+#line 210 "../SqlLexer.lpp"
 return TOKEN_FLOAT;
 	YY_BREAK
 case 49:
 YY_RULE_SETUP
-#line 210 "../SqlLexer.lpp"
+#line 211 "../SqlLexer.lpp"
 return TOKEN_FOREIGN;
 	YY_BREAK
 case 50:
 YY_RULE_SETUP
-#line 211 "../SqlLexer.lpp"
+#line 212 "../SqlLexer.lpp"
 return TOKEN_FROM;
 	YY_BREAK
 case 51:
 YY_RULE_SETUP
-#line 212 "../SqlLexer.lpp"
+#line 213 "../SqlLexer.lpp"
 return TOKEN_FULL;
 	YY_BREAK
 case 52:
 YY_RULE_SETUP
-#line 213 "../SqlLexer.lpp"
+#line 214 "../SqlLexer.lpp"
 return TOKEN_GROUP;
 	YY_BREAK
 case 53:
 YY_RULE_SETUP
-#line 214 "../SqlLexer.lpp"
+#line 215 "../SqlLexer.lpp"
 return TOKEN_HASH;
 	YY_BREAK
 case 54:
 YY_RULE_SETUP
-#line 215 "../SqlLexer.lpp"
+#line 216 "../SqlLexer.lpp"
 return TOKEN_HAVING;
 	YY_BREAK
 case 55:
 YY_RULE_SETUP
-#line 216 "../SqlLexer.lpp"
+#line 217 "../SqlLexer.lpp"
 return TOKEN_IN;
 	YY_BREAK
 case 56:
 YY_RULE_SETUP
-#line 217 "../SqlLexer.lpp"
+#line 218 "../SqlLexer.lpp"
 return TOKEN_INDEX;
 	YY_BREAK
 case 57:
 YY_RULE_SETUP
-#line 218 "../SqlLexer.lpp"
+#line 219 "../SqlLexer.lpp"
 return TOKEN_INNER;
 	YY_BREAK
 case 58:
 YY_RULE_SETUP
-#line 219 "../SqlLexer.lpp"
+#line 220 "../SqlLexer.lpp"
 return TOKEN_INSERT;
 	YY_BREAK
 case 59:
 YY_RULE_SETUP
-#line 220 "../SqlLexer.lpp"
+#line 221 "../SqlLexer.lpp"
 return TOKEN_INTEGER;
 	YY_BREAK
 case 60:
 YY_RULE_SETUP
-#line 221 "../SqlLexer.lpp"
+#line 222 "../SqlLexer.lpp"
 return TOKEN_INTEGER;
 	YY_BREAK
 case 61:
 YY_RULE_SETUP
-#line 222 "../SqlLexer.lpp"
+#line 223 "../SqlLexer.lpp"
 return TOKEN_INTERVAL;
 	YY_BREAK
 case 62:
 YY_RULE_SETUP
-#line 223 "../SqlLexer.lpp"
+#line 224 "../SqlLexer.lpp"
 return TOKEN_INTO;
 	YY_BREAK
 case 63:
 YY_RULE_SETUP
-#line 224 "../SqlLexer.lpp"
+#line 225 "../SqlLexer.lpp"
 return TOKEN_IS;
 	YY_BREAK
 case 64:
 YY_RULE_SETUP
-#line 225 "../SqlLexer.lpp"
+#line 226 "../SqlLexer.lpp"
 return TOKEN_JOIN;
 	YY_BREAK
 case 65:
 YY_RULE_SETUP
-#line 226 "../SqlLexer.lpp"
+#line 227 "../SqlLexer.lpp"
 return TOKEN_KEY;
 	YY_BREAK
 case 66:
 YY_RULE_SETUP
-#line 227 "../SqlLexer.lpp"
+#line 228 "../SqlLexer.lpp"
 return TOKEN_LAST;
 	YY_BREAK
 case 67:
 YY_RULE_SETUP
-#line 228 "../SqlLexer.lpp"
+#line 229 "../SqlLexer.lpp"
 return TOKEN_LEFT;
 	YY_BREAK
 case 68:
 YY_RULE_SETUP
-#line 229 "../SqlLexer.lpp"
+#line 230 "../SqlLexer.lpp"
 return TOKEN_LIKE;
 	YY_BREAK
 case 69:
 YY_RULE_SETUP
-#line 230 "../SqlLexer.lpp"
+#line 231 "../SqlLexer.lpp"
 return TOKEN_LIMIT;
 	YY_BREAK
 case 70:
 YY_RULE_SETUP
-#line 231 "../SqlLexer.lpp"
+#line 232 "../SqlLexer.lpp"
 return TOKEN_LONG;
 	YY_BREAK
 case 71:
 YY_RULE_SETUP
-#line 232 "../SqlLexer.lpp"
+#line 233 "../SqlLexer.lpp"
 return TOKEN_NOT;
 	YY_BREAK
 case 72:
 YY_RULE_SETUP
-#line 233 "../SqlLexer.lpp"
+#line 234 "../SqlLexer.lpp"
 return TOKEN_NULL;
 	YY_BREAK
 case 73:
 YY_RULE_SETUP
-#line 234 "../SqlLexer.lpp"
+#line 235 "../SqlLexer.lpp"
 return TOKEN_NULLS;
 	YY_BREAK
 case 74:
 YY_RULE_SETUP
-#line 235 "../SqlLexer.lpp"
+#line 236 "../SqlLexer.lpp"
 return TOKEN_OFF;
 	YY_BREAK
 case 75:
 YY_RULE_SETUP
-#line 236 "../SqlLexer.lpp"
+#line 237 "../SqlLexer.lpp"
 return TOKEN_ON;
 	YY_BREAK
 case 76:
 YY_RULE_SETUP
-#line 237 "../SqlLexer.lpp"
+#line 238 "../SqlLexer.lpp"
 return TOKEN_OR;
 	YY_BREAK
 case 77:
 YY_RULE_SETUP
-#line 238 "../SqlLexer.lpp"
+#line 239 "../SqlLexer.lpp"
 return TOKEN_ORDER;
 	YY_BREAK
 case 78:
 YY_RULE_SETUP
-#line 239 "../SqlLexer.lpp"
+#line 240 "../SqlLexer.lpp"
 return TOKEN_OUTER;
 	YY_BREAK
 case 79:
 YY_RULE_SETUP
-#line 240 "../SqlLexer.lpp"
+#line 241 "../SqlLexer.lpp"
 return TOKEN_PARTITION;
 	YY_BREAK
 case 80:
 YY_RULE_SETUP
-#line 241 "../SqlLexer.lpp"
+#line 242 "../SqlLexer.lpp"
 return TOKEN_PARTITIONS;
 	YY_BREAK
 case 81:
 YY_RULE_SETUP
-#line 242 "../SqlLexer.lpp"
+#line 243 "../SqlLexer.lpp"
 return TOKEN_PERCENT;
 	YY_BREAK
 case 82:
 YY_RULE_SETUP
-#line 243 "../SqlLexer.lpp"
+#line 244 "../SqlLexer.lpp"
 return TOKEN_PRIMARY;
 	YY_BREAK
 case 83:
 YY_RULE_SETUP
-#line 244 "../SqlLexer.lpp"
+#line 245 "../SqlLexer.lpp"
 return TOKEN_QUIT;
 	YY_BREAK
 case 84:
 YY_RULE_SETUP
-#line 245 "../SqlLexer.lpp"
+#line 246 "../SqlLexer.lpp"
 return TOKEN_RANGE;
 	YY_BREAK
 case 85:
 YY_RULE_SETUP
-#line 246 "../SqlLexer.lpp"
+#line 247 "../SqlLexer.lpp"
 return TOKEN_REAL;
 	YY_BREAK
 case 86:
 YY_RULE_SETUP
-#line 247 "../SqlLexer.lpp"
+#line 248 "../SqlLexer.lpp"
 return TOKEN_REFERENCES;
 	YY_BREAK
 case 87:
 YY_RULE_SETUP
-#line 248 "../SqlLexer.lpp"
+#line 249 "../SqlLexer.lpp"
 return TOKEN_REGEXP;
 	YY_BREAK
 case 88:
 YY_RULE_SETUP
-#line 249 "../SqlLexer.lpp"
+#line 250 "../SqlLexer.lpp"
 return TOKEN_RIGHT;
 	YY_BREAK
 case 89:
 YY_RULE_SETUP
-#line 250 "../SqlLexer.lpp"
+#line 251 "../SqlLexer.lpp"
 return TOKEN_ROW_DELIMITER;
 	YY_BREAK
 case 90:
 YY_RULE_SETUP
-#line 251 "../SqlLexer.lpp"
+#line 252 "../SqlLexer.lpp"
 return TOKEN_SELECT;
 	YY_BREAK
 case 91:
 YY_RULE_SETUP
-#line 252 "../SqlLexer.lpp"
+#line 253 "../SqlLexer.lpp"
 return TOKEN_SET;
 	YY_BREAK
 case 92:
 YY_RULE_SETUP
-#line 253 "../SqlLexer.lpp"
+#line 254 "../SqlLexer.lpp"
 return TOKEN_SMA;
 	YY_BREAK
 case 93:
 YY_RULE_SETUP
-#line 254 "../SqlLexer.lpp"
+#line 255 "../SqlLexer.lpp"
 return TOKEN_SMALLINT;
 	YY_BREAK
 case 94:
 YY_RULE_SETUP
-#line 255 "../SqlLexer.lpp"
+#line 256 "../SqlLexer.lpp"
 return TOKEN_TABLE;
 	YY_BREAK
 case 95:
 YY_RULE_SETUP
-#line 256 "../SqlLexer.lpp"
+#line 257 "../SqlLexer.lpp"
 return TOKEN_THEN;
 	YY_BREAK
 case 96:
 YY_RULE_SETUP
-#line 257 "../SqlLexer.lpp"
+#line 258 "../SqlLexer.lpp"
 return TOKEN_TIME;
 	YY_BREAK
 case 97:
 YY_RULE_SETUP
-#line 258 "../SqlLexer.lpp"
+#line 259 "../SqlLexer.lpp"
 return TOKEN_TIMESTAMP;
 	YY_BREAK
 case 98:
 YY_RULE_SETUP
-#line 259 "../SqlLexer.lpp"
+#line 260 "../SqlLexer.lpp"
 return TOKEN_TRUE;
 	YY_BREAK
 case 99:
 YY_RULE_SETUP
-#line 260 "../SqlLexer.lpp"
+#line 261 "../SqlLexer.lpp"
 return TOKEN_TUPLESAMPLE;
 	YY_BREAK
 case 100:
 YY_RULE_SETUP
-#line 261 "../SqlLexer.lpp"
+#line 262 "../SqlLexer.lpp"
 return TOKEN_UNIQUE;
 	YY_BREAK
 case 101:
 YY_RULE_SETUP
-#line 262 "../SqlLexer.lpp"
+#line 263 "../SqlLexer.lpp"
 return TOKEN_UPDATE;
 	YY_BREAK
 case 102:
 YY_RULE_SETUP
-#line 263 "../SqlLexer.lpp"
+#line 264 "../SqlLexer.lpp"
 return TOKEN_USING;
 	YY_BREAK
 case 103:
 YY_RULE_SETUP
-#line 264 "../SqlLexer.lpp"
+#line 265 "../SqlLexer.lpp"
 return TOKEN_VALUES;
 	YY_BREAK
 case 104:
 YY_RULE_SETUP
-#line 265 "../SqlLexer.lpp"
+#line 266 "../SqlLexer.lpp"
 return TOKEN_VARCHAR;
 	YY_BREAK
 case 105:
 YY_RULE_SETUP
-#line 266 "../SqlLexer.lpp"
+#line 267 "../SqlLexer.lpp"
 return TOKEN_WHEN;
 	YY_BREAK
 case 106:
 YY_RULE_SETUP
-#line 267 "../SqlLexer.lpp"
+#line 268 "../SqlLexer.lpp"
 return TOKEN_WHERE;
 	YY_BREAK
 case 107:
 YY_RULE_SETUP
-#line 268 "../SqlLexer.lpp"
+#line 269 "../SqlLexer.lpp"
 return TOKEN_WITH;
 	YY_BREAK
 case 108:
 YY_RULE_SETUP
-#line 269 "../SqlLexer.lpp"
+#line 270 "../SqlLexer.lpp"
 return TOKEN_YEARMONTH;
 	YY_BREAK
 case 109:
 YY_RULE_SETUP
-#line 271 "../SqlLexer.lpp"
+#line 272 "../SqlLexer.lpp"
 return TOKEN_EQ;
 	YY_BREAK
 case 110:
 YY_RULE_SETUP
-#line 272 "../SqlLexer.lpp"
+#line 273 "../SqlLexer.lpp"
 return TOKEN_NEQ;
 	YY_BREAK
 case 111:
 YY_RULE_SETUP
-#line 273 "../SqlLexer.lpp"
+#line 274 "../SqlLexer.lpp"
 return TOKEN_NEQ;
 	YY_BREAK
 case 112:
 YY_RULE_SETUP
-#line 274 "../SqlLexer.lpp"
+#line 275 "../SqlLexer.lpp"
 return TOKEN_LT;
 	YY_BREAK
 case 113:
 YY_RULE_SETUP
-#line 275 "../SqlLexer.lpp"
+#line 276 "../SqlLexer.lpp"
 return TOKEN_GT;
 	YY_BREAK
 case 114:
 YY_RULE_SETUP
-#line 276 "../SqlLexer.lpp"
+#line 277 "../SqlLexer.lpp"
 return TOKEN_LEQ;
 	YY_BREAK
 case 115:
 YY_RULE_SETUP
-#line 277 "../SqlLexer.lpp"
+#line 278 "../SqlLexer.lpp"
 return TOKEN_GEQ;
 	YY_BREAK
 case 116:
 YY_RULE_SETUP
-#line 279 "../SqlLexer.lpp"
+#line 280 "../SqlLexer.lpp"
 return yytext[0];
 	YY_BREAK
 case 117:
 YY_RULE_SETUP
-#line 280 "../SqlLexer.lpp"
+#line 281 "../SqlLexer.lpp"
 return yytext[0];
 	YY_BREAK
 /**
@@ -2008,7 +2009,7 @@ return yytext[0];
     **/
 case 118:
 YY_RULE_SETUP
-#line 286 "../SqlLexer.lpp"
+#line 287 "../SqlLexer.lpp"
 {
     yylval->string_value_ = new quickstep::ParseString(yylloc->first_line, yylloc->first_column);
     BEGIN(CONDITION_STRING_SINGLE_QUOTED_ESCAPED);
@@ -2016,7 +2017,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 119:
 YY_RULE_SETUP
-#line 291 "../SqlLexer.lpp"
+#line 292 "../SqlLexer.lpp"
 {
     yylval->string_value_ = new quickstep::ParseString(yylloc->first_line, yylloc->first_column);
     BEGIN(CONDITION_STRING_SINGLE_QUOTED);
@@ -2024,7 +2025,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 120:
 YY_RULE_SETUP
-#line 296 "../SqlLexer.lpp"
+#line 297 "../SqlLexer.lpp"
 {
     yylval->string_value_ = new quickstep::ParseString(yylloc->first_line, yylloc->first_column);
     BEGIN(CONDITION_STRING_DOUBLE_QUOTED);
@@ -2036,7 +2037,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 305 "../SqlLexer.lpp"
+#line 306 "../SqlLexer.lpp"
 {
     delete yylval->string_value_;
     BEGIN(INITIAL);
@@ -2049,7 +2050,7 @@ case YY_STATE_EOF(CONDITION_STRING_DOUBLE_QUOTED):
 
 case 121:
 YY_RULE_SETUP
-#line 315 "../SqlLexer.lpp"
+#line 316 "../SqlLexer.lpp"
 {
     /* Octal code */
     unsigned int code;
@@ -2065,7 +2066,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 122:
 YY_RULE_SETUP
-#line 327 "../SqlLexer.lpp"
+#line 328 "../SqlLexer.lpp"
 {
     /* Hexadecimal code */
     unsigned int code;
@@ -2075,7 +2076,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 123:
 YY_RULE_SETUP
-#line 333 "../SqlLexer.lpp"
+#line 334 "../SqlLexer.lpp"
 {
     /* A numeric escape sequence that isn't correctly specified. */
     delete yylval->string_value_;
@@ -2086,7 +2087,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 124:
 YY_RULE_SETUP
-#line 340 "../SqlLexer.lpp"
+#line 341 "../SqlLexer.lpp"
 {
     /* Backspace */
     yylval->string_value_->push_back('\b');
@@ -2094,7 +2095,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 125:
 YY_RULE_SETUP
-#line 344 "../SqlLexer.lpp"
+#line 345 "../SqlLexer.lpp"
 {
     /* Form-feed */
     yylval->string_value_->push_back('\f');
@@ -2102,7 +2103,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 126:
 YY_RULE_SETUP
-#line 348 "../SqlLexer.lpp"
+#line 349 "../SqlLexer.lpp"
 {
     /* Newline */
     yylval->string_value_->push_back('\n');
@@ -2110,7 +2111,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 127:
 YY_RULE_SETUP
-#line 352 "../SqlLexer.lpp"
+#line 353 "../SqlLexer.lpp"
 {
     /* Carriage-return */
     yylval->string_value_->push_back('\r');
@@ -2118,7 +2119,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 128:
 YY_RULE_SETUP
-#line 356 "../SqlLexer.lpp"
+#line 357 "../SqlLexer.lpp"
 {
     /* Horizontal Tab */
     yylval->string_value_->push_back('\t');
@@ -2127,7 +2128,7 @@ YY_RULE_SETUP
 case 129:
 /* rule 129 can match eol */
 YY_RULE_SETUP
-#line 360 "../SqlLexer.lpp"
+#line 361 "../SqlLexer.lpp"
 {
     /* Any other character (including actual newline or carriage return) */
     yylval->string_value_->push_back(yytext[1]);
@@ -2135,7 +2136,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 130:
 YY_RULE_SETUP
-#line 364 "../SqlLexer.lpp"
+#line 365 "../SqlLexer.lpp"
 {
     /* This should only be encountered right before an EOF. */
     delete yylval->string_value_;
@@ -2148,7 +2149,7 @@ YY_RULE_SETUP
 
 case 131:
 YY_RULE_SETUP
-#line 374 "../SqlLexer.lpp"
+#line 375 "../SqlLexer.lpp"
 {
     /* Two quotes in a row become a single quote (this is specified by the SQL standard). */
     yylval->string_value_->push_back('\'');
@@ -2156,7 +2157,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 132:
 YY_RULE_SETUP
-#line 378 "../SqlLexer.lpp"
+#line 379 "../SqlLexer.lpp"
 {
     /* End string */
     BEGIN(CONDITION_SQL);
@@ -2167,7 +2168,7 @@ YY_RULE_SETUP
 
 case 133:
 YY_RULE_SETUP
-#line 386 "../SqlLexer.lpp"
+#line 387 "../SqlLexer.lpp"
 {
     /* Two quotes in a row become a single quote (this is specified by the SQL standard). */
     yylval->string_value_->push_back('"');
@@ -2175,7 +2176,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 134:
 YY_RULE_SETUP
-#line 390 "../SqlLexer.lpp"
+#line 391 "../SqlLexer.lpp"
 {
     /* End string */
     BEGIN(CONDITION_SQL);
@@ -2186,7 +2187,7 @@ YY_RULE_SETUP
 case 135:
 /* rule 135 can match eol */
 YY_RULE_SETUP
-#line 397 "../SqlLexer.lpp"
+#line 398 "../SqlLexer.lpp"
 {
   /* Scan up to a quote. */
   yylval->string_value_->append(yytext, yyleng);
@@ -2195,7 +2196,7 @@ YY_RULE_SETUP
 case 136:
 /* rule 136 can match eol */
 YY_RULE_SETUP
-#line 402 "../SqlLexer.lpp"
+#line 403 "../SqlLexer.lpp"
 {
   /* Scan up to a quote or escape sequence. */
   yylval->string_value_->append(yytext, yyleng);
@@ -2204,7 +2205,7 @@ YY_RULE_SETUP
 case 137:
 /* rule 137 can match eol */
 YY_RULE_SETUP
-#line 407 "../SqlLexer.lpp"
+#line 408 "../SqlLexer.lpp"
 {
   /* Scan up to a quote. */
   yylval->string_value_->append(yytext, yyleng);
@@ -2213,7 +2214,7 @@ YY_RULE_SETUP
 
 case 138:
 YY_RULE_SETUP
-#line 413 "../SqlLexer.lpp"
+#line 414 "../SqlLexer.lpp"
 {
     yylval->string_value_ = new quickstep::ParseString(
         yylloc->first_line, yylloc->first_column, std::string(yytext, yyleng));
@@ -2222,7 +2223,7 @@ YY_RULE_SETUP
 	YY_BREAK
 case 139:
 YY_RULE_SETUP
-#line 419 "../SqlLexer.lpp"
+#line 420 "../SqlLexer.lpp"
 {
     yylval->numeric_literal_value_ = new quickstep::NumericParseLiteralValue(
         yylloc->first_line, yylloc->first_column, yytext);
@@ -2231,25 +2232,25 @@ YY_RULE_SETUP
 	YY_BREAK
 case 140:
 YY_RULE_SETUP
-#line 425 "../SqlLexer.lpp"
+#line 426 "../SqlLexer.lpp"
 /* comment */
 	YY_BREAK
 case 141:
 /* rule 141 can match eol */
 YY_RULE_SETUP
-#line 427 "../SqlLexer.lpp"
+#line 428 "../SqlLexer.lpp"
 { yycolumn = 0; }
 	YY_BREAK
 case 142:
 YY_RULE_SETUP
-#line 429 "../SqlLexer.lpp"
+#line 430 "../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 433 "../SqlLexer.lpp"
+#line 434 "../SqlLexer.lpp"
 {
   /* All conditions except for mutli-state string extracting conditions. */
   BEGIN(INITIAL);
@@ -2258,7 +2259,7 @@ case YY_STATE_EOF(CONDITION_SQL):
 	YY_BREAK
 case 143:
 YY_RULE_SETUP
-#line 439 "../SqlLexer.lpp"
+#line 440 "../SqlLexer.lpp"
 {
   BEGIN(INITIAL);
   quickstep_yyerror(NULL, yyscanner, NULL, "illegal character");
@@ -2267,10 +2268,10 @@ YY_RULE_SETUP
 	YY_BREAK
 case 144:
 YY_RULE_SETUP
-#line 445 "../SqlLexer.lpp"
+#line 446 "../SqlLexer.lpp"
 YY_FATAL_ERROR( "flex scanner jammed" );
 	YY_BREAK
-#line 2274 "SqlLexer_gen.cpp"
+#line 2275 "SqlLexer_gen.cpp"
 
 	case YY_END_OF_BUFFER:
 		{
@@ -3431,7 +3432,7 @@ void quickstep_yyfree (void * ptr , yyscan_t yyscanner)
 
 #define YYTABLES_NAME "yytables"
 
-#line 445 "../SqlLexer.lpp"
+#line 446 "../SqlLexer.lpp"
 
 
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/parser/preprocessed/SqlLexer_gen.hpp
----------------------------------------------------------------------
diff --git a/parser/preprocessed/SqlLexer_gen.hpp b/parser/preprocessed/SqlLexer_gen.hpp
index de44998..b30d697 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 445 "../SqlLexer.lpp"
+#line 446 "../SqlLexer.lpp"
 
 
 #line 367 "SqlLexer_gen.hpp"



[12/24] incubator-quickstep git commit: Adds support for IN predicate (#167)

Posted by zu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/parser/preprocessed/SqlParser_gen.hpp
----------------------------------------------------------------------
diff --git a/parser/preprocessed/SqlParser_gen.hpp b/parser/preprocessed/SqlParser_gen.hpp
index 9447a22..807a39b 100644
--- a/parser/preprocessed/SqlParser_gen.hpp
+++ b/parser/preprocessed/SqlParser_gen.hpp
@@ -1,8 +1,8 @@
-/* A Bison parser, made by GNU Bison 3.0.2.  */
+/* A Bison parser, made by GNU Bison 3.0.4.  */
 
 /* Bison interface for Yacc-like parsers in C
 
-   Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
+   Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -108,64 +108,65 @@ extern int quickstep_yydebug;
     TOKEN_GROUP = 318,
     TOKEN_HASH = 319,
     TOKEN_HAVING = 320,
-    TOKEN_INDEX = 321,
-    TOKEN_INNER = 322,
-    TOKEN_INSERT = 323,
-    TOKEN_INTEGER = 324,
-    TOKEN_INTERVAL = 325,
-    TOKEN_INTO = 326,
-    TOKEN_JOIN = 327,
-    TOKEN_KEY = 328,
-    TOKEN_LAST = 329,
-    TOKEN_LEFT = 330,
-    TOKEN_LIMIT = 331,
-    TOKEN_LONG = 332,
-    TOKEN_NULL = 333,
-    TOKEN_NULLS = 334,
-    TOKEN_OFF = 335,
-    TOKEN_ON = 336,
-    TOKEN_ORDER = 337,
-    TOKEN_OUTER = 338,
-    TOKEN_PARTITION = 339,
-    TOKEN_PARTITIONS = 340,
-    TOKEN_PERCENT = 341,
-    TOKEN_PRIMARY = 342,
-    TOKEN_QUIT = 343,
-    TOKEN_RANGE = 344,
-    TOKEN_REAL = 345,
-    TOKEN_REFERENCES = 346,
-    TOKEN_RIGHT = 347,
-    TOKEN_ROW_DELIMITER = 348,
-    TOKEN_SELECT = 349,
-    TOKEN_SET = 350,
-    TOKEN_SMA = 351,
-    TOKEN_SMALLINT = 352,
-    TOKEN_TABLE = 353,
-    TOKEN_THEN = 354,
-    TOKEN_TIME = 355,
-    TOKEN_TIMESTAMP = 356,
-    TOKEN_TRUE = 357,
-    TOKEN_TUPLESAMPLE = 358,
-    TOKEN_UNIQUE = 359,
-    TOKEN_UPDATE = 360,
-    TOKEN_USING = 361,
-    TOKEN_VALUES = 362,
-    TOKEN_VARCHAR = 363,
-    TOKEN_WHEN = 364,
-    TOKEN_WHERE = 365,
-    TOKEN_WITH = 366,
-    TOKEN_YEARMONTH = 367,
-    TOKEN_EOF = 368,
-    TOKEN_LEX_ERROR = 369
+    TOKEN_IN = 321,
+    TOKEN_INDEX = 322,
+    TOKEN_INNER = 323,
+    TOKEN_INSERT = 324,
+    TOKEN_INTEGER = 325,
+    TOKEN_INTERVAL = 326,
+    TOKEN_INTO = 327,
+    TOKEN_JOIN = 328,
+    TOKEN_KEY = 329,
+    TOKEN_LAST = 330,
+    TOKEN_LEFT = 331,
+    TOKEN_LIMIT = 332,
+    TOKEN_LONG = 333,
+    TOKEN_NULL = 334,
+    TOKEN_NULLS = 335,
+    TOKEN_OFF = 336,
+    TOKEN_ON = 337,
+    TOKEN_ORDER = 338,
+    TOKEN_OUTER = 339,
+    TOKEN_PARTITION = 340,
+    TOKEN_PARTITIONS = 341,
+    TOKEN_PERCENT = 342,
+    TOKEN_PRIMARY = 343,
+    TOKEN_QUIT = 344,
+    TOKEN_RANGE = 345,
+    TOKEN_REAL = 346,
+    TOKEN_REFERENCES = 347,
+    TOKEN_RIGHT = 348,
+    TOKEN_ROW_DELIMITER = 349,
+    TOKEN_SELECT = 350,
+    TOKEN_SET = 351,
+    TOKEN_SMA = 352,
+    TOKEN_SMALLINT = 353,
+    TOKEN_TABLE = 354,
+    TOKEN_THEN = 355,
+    TOKEN_TIME = 356,
+    TOKEN_TIMESTAMP = 357,
+    TOKEN_TRUE = 358,
+    TOKEN_TUPLESAMPLE = 359,
+    TOKEN_UNIQUE = 360,
+    TOKEN_UPDATE = 361,
+    TOKEN_USING = 362,
+    TOKEN_VALUES = 363,
+    TOKEN_VARCHAR = 364,
+    TOKEN_WHEN = 365,
+    TOKEN_WHERE = 366,
+    TOKEN_WITH = 367,
+    TOKEN_YEARMONTH = 368,
+    TOKEN_EOF = 369,
+    TOKEN_LEX_ERROR = 370
   };
 #endif
 
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-typedef union YYSTYPE YYSTYPE;
+
 union YYSTYPE
 {
-#line 116 "../SqlParser.ypp" /* yacc.c:1909  */
+#line 117 "../SqlParser.ypp" /* yacc.c:1915  */
 
   quickstep::ParseString *string_value_;
 
@@ -255,8 +256,10 @@ union YYSTYPE
   quickstep::PtrVector<quickstep::ParseSubqueryTableReference> *with_list_;
   quickstep::ParseSubqueryTableReference *with_list_element_;
 
-#line 259 "SqlParser_gen.hpp" /* yacc.c:1909  */
+#line 260 "SqlParser_gen.hpp" /* yacc.c:1915  */
 };
+
+typedef union YYSTYPE YYSTYPE;
 # define YYSTYPE_IS_TRIVIAL 1
 # define YYSTYPE_IS_DECLARED 1
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/parser/tests/Select.test
----------------------------------------------------------------------
diff --git a/parser/tests/Select.test b/parser/tests/Select.test
index 18c3f0d..8a10a12 100644
--- a/parser/tests/Select.test
+++ b/parser/tests/Select.test
@@ -1555,3 +1555,133 @@ SelectStatement
   |       +-right_operand=AttributeReference[attribute_name=col4]
   +-from_clause=
     +-TableReference[table=test]
+==
+
+# IN predicate
+SELECT *
+FROM test 
+WHERE col1 IN (1, 3, 5);
+--
+SelectStatement
++-select_query=Select
+  +-select_clause=SelectStar
+  +-where_clause=InValueList
+  | +-test_expression=AttributeReference[attribute_name=col1]
+  | +-value_list=
+  |   +-Literal
+  |   | +-NumericLiteral[numeric_string=1,float_like=false]
+  |   +-Literal
+  |   | +-NumericLiteral[numeric_string=3,float_like=false]
+  |   +-Literal
+  |     +-NumericLiteral[numeric_string=5,float_like=false]
+  +-from_clause=
+    +-TableReference[table=test]
+==
+
+SELECT *
+FROM test
+WHERE col1 IN (FUN(1),
+               col2+col3,
+               CASE WHEN col4 > 0 THEN col5 ELSE col6 END);
+--
+SelectStatement
++-select_query=Select
+  +-select_clause=SelectStar
+  +-where_clause=InValueList
+  | +-test_expression=AttributeReference[attribute_name=col1]
+  | +-value_list=
+  |   +-FunctionCall[name=FUN]
+  |   | +-Literal
+  |   |   +-NumericLiteral[numeric_string=1,float_like=false]
+  |   +-Add
+  |   | +-left_operand=AttributeReference[attribute_name=col2]
+  |   | +-right_operand=AttributeReference[attribute_name=col3]
+  |   +-SearchedCaseExpression
+  |     +-else_result_expression=AttributeReference[attribute_name=col6]
+  |     +-when_clauses=
+  |       +-SearchedWhenClause
+  |         +-condition_predicate=Greater
+  |         | +-left_operand=AttributeReference[attribute_name=col4]
+  |         | +-right_operand=Literal
+  |         |   +-NumericLiteral[numeric_string=0,float_like=false]
+  |         +-result_expression=AttributeReference[attribute_name=col5]
+  +-from_clause=
+    +-TableReference[table=test]
+==
+
+SELECT *
+FROM test
+WHERE col1 NOT IN (col1, col2 + col3);
+--
+SelectStatement
++-select_query=Select
+  +-select_clause=SelectStar
+  +-where_clause=Not
+  | +-InValueList
+  |   +-test_expression=AttributeReference[attribute_name=col1]
+  |   +-value_list=
+  |     +-AttributeReference[attribute_name=col1]
+  |     +-Add
+  |       +-left_operand=AttributeReference[attribute_name=col2]
+  |       +-right_operand=AttributeReference[attribute_name=col3]
+  +-from_clause=
+    +-TableReference[table=test]
+==
+
+SELECT *
+FROM test
+WHERE col1 IN (
+  SELECT SUM(col2+col3)
+  FROM bar
+  GROUP BY col4
+);
+--
+SelectStatement
++-select_query=Select
+  +-select_clause=SelectStar
+  +-where_clause=InTableQuery
+  | +-test_expression=AttributeReference[attribute_name=col1]
+  | +-table_query=SubqueryExpression
+  |   +-Select
+  |     +-select_clause=SelectList
+  |     | +-SelectListItem
+  |     |   +-FunctionCall[name=SUM]
+  |     |     +-Add
+  |     |       +-left_operand=AttributeReference[attribute_name=col2]
+  |     |       +-right_operand=AttributeReference[attribute_name=col3]
+  |     +-group_by=GroupBy
+  |     | +-AttributeReference[attribute_name=col4]
+  |     +-from_clause=
+  |       +-TableReference[table=bar]
+  +-from_clause=
+    +-TableReference[table=test]
+==
+
+SELECT *
+FROM test
+WHERE col1 NOT IN (
+  SELECT col2
+  FROM bar
+  WHERE col3 IN (col4, col5)
+);
+--
+SelectStatement
++-select_query=Select
+  +-select_clause=SelectStar
+  +-where_clause=Not
+  | +-InTableQuery
+  |   +-test_expression=AttributeReference[attribute_name=col1]
+  |   +-table_query=SubqueryExpression
+  |     +-Select
+  |       +-select_clause=SelectList
+  |       | +-SelectListItem
+  |       |   +-AttributeReference[attribute_name=col2]
+  |       +-where_clause=InValueList
+  |       | +-test_expression=AttributeReference[attribute_name=col3]
+  |       | +-value_list=
+  |       |   +-AttributeReference[attribute_name=col4]
+  |       |   +-AttributeReference[attribute_name=col5]
+  |       +-from_clause=
+  |         +-TableReference[table=bar]
+  +-from_clause=
+    +-TableReference[table=test]

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/parser/tests/TPCH.test
----------------------------------------------------------------------
diff --git a/parser/tests/TPCH.test b/parser/tests/TPCH.test
index 45071e4..dfcd6aa 100644
--- a/parser/tests/TPCH.test
+++ b/parser/tests/TPCH.test
@@ -974,7 +974,7 @@ FROM
   lineitem
 WHERE
   o_orderkey = l_orderkey
-  AND l_shipmode in ('REG AIR', 'RAIL')
+  AND l_shipmode IN ('REG AIR', 'RAIL')
   AND l_commitdate < l_receiptdate
   AND l_shipdate < l_commitdate
   AND l_receiptdate >= DATE '1997-01-01'
@@ -984,9 +984,87 @@ GROUP BY
 ORDER BY
   l_shipmode
 --
-ERROR: syntax error (20 : 18)
-  AND l_shipmode in ('REG AIR', 'RAIL')
-                 ^
+SelectStatement
++-select_query=Select
+  +-select_clause=SelectList
+  | +-SelectListItem
+  | | +-AttributeReference[attribute_name=l_shipmode]
+  | +-SelectListItem[alias=high_line_count]
+  | | +-FunctionCall[name=SUM]
+  | |   +-SearchedCaseExpression
+  | |     +-else_result_expression=Literal
+  | |     | +-NumericLiteral[numeric_string=0,float_like=false]
+  | |     +-when_clauses=
+  | |       +-SearchedWhenClause
+  | |         +-condition_predicate=Or
+  | |         | +-Equal
+  | |         | | +-left_operand=AttributeReference[
+  | |         | | | attribute_name=o_orderpriority]
+  | |         | | +-right_operand=Literal
+  | |         | |   +-StringLiteral[value=1-URGENT]
+  | |         | +-Equal
+  | |         |   +-left_operand=AttributeReference[
+  | |         |   | attribute_name=o_orderpriority]
+  | |         |   +-right_operand=Literal
+  | |         |     +-StringLiteral[value=2-HIGH]
+  | |         +-result_expression=Literal
+  | |           +-NumericLiteral[numeric_string=1,float_like=false]
+  | +-SelectListItem[alias=low_line_count]
+  |   +-FunctionCall[name=SUM]
+  |     +-SearchedCaseExpression
+  |       +-else_result_expression=Literal
+  |       | +-NumericLiteral[numeric_string=0,float_like=false]
+  |       +-when_clauses=
+  |         +-SearchedWhenClause
+  |           +-condition_predicate=And
+  |           | +-NotEqual
+  |           | | +-left_operand=AttributeReference[
+  |           | | | attribute_name=o_orderpriority]
+  |           | | +-right_operand=Literal
+  |           | |   +-StringLiteral[value=1-URGENT]
+  |           | +-NotEqual
+  |           |   +-left_operand=AttributeReference[
+  |           |   | attribute_name=o_orderpriority]
+  |           |   +-right_operand=Literal
+  |           |     +-StringLiteral[value=2-HIGH]
+  |           +-result_expression=Literal
+  |             +-NumericLiteral[numeric_string=1,float_like=false]
+  +-where_clause=And
+  | +-Equal
+  | | +-left_operand=AttributeReference[attribute_name=o_orderkey]
+  | | +-right_operand=AttributeReference[attribute_name=l_orderkey]
+  | +-InValueList
+  | | +-test_expression=AttributeReference[attribute_name=l_shipmode]
+  | | +-value_list=
+  | |   +-Literal
+  | |   | +-StringLiteral[value=REG AIR]
+  | |   +-Literal
+  | |     +-StringLiteral[value=RAIL]
+  | +-Less
+  | | +-left_operand=AttributeReference[attribute_name=l_commitdate]
+  | | +-right_operand=AttributeReference[attribute_name=l_receiptdate]
+  | +-Less
+  | | +-left_operand=AttributeReference[attribute_name=l_shipdate]
+  | | +-right_operand=AttributeReference[attribute_name=l_commitdate]
+  | +-GreaterOrEqual
+  | | +-left_operand=AttributeReference[attribute_name=l_receiptdate]
+  | | +-right_operand=Literal
+  | |   +-StringLiteral[value=1997-01-01,explicit_type=Datetime]
+  | +-Less
+  |   +-left_operand=AttributeReference[attribute_name=l_receiptdate]
+  |   +-right_operand=Add
+  |     +-left_operand=Literal
+  |     | +-StringLiteral[value=1997-01-01,explicit_type=Datetime]
+  |     +-right_operand=Literal
+  |       +-StringLiteral[value=1 year,explicit_type=YearMonthInterval]
+  +-group_by=GroupBy
+  | +-AttributeReference[attribute_name=l_shipmode]
+  +-order_by=OrderBy
+  | +-OrderByItem[is_asc=true,nulls_first=false]
+  |   +-AttributeReference[attribute_name=l_shipmode]
+  +-from_clause=
+    +-TableReference[table=orders]
+    +-TableReference[table=lineitem]
 ==
 
 # Query 13
@@ -1152,9 +1230,79 @@ ORDER BY
   p_type,
   p_size
 --
-ERROR: syntax error (13 : 14)
-  AND p_size IN (32, 42, 9, 18, 50, 30, 12,...
-             ^
+SelectStatement
++-select_query=Select
+  +-select_clause=SelectList
+  | +-SelectListItem
+  | | +-AttributeReference[attribute_name=p_brand]
+  | +-SelectListItem
+  | | +-AttributeReference[attribute_name=p_type]
+  | +-SelectListItem
+  | | +-AttributeReference[attribute_name=p_size]
+  | +-SelectListItem[alias=supplier_cnt]
+  |   +-FunctionCall[name=COUNT,is_distinct=true]
+  |     +-AttributeReference[attribute_name=ps_suppkey]
+  +-where_clause=And
+  | +-Equal
+  | | +-left_operand=AttributeReference[attribute_name=p_partkey]
+  | | +-right_operand=AttributeReference[attribute_name=ps_partkey]
+  | +-NotEqual
+  | | +-left_operand=AttributeReference[attribute_name=p_brand]
+  | | +-right_operand=Literal
+  | |   +-StringLiteral[value=Brand#22]
+  | +-NotLike
+  | | +-left_operand=AttributeReference[attribute_name=p_type]
+  | | +-right_operand=Literal
+  | |   +-StringLiteral[value=ECONOMY BURNISHED%]
+  | +-InValueList
+  | | +-test_expression=AttributeReference[attribute_name=p_size]
+  | | +-value_list=
+  | |   +-Literal
+  | |   | +-NumericLiteral[numeric_string=32,float_like=false]
+  | |   +-Literal
+  | |   | +-NumericLiteral[numeric_string=42,float_like=false]
+  | |   +-Literal
+  | |   | +-NumericLiteral[numeric_string=9,float_like=false]
+  | |   +-Literal
+  | |   | +-NumericLiteral[numeric_string=18,float_like=false]
+  | |   +-Literal
+  | |   | +-NumericLiteral[numeric_string=50,float_like=false]
+  | |   +-Literal
+  | |   | +-NumericLiteral[numeric_string=30,float_like=false]
+  | |   +-Literal
+  | |   | +-NumericLiteral[numeric_string=12,float_like=false]
+  | |   +-Literal
+  | |     +-NumericLiteral[numeric_string=21,float_like=false]
+  | +-Not
+  |   +-InTableQuery
+  |     +-test_expression=AttributeReference[attribute_name=ps_suppkey]
+  |     +-table_query=SubqueryExpression
+  |       +-Select
+  |         +-select_clause=SelectList
+  |         | +-SelectListItem
+  |         |   +-AttributeReference[attribute_name=s_suppkey]
+  |         +-where_clause=Like
+  |         | +-left_operand=AttributeReference[attribute_name=s_comment]
+  |         | +-right_operand=Literal
+  |         |   +-StringLiteral[value=%Customer%Complaints%]
+  |         +-from_clause=
+  |           +-TableReference[table=supplier]
+  +-group_by=GroupBy
+  | +-AttributeReference[attribute_name=p_brand]
+  | +-AttributeReference[attribute_name=p_type]
+  | +-AttributeReference[attribute_name=p_size]
+  +-order_by=OrderBy
+  | +-OrderByItem[is_asc=false,nulls_first=true]
+  | | +-AttributeReference[attribute_name=supplier_cnt]
+  | +-OrderByItem[is_asc=true,nulls_first=false]
+  | | +-AttributeReference[attribute_name=p_brand]
+  | +-OrderByItem[is_asc=true,nulls_first=false]
+  | | +-AttributeReference[attribute_name=p_type]
+  | +-OrderByItem[is_asc=true,nulls_first=false]
+  |   +-AttributeReference[attribute_name=p_size]
+  +-from_clause=
+    +-TableReference[table=partsupp]
+    +-TableReference[table=part]
 ==
 
 # Query 17
@@ -1194,7 +1342,7 @@ FROM
   orders,
   lineitem
 WHERE
-  o_orderkey in (
+  o_orderkey IN (
     SELECT
       l_orderkey
     FROM
@@ -1216,9 +1364,63 @@ ORDER BY
   o_orderdate
 LIMIT 100
 --
-ERROR: syntax error (13 : 14)
-  o_orderkey in (
-             ^
+SelectStatement
++-select_query=Select
+  +-select_clause=SelectList
+  | +-SelectListItem
+  | | +-AttributeReference[attribute_name=c_name]
+  | +-SelectListItem
+  | | +-AttributeReference[attribute_name=c_custkey]
+  | +-SelectListItem
+  | | +-AttributeReference[attribute_name=o_orderkey]
+  | +-SelectListItem
+  | | +-AttributeReference[attribute_name=o_orderdate]
+  | +-SelectListItem
+  | | +-AttributeReference[attribute_name=o_totalprice]
+  | +-SelectListItem
+  |   +-FunctionCall[name=sum]
+  |     +-AttributeReference[attribute_name=l_quantity]
+  +-where_clause=And
+  | +-InTableQuery
+  | | +-test_expression=AttributeReference[attribute_name=o_orderkey]
+  | | +-table_query=SubqueryExpression
+  | |   +-Select
+  | |     +-select_clause=SelectList
+  | |     | +-SelectListItem
+  | |     |   +-AttributeReference[attribute_name=l_orderkey]
+  | |     +-group_by=GroupBy
+  | |     | +-AttributeReference[attribute_name=l_orderkey]
+  | |     +-having=HAVING
+  | |     | +-Greater
+  | |     |   +-left_operand=FunctionCall[name=SUM]
+  | |     |   | +-AttributeReference[attribute_name=l_quantity]
+  | |     |   +-right_operand=Literal
+  | |     |     +-NumericLiteral[numeric_string=314,float_like=false]
+  | |     +-from_clause=
+  | |       +-TableReference[table=lineitem]
+  | +-Equal
+  | | +-left_operand=AttributeReference[attribute_name=c_custkey]
+  | | +-right_operand=AttributeReference[attribute_name=o_custkey]
+  | +-Equal
+  |   +-left_operand=AttributeReference[attribute_name=o_orderkey]
+  |   +-right_operand=AttributeReference[attribute_name=l_orderkey]
+  +-group_by=GroupBy
+  | +-AttributeReference[attribute_name=c_name]
+  | +-AttributeReference[attribute_name=c_custkey]
+  | +-AttributeReference[attribute_name=o_orderkey]
+  | +-AttributeReference[attribute_name=o_orderdate]
+  | +-AttributeReference[attribute_name=o_totalprice]
+  +-order_by=OrderBy
+  | +-OrderByItem[is_asc=false,nulls_first=true]
+  | | +-AttributeReference[attribute_name=o_totalprice]
+  | +-OrderByItem[is_asc=true,nulls_first=false]
+  |   +-AttributeReference[attribute_name=o_orderdate]
+  +-limit=LIMIT
+  | +-NumericLiteral[numeric_string=100,float_like=false]
+  +-from_clause=
+    +-TableReference[table=customer]
+    +-TableReference[table=orders]
+    +-TableReference[table=lineitem]
 ==
 
 # Query 19
@@ -1258,9 +1460,162 @@ WHERE
     AND l_shipinstruct = 'DELIVER IN PERSON'
   )
 --
-ERROR: syntax error (10 : 21)
-    AND p_container IN ('SM CASE', 'SM BOX', 'SM PAC...
-                    ^
+SelectStatement
++-select_query=Select
+  +-select_clause=SelectList
+  | +-SelectListItem[alias=revenue]
+  |   +-FunctionCall[name=SUM]
+  |     +-Multiply
+  |       +-left_operand=AttributeReference[attribute_name=l_extendedprice]
+  |       +-right_operand=Subtract
+  |         +-left_operand=Literal
+  |         | +-NumericLiteral[numeric_string=1,float_like=false]
+  |         +-right_operand=AttributeReference[attribute_name=l_discount]
+  +-where_clause=Or
+  | +-And
+  | | +-Equal
+  | | | +-left_operand=AttributeReference[attribute_name=p_partkey]
+  | | | +-right_operand=AttributeReference[attribute_name=l_partkey]
+  | | +-Equal
+  | | | +-left_operand=AttributeReference[attribute_name=p_brand]
+  | | | +-right_operand=Literal
+  | | |   +-StringLiteral[value=Brand#45]
+  | | +-InValueList
+  | | | +-test_expression=AttributeReference[attribute_name=p_container]
+  | | | +-value_list=
+  | | |   +-Literal
+  | | |   | +-StringLiteral[value=SM CASE]
+  | | |   +-Literal
+  | | |   | +-StringLiteral[value=SM BOX]
+  | | |   +-Literal
+  | | |   | +-StringLiteral[value=SM PACK]
+  | | |   +-Literal
+  | | |     +-StringLiteral[value=SM PKG]
+  | | +-GreaterOrEqual
+  | | | +-left_operand=AttributeReference[attribute_name=l_quantity]
+  | | | +-right_operand=Literal
+  | | |   +-NumericLiteral[numeric_string=2,float_like=false]
+  | | +-LessOrEqual
+  | | | +-left_operand=AttributeReference[attribute_name=l_quantity]
+  | | | +-right_operand=Add
+  | | |   +-left_operand=Literal
+  | | |   | +-NumericLiteral[numeric_string=2,float_like=false]
+  | | |   +-right_operand=Literal
+  | | |     +-NumericLiteral[numeric_string=10,float_like=false]
+  | | +-Between
+  | | | +-check_operand=AttributeReference[attribute_name=p_size]
+  | | | +-lower_bound_operand=Literal
+  | | | | +-NumericLiteral[numeric_string=1,float_like=false]
+  | | | +-upper_bound_operand=Literal
+  | | |   +-NumericLiteral[numeric_string=5,float_like=false]
+  | | +-InValueList
+  | | | +-test_expression=AttributeReference[attribute_name=l_shipmode]
+  | | | +-value_list=
+  | | |   +-Literal
+  | | |   | +-StringLiteral[value=AIR]
+  | | |   +-Literal
+  | | |     +-StringLiteral[value=AIR REG]
+  | | +-Equal
+  | |   +-left_operand=AttributeReference[attribute_name=l_shipinstruct]
+  | |   +-right_operand=Literal
+  | |     +-StringLiteral[value=DELIVER IN PERSON]
+  | +-And
+  | | +-Equal
+  | | | +-left_operand=AttributeReference[attribute_name=p_partkey]
+  | | | +-right_operand=AttributeReference[attribute_name=l_partkey]
+  | | +-Equal
+  | | | +-left_operand=AttributeReference[attribute_name=p_brand]
+  | | | +-right_operand=Literal
+  | | |   +-StringLiteral[value=Brand#12]
+  | | +-InValueList
+  | | | +-test_expression=AttributeReference[attribute_name=p_container]
+  | | | +-value_list=
+  | | |   +-Literal
+  | | |   | +-StringLiteral[value=MED BAG]
+  | | |   +-Literal
+  | | |   | +-StringLiteral[value=MED BOX]
+  | | |   +-Literal
+  | | |   | +-StringLiteral[value=MED PKG]
+  | | |   +-Literal
+  | | |     +-StringLiteral[value=MED PACK]
+  | | +-GreaterOrEqual
+  | | | +-left_operand=AttributeReference[attribute_name=l_quantity]
+  | | | +-right_operand=Literal
+  | | |   +-NumericLiteral[numeric_string=13,float_like=false]
+  | | +-LessOrEqual
+  | | | +-left_operand=AttributeReference[attribute_name=l_quantity]
+  | | | +-right_operand=Add
+  | | |   +-left_operand=Literal
+  | | |   | +-NumericLiteral[numeric_string=13,float_like=false]
+  | | |   +-right_operand=Literal
+  | | |     +-NumericLiteral[numeric_string=10,float_like=false]
+  | | +-Between
+  | | | +-check_operand=AttributeReference[attribute_name=p_size]
+  | | | +-lower_bound_operand=Literal
+  | | | | +-NumericLiteral[numeric_string=1,float_like=false]
+  | | | +-upper_bound_operand=Literal
+  | | |   +-NumericLiteral[numeric_string=10,float_like=false]
+  | | +-InValueList
+  | | | +-test_expression=AttributeReference[attribute_name=l_shipmode]
+  | | | +-value_list=
+  | | |   +-Literal
+  | | |   | +-StringLiteral[value=AIR]
+  | | |   +-Literal
+  | | |     +-StringLiteral[value=AIR REG]
+  | | +-Equal
+  | |   +-left_operand=AttributeReference[attribute_name=l_shipinstruct]
+  | |   +-right_operand=Literal
+  | |     +-StringLiteral[value=DELIVER IN PERSON]
+  | +-And
+  |   +-Equal
+  |   | +-left_operand=AttributeReference[attribute_name=p_partkey]
+  |   | +-right_operand=AttributeReference[attribute_name=l_partkey]
+  |   +-Equal
+  |   | +-left_operand=AttributeReference[attribute_name=p_brand]
+  |   | +-right_operand=Literal
+  |   |   +-StringLiteral[value=Brand#53]
+  |   +-InValueList
+  |   | +-test_expression=AttributeReference[attribute_name=p_container]
+  |   | +-value_list=
+  |   |   +-Literal
+  |   |   | +-StringLiteral[value=LG CASE]
+  |   |   +-Literal
+  |   |   | +-StringLiteral[value=LG BOX]
+  |   |   +-Literal
+  |   |   | +-StringLiteral[value=LG PACK]
+  |   |   +-Literal
+  |   |     +-StringLiteral[value=LG PKG]
+  |   +-GreaterOrEqual
+  |   | +-left_operand=AttributeReference[attribute_name=l_quantity]
+  |   | +-right_operand=Literal
+  |   |   +-NumericLiteral[numeric_string=24,float_like=false]
+  |   +-LessOrEqual
+  |   | +-left_operand=AttributeReference[attribute_name=l_quantity]
+  |   | +-right_operand=Add
+  |   |   +-left_operand=Literal
+  |   |   | +-NumericLiteral[numeric_string=24,float_like=false]
+  |   |   +-right_operand=Literal
+  |   |     +-NumericLiteral[numeric_string=10,float_like=false]
+  |   +-Between
+  |   | +-check_operand=AttributeReference[attribute_name=p_size]
+  |   | +-lower_bound_operand=Literal
+  |   | | +-NumericLiteral[numeric_string=1,float_like=false]
+  |   | +-upper_bound_operand=Literal
+  |   |   +-NumericLiteral[numeric_string=15,float_like=false]
+  |   +-InValueList
+  |   | +-test_expression=AttributeReference[attribute_name=l_shipmode]
+  |   | +-value_list=
+  |   |   +-Literal
+  |   |   | +-StringLiteral[value=AIR]
+  |   |   +-Literal
+  |   |     +-StringLiteral[value=AIR REG]
+  |   +-Equal
+  |     +-left_operand=AttributeReference[attribute_name=l_shipinstruct]
+  |     +-right_operand=Literal
+  |       +-StringLiteral[value=DELIVER IN PERSON]
+  +-from_clause=
+    +-TableReference[table=lineitem]
+    +-TableReference[table=part]
 ==
 
 # Query 20
@@ -1271,7 +1626,7 @@ FROM
   supplier,
   nation
 WHERE
-  s_suppkey in (
+  s_suppkey IN (
     SELECT
       ps_suppkey
     FROM
@@ -1302,9 +1657,9 @@ WHERE
 ORDER BY
   s_name
 --
-ERROR: syntax error (8 : 13)
-  s_suppkey in (
-            ^
+ERROR: syntax error (23 : 9)
+        SELECT
+        ^
 ==
 
 # Query 21
@@ -1453,7 +1808,7 @@ FROM
     FROM
       customer
     WHERE
-      SUBSTR(c_phone, 1, 2) in
+      SUBSTR(c_phone, 1, 2) IN
         ('27', '44', '34', '25', '30', '33', '23')
       AND c_acctbal > (
         SELECT
@@ -1462,10 +1817,10 @@ FROM
           customer
         WHERE
           c_acctbal > 0.00
-          AND SUBSTR(c_phone, 1, 2) in
+          AND SUBSTR(c_phone, 1, 2) IN
             ('27', '44', '34', '25', '30', '33', '23')
       )
-      AND NOT exists (
+      AND NOT EXISTS (
         SELECT *
         FROM
           orders
@@ -1478,6 +1833,6 @@ GROUP BY
 ORDER BY
   cntrycode
 --
-ERROR: syntax error (13 : 29)
-      SUBSTR(c_phone, 1, 2) in
-                            ^
+ERROR: syntax error (16 : 9)
+        SELECT
+        ^

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/query_optimizer/expressions/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/CMakeLists.txt b/query_optimizer/expressions/CMakeLists.txt
index ca064dc..6c40741 100644
--- a/query_optimizer/expressions/CMakeLists.txt
+++ b/query_optimizer/expressions/CMakeLists.txt
@@ -28,6 +28,8 @@ add_library(quickstep_queryoptimizer_expressions_Expression ../../empty_src.cpp
 add_library(quickstep_queryoptimizer_expressions_ExpressionType ../../empty_src.cpp ExpressionType.hpp)
 add_library(quickstep_queryoptimizer_expressions_ExprId ../../empty_src.cpp ExprId.hpp)
 add_library(quickstep_queryoptimizer_expressions_ExpressionUtil ExpressionUtil.cpp ExpressionUtil.hpp)
+add_library(quickstep_queryoptimizer_expressions_InTableQuery InTableQuery.cpp InTableQuery.hpp)
+add_library(quickstep_queryoptimizer_expressions_InValueList InValueList.cpp InValueList.hpp)
 add_library(quickstep_queryoptimizer_expressions_LogicalAnd LogicalAnd.cpp LogicalAnd.hpp)
 add_library(quickstep_queryoptimizer_expressions_LogicalNot LogicalNot.cpp LogicalNot.hpp)
 add_library(quickstep_queryoptimizer_expressions_LogicalOr LogicalOr.cpp LogicalOr.hpp)
@@ -138,6 +140,31 @@ target_link_libraries(quickstep_queryoptimizer_expressions_ExpressionUtil
                       quickstep_queryoptimizer_expressions_ExprId
                       quickstep_queryoptimizer_expressions_NamedExpression
                       quickstep_queryoptimizer_expressions_PatternMatcher)
+target_link_libraries(quickstep_queryoptimizer_expressions_InTableQuery
+                      quickstep_queryoptimizer_OptimizerTree
+                      quickstep_queryoptimizer_expressions_AttributeReference
+                      quickstep_queryoptimizer_expressions_ExprId
+                      quickstep_queryoptimizer_expressions_Expression
+                      quickstep_queryoptimizer_expressions_ExpressionType
+                      quickstep_queryoptimizer_expressions_Predicate
+                      quickstep_queryoptimizer_expressions_Scalar
+                      quickstep_queryoptimizer_expressions_SubqueryExpression
+                      quickstep_utility_Macros)
+target_link_libraries(quickstep_queryoptimizer_expressions_InValueList
+                      quickstep_queryoptimizer_OptimizerTree
+                      quickstep_expressions_predicate_DisjunctionPredicate
+                      quickstep_expressions_predicate_Predicate
+                      quickstep_queryoptimizer_expressions_AttributeReference
+                      quickstep_queryoptimizer_expressions_ComparisonExpression
+                      quickstep_queryoptimizer_expressions_ExprId
+                      quickstep_queryoptimizer_expressions_Expression
+                      quickstep_queryoptimizer_expressions_ExpressionType
+                      quickstep_queryoptimizer_expressions_Predicate
+                      quickstep_queryoptimizer_expressions_Scalar
+                      quickstep_types_operations_comparisons_ComparisonFactory
+                      quickstep_types_operations_comparisons_ComparisonID
+                      quickstep_utility_Cast
+                      quickstep_utility_Macros)
 target_link_libraries(quickstep_queryoptimizer_expressions_LogicalAnd
                       glog
                       quickstep_expressions_predicate_ConjunctionPredicate
@@ -289,6 +316,8 @@ target_link_libraries(quickstep_queryoptimizer_expressions
                       quickstep_queryoptimizer_expressions_ExpressionType
                       quickstep_queryoptimizer_expressions_ExprId
                       quickstep_queryoptimizer_expressions_ExpressionUtil
+                      quickstep_queryoptimizer_expressions_InTableQuery
+                      quickstep_queryoptimizer_expressions_InValueList
                       quickstep_queryoptimizer_expressions_LogicalAnd
                       quickstep_queryoptimizer_expressions_LogicalNot
                       quickstep_queryoptimizer_expressions_LogicalOr

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/query_optimizer/expressions/ExpressionType.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/ExpressionType.hpp b/query_optimizer/expressions/ExpressionType.hpp
index afd6f81..23770e0 100644
--- a/query_optimizer/expressions/ExpressionType.hpp
+++ b/query_optimizer/expressions/ExpressionType.hpp
@@ -39,6 +39,8 @@ enum class ExpressionType {
   kCast,
   kComparisonExpression,
   kExists,
+  kInTableQuery,
+  kInValueList,
   kLogicalAnd,
   kLogicalOr,
   kLogicalNot,

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/query_optimizer/expressions/InTableQuery.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/InTableQuery.cpp b/query_optimizer/expressions/InTableQuery.cpp
new file mode 100644
index 0000000..b4abbe0
--- /dev/null
+++ b/query_optimizer/expressions/InTableQuery.cpp
@@ -0,0 +1,53 @@
+/**
+ *   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.
+ **/
+
+#include "query_optimizer/expressions/InTableQuery.hpp"
+
+#include <string>
+#include <vector>
+
+#include "query_optimizer/OptimizerTree.hpp"
+#include "query_optimizer/expressions/ExprId.hpp"
+
+#include "glog/logging.h"
+
+namespace quickstep {
+namespace optimizer {
+namespace expressions {
+
+::quickstep::Predicate* InTableQuery::concretize(
+    const std::unordered_map<ExprId, const CatalogAttribute*> &substitution_map) const {
+  LOG(FATAL) << "InTableQuery predicate should not be concretized";
+}
+
+void InTableQuery::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<OptimizerTreeBaseNodePtr> *non_container_child_fields,
+    std::vector<std::string> *container_child_field_names,
+    std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const {
+  non_container_child_field_names->push_back("test_expression");
+  non_container_child_fields->push_back(test_expression_);
+
+  non_container_child_field_names->push_back("table_query");
+  non_container_child_fields->push_back(table_query_);
+}
+
+}  // namespace expressions
+}  // namespace optimizer
+}  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/query_optimizer/expressions/InTableQuery.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/InTableQuery.hpp b/query_optimizer/expressions/InTableQuery.hpp
new file mode 100644
index 0000000..e4abf22
--- /dev/null
+++ b/query_optimizer/expressions/InTableQuery.hpp
@@ -0,0 +1,143 @@
+/**
+ *   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_QUERY_OPTIMIZER_EXPRESSIONS_IN_TABLE_QUERY_HPP_
+#define QUICKSTEP_QUERY_OPTIMIZER_EXPRESSIONS_IN_TABLE_QUERY_HPP_
+
+#include <memory>
+#include <string>
+#include <unordered_map>
+#include <vector>
+
+#include "query_optimizer/OptimizerTree.hpp"
+#include "query_optimizer/expressions/AttributeReference.hpp"
+#include "query_optimizer/expressions/ExprId.hpp"
+#include "query_optimizer/expressions/Expression.hpp"
+#include "query_optimizer/expressions/ExpressionType.hpp"
+#include "query_optimizer/expressions/Predicate.hpp"
+#include "query_optimizer/expressions/Scalar.hpp"
+#include "query_optimizer/expressions/SubqueryExpression.hpp"
+#include "utility/Macros.hpp"
+
+#include "glog/logging.h"
+
+namespace quickstep {
+
+class CatalogAttribute;
+class Predicate;
+
+namespace optimizer {
+namespace expressions {
+
+/** \addtogroup OptimizerExpressions
+ *  @{
+ */
+
+class InTableQuery;
+typedef std::shared_ptr<const InTableQuery> InTableQueryPtr;
+
+/**
+ * @brief IN predicate with a subquery.
+ */
+class InTableQuery : public Predicate {
+ public:
+  ExpressionType getExpressionType() const override {
+    return ExpressionType::kInTableQuery;
+  }
+
+  std::string getName() const override {
+    return "InTableQuery";
+  }
+
+  bool isConstant() const override {
+    return false;
+  }
+
+  /**
+   * @return The expression to test with the result of the table subquery.
+   */
+  const ScalarPtr& test_expression() const {
+    return test_expression_;
+  }
+
+  /**
+   * @return The table subquery that returns a single column to search for
+   *         the value of the test expression.
+   */
+  const SubqueryExpressionPtr& table_query() const {
+    return table_query_;
+  }
+
+  ExpressionPtr copyWithNewChildren(
+      const std::vector<ExpressionPtr> &new_children) const override {
+    DCHECK_EQ(2u, new_children.size());
+    return Create(std::static_pointer_cast<const Scalar>(new_children[0]),
+                  std::static_pointer_cast<const SubqueryExpression>(new_children[1]));
+  }
+
+  std::vector<AttributeReferencePtr> getReferencedAttributes() const override {
+    return {};
+  }
+
+  ::quickstep::Predicate* concretize(
+      const std::unordered_map<ExprId, const CatalogAttribute*> &substitution_map) const override;
+
+  /**
+   * @brief Create an IN predicate with a subquery.
+   *
+   * @param test_expression The expression to test with the result of a table subquery.
+   * @param table_query The table subquery that returns a single column to search for
+   *        the value of the test expression.
+   *
+   * @return An immutable IN predicate node.
+   */
+  static InTableQueryPtr Create(const ScalarPtr &test_expression,
+                                const SubqueryExpressionPtr &table_query) {
+    return InTableQueryPtr(new InTableQuery(test_expression, table_query));
+  }
+
+ 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<OptimizerTreeBaseNodePtr> *non_container_child_fields,
+      std::vector<std::string> *container_child_field_names,
+      std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const override;
+
+ private:
+  InTableQuery(const ScalarPtr &test_expression,
+               const SubqueryExpressionPtr &table_query)
+      : test_expression_(test_expression),
+        table_query_(table_query) {
+    addChild(test_expression_);
+    addChild(table_query_);
+  }
+
+  ScalarPtr test_expression_;
+  SubqueryExpressionPtr table_query_;
+
+  DISALLOW_COPY_AND_ASSIGN(InTableQuery);
+};
+
+/** @} */
+
+}  // namespace expressions
+}  // namespace optimizer
+}  // namespace quickstep
+
+#endif  // QUICKSTEP_QUERY_OPTIMIZER_EXPRESSIONS_IN_TABLE_QUERY_HPP_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/query_optimizer/expressions/InValueList.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/InValueList.cpp b/query_optimizer/expressions/InValueList.cpp
new file mode 100644
index 0000000..dd77d95
--- /dev/null
+++ b/query_optimizer/expressions/InValueList.cpp
@@ -0,0 +1,72 @@
+/**
+ *   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.
+ **/
+
+#include "query_optimizer/expressions/InValueList.hpp"
+
+#include <string>
+#include <vector>
+
+#include "expressions/predicate/DisjunctionPredicate.hpp"
+#include "expressions/predicate/Predicate.hpp"
+#include "query_optimizer/OptimizerTree.hpp"
+#include "query_optimizer/expressions/ComparisonExpression.hpp"
+#include "query_optimizer/expressions/ExprId.hpp"
+#include "query_optimizer/expressions/Predicate.hpp"
+#include "query_optimizer/expressions/Scalar.hpp"
+#include "types/operations/comparisons/ComparisonID.hpp"
+#include "types/operations/comparisons/ComparisonFactory.hpp"
+#include "utility/Cast.hpp"
+
+namespace quickstep {
+namespace optimizer {
+namespace expressions {
+
+::quickstep::Predicate* InValueList::concretize(
+    const std::unordered_map<ExprId, const CatalogAttribute*> &substitution_map) const {
+  std::unique_ptr<quickstep::DisjunctionPredicate>
+      disjunction_predicate(new quickstep::DisjunctionPredicate());
+  for (const ScalarPtr &match_expression : match_expressions_) {
+    const PredicatePtr match_predicate =
+        ComparisonExpression::Create(
+            quickstep::ComparisonFactory::GetComparison(quickstep::ComparisonID::kEqual),
+            test_expression_,
+            match_expression);
+
+    disjunction_predicate->addPredicate(
+        match_predicate->concretize(substitution_map));
+  }
+  return disjunction_predicate.release();
+}
+
+void InValueList::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<OptimizerTreeBaseNodePtr> *non_container_child_fields,
+    std::vector<std::string> *container_child_field_names,
+    std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const {
+  non_container_child_field_names->push_back("test_expression");
+  non_container_child_fields->push_back(test_expression_);
+
+  container_child_field_names->push_back("match_expressions");
+  container_child_fields->push_back(
+      CastSharedPtrVector<OptimizerTreeBase>(match_expressions_));
+}
+
+}  // namespace expressions
+}  // namespace optimizer
+}  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/query_optimizer/expressions/InValueList.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/InValueList.hpp b/query_optimizer/expressions/InValueList.hpp
new file mode 100644
index 0000000..9fc2ace
--- /dev/null
+++ b/query_optimizer/expressions/InValueList.hpp
@@ -0,0 +1,157 @@
+/**
+ *   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_QUERY_OPTIMIZER_EXPRESSIONS_IN_VALUE_LIST_HPP_
+#define QUICKSTEP_QUERY_OPTIMIZER_EXPRESSIONS_IN_VALUE_LIST_HPP_
+
+#include <cstddef>
+#include <memory>
+#include <string>
+#include <unordered_map>
+#include <vector>
+
+#include "query_optimizer/OptimizerTree.hpp"
+#include "query_optimizer/expressions/AttributeReference.hpp"
+#include "query_optimizer/expressions/ExprId.hpp"
+#include "query_optimizer/expressions/Expression.hpp"
+#include "query_optimizer/expressions/ExpressionType.hpp"
+#include "query_optimizer/expressions/Predicate.hpp"
+#include "query_optimizer/expressions/Scalar.hpp"
+#include "utility/Macros.hpp"
+
+#include "glog/logging.h"
+
+namespace quickstep {
+
+class CatalogAttribute;
+class Predicate;
+
+namespace optimizer {
+namespace expressions {
+
+/** \addtogroup OptimizerExpressions
+ *  @{
+ */
+
+class InValueList;
+typedef std::shared_ptr<const InValueList> InValueListPtr;
+
+/**
+ * @brief IN predicate with a value list.
+ */
+class InValueList : public Predicate {
+ public:
+  ExpressionType getExpressionType() const override {
+    return ExpressionType::kInValueList;
+  }
+
+  std::string getName() const override {
+    return "InValueList";
+  }
+
+  bool isConstant() const override {
+    return false;
+  }
+
+  /**
+   * @return The expression to test with a value list.
+   */
+  const ScalarPtr& test_expression() const {
+    return test_expression_;
+  }
+
+  /**
+   * @return Expressions to search for the value of the test_expression.
+   */
+  const std::vector<ScalarPtr>& match_expressions() const {
+    return match_expressions_;
+  }
+
+  ExpressionPtr copyWithNewChildren(
+      const std::vector<ExpressionPtr> &new_children) const override {
+    DCHECK_EQ(children().size(), new_children.size());
+    std::vector<ScalarPtr> new_match_expressions;
+    for (std::size_t idx = 1; idx < new_children.size(); ++idx) {
+      new_match_expressions.emplace_back(
+          std::static_pointer_cast<const Scalar>(new_children[idx]));
+    }
+    return Create(std::static_pointer_cast<const Scalar>(new_children[0]),
+                  new_match_expressions);
+  }
+
+  std::vector<AttributeReferencePtr> getReferencedAttributes() const override {
+    std::vector<AttributeReferencePtr> referenced_attrs =
+        test_expression_->getReferencedAttributes();
+    for (const ScalarPtr &match_expression : match_expressions_) {
+      const std::vector<AttributeReferencePtr> referenced_attrs_in_match_expr =
+          match_expression->getReferencedAttributes();
+      referenced_attrs.insert(referenced_attrs.end(),
+                              referenced_attrs_in_match_expr.begin(),
+                              referenced_attrs_in_match_expr.end());
+    }
+    return referenced_attrs;
+  }
+
+  ::quickstep::Predicate* concretize(
+      const std::unordered_map<ExprId, const CatalogAttribute*> &substitution_map) const override;
+
+  /**
+   * @brief Create an IN predicate with a value list.
+   *
+   * @param test_expression The expression to test with a value list.
+   * @param match_expressions Expressions to search for the value of the test_expression.
+   *
+   * @return An immutable IN predicate node with a value list.
+   */
+  static InValueListPtr Create(const ScalarPtr &test_expression,
+                               const std::vector<ScalarPtr> &match_expressions) {
+    return InValueListPtr(new InValueList(test_expression, match_expressions));
+  }
+
+ 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<OptimizerTreeBaseNodePtr> *non_container_child_fields,
+      std::vector<std::string> *container_child_field_names,
+      std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const override;
+
+ private:
+  InValueList(const ScalarPtr &test_expression,
+              const std::vector<ScalarPtr> &match_expressions)
+      : test_expression_(test_expression),
+        match_expressions_(match_expressions) {
+    addChild(test_expression_);
+    for (const ScalarPtr &match_expression : match_expressions_) {
+      addChild(match_expression);
+    }
+  }
+
+  ScalarPtr test_expression_;
+  std::vector<ScalarPtr> match_expressions_;
+
+  DISALLOW_COPY_AND_ASSIGN(InValueList);
+};
+
+/** @} */
+
+}  // namespace expressions
+}  // namespace optimizer
+}  // namespace quickstep
+
+#endif  // QUICKSTEP_QUERY_OPTIMIZER_EXPRESSIONS_IN_VALUE_LIST_HPP_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/query_optimizer/expressions/PatternMatcher.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/PatternMatcher.hpp b/query_optimizer/expressions/PatternMatcher.hpp
index 528b1e6..87bc52a 100644
--- a/query_optimizer/expressions/PatternMatcher.hpp
+++ b/query_optimizer/expressions/PatternMatcher.hpp
@@ -38,6 +38,8 @@ class Cast;
 class ComparisonExpression;
 class Count;
 class Exists;
+class InTableQuery;
+class InValueList;
 class LogicalAnd;
 class LogicalNot;
 class LogicalOr;
@@ -119,6 +121,8 @@ using SomeBinaryExpression = SomeExpressionNode<BinaryExpression, ExpressionType
 using SomeCast = SomeExpressionNode<Cast, ExpressionType::kCast>;
 using SomeComparisonExpression = SomeExpressionNode<ComparisonExpression, ExpressionType::kComparisonExpression>;
 using SomeExists = SomeExpressionNode<Exists, ExpressionType::kExists>;
+using SomeInTableQuery = SomeExpressionNode<InTableQuery, ExpressionType::kInTableQuery>;
+using SomeInValueList = SomeExpressionNode<InValueList, ExpressionType::kInValueList>;
 using SomeLogicalAnd = SomeExpressionNode<LogicalAnd, ExpressionType::kLogicalAnd>;
 using SomeLogicalNot = SomeExpressionNode<LogicalNot, ExpressionType::kLogicalNot>;
 using SomeLogicalOr = SomeExpressionNode<LogicalOr, ExpressionType::kLogicalOr>;
@@ -128,6 +132,8 @@ using SomeNamedExpression = SomeExpressionNode<NamedExpression,
 using SomePredicate = SomeExpressionNode<Predicate,
                                          ExpressionType::kComparisonExpression,
                                          ExpressionType::kExists,
+                                         ExpressionType::kInTableQuery,
+                                         ExpressionType::kInValueList,
                                          ExpressionType::kLogicalAnd,
                                          ExpressionType::kLogicalNot,
                                          ExpressionType::kLogicalOr,

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/query_optimizer/resolver/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/query_optimizer/resolver/CMakeLists.txt b/query_optimizer/resolver/CMakeLists.txt
index 72f5bd7..f8ffa72 100644
--- a/query_optimizer/resolver/CMakeLists.txt
+++ b/query_optimizer/resolver/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.
@@ -49,6 +51,7 @@ target_link_libraries(quickstep_queryoptimizer_resolver_Resolver
                       quickstep_parser_ParseOrderBy
                       quickstep_parser_ParsePredicate
                       quickstep_parser_ParsePredicateExists
+                      quickstep_parser_ParsePredicateInTableQuery
                       quickstep_parser_ParseSelect
                       quickstep_parser_ParseSelectionClause
                       quickstep_parser_ParseSimpleTableReference
@@ -68,6 +71,8 @@ target_link_libraries(quickstep_queryoptimizer_resolver_Resolver
                       quickstep_queryoptimizer_expressions_Exists
                       quickstep_queryoptimizer_expressions_ExprId
                       quickstep_queryoptimizer_expressions_ExpressionUtil
+                      quickstep_queryoptimizer_expressions_InTableQuery
+                      quickstep_queryoptimizer_expressions_InValueList
                       quickstep_queryoptimizer_expressions_LogicalAnd
                       quickstep_queryoptimizer_expressions_LogicalNot
                       quickstep_queryoptimizer_expressions_LogicalOr

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/query_optimizer/resolver/Resolver.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/resolver/Resolver.cpp b/query_optimizer/resolver/Resolver.cpp
index f44aae8..8323c33 100644
--- a/query_optimizer/resolver/Resolver.cpp
+++ b/query_optimizer/resolver/Resolver.cpp
@@ -47,6 +47,7 @@
 #include "parser/ParseOrderBy.hpp"
 #include "parser/ParsePredicate.hpp"
 #include "parser/ParsePredicateExists.hpp"
+#include "parser/ParsePredicateInTableQuery.hpp"
 #include "parser/ParseSelect.hpp"
 #include "parser/ParseSelectionClause.hpp"
 #include "parser/ParseSimpleTableReference.hpp"
@@ -66,6 +67,8 @@
 #include "query_optimizer/expressions/Exists.hpp"
 #include "query_optimizer/expressions/ExprId.hpp"
 #include "query_optimizer/expressions/ExpressionUtil.hpp"
+#include "query_optimizer/expressions/InTableQuery.hpp"
+#include "query_optimizer/expressions/InValueList.hpp"
 #include "query_optimizer/expressions/LogicalAnd.hpp"
 #include "query_optimizer/expressions/LogicalNot.hpp"
 #include "query_optimizer/expressions/LogicalOr.hpp"
@@ -115,6 +118,8 @@
 #include "utility/SqlError.hpp"
 #include "utility/StringUtil.hpp"
 
+#include "glog/logging.h"
+
 namespace quickstep {
 namespace optimizer {
 namespace resolver {
@@ -1188,13 +1193,21 @@ L::LogicalPtr Resolver::resolveSelect(
 E::SubqueryExpressionPtr Resolver::resolveSubqueryExpression(
     const ParseSubqueryExpression &parse_subquery_expression,
     const std::vector<const Type*> *type_hints,
-    ExpressionResolutionInfo *expression_resolution_info) {
+    ExpressionResolutionInfo *expression_resolution_info,
+    const bool has_single_column) {
   L::LogicalPtr logical_subquery =
       resolveSelect(*parse_subquery_expression.query(),
                     "" /* select_name */,
                     type_hints,
                     &expression_resolution_info->name_resolver);
 
+  // Raise SQL error if the subquery is expected to return only one column but
+  // it returns multiple columns.
+  if (has_single_column && logical_subquery->getOutputAttributes().size() > 1u) {
+    THROW_SQL_ERROR_AT(&parse_subquery_expression)
+        << "Subquery must return exactly one column";
+  }
+
   if (!context_->has_nested_queries()) {
     context_->set_has_nested_queries();
   }
@@ -2523,7 +2536,74 @@ E::PredicatePtr Resolver::resolvePredicate(
       return E::Exists::Create(
           resolveSubqueryExpression(*exists.subquery(),
                                     nullptr /* type_hints */,
-                                    expression_resolution_info));
+                                    expression_resolution_info,
+                                    false /* has_single_column */));
+    }
+    case ParsePredicate::kInTableQuery: {
+      const ParsePredicateInTableQuery &in_table_query =
+          static_cast<const ParsePredicateInTableQuery&>(parse_predicate);
+
+      ExpressionResolutionInfo test_expr_resolution_info(*expression_resolution_info);
+      const E::ScalarPtr test_expression =
+          resolveExpression(*in_table_query.test_expression(),
+                            nullptr /* type_hint */,
+                            &test_expr_resolution_info);
+      if (test_expr_resolution_info.hasAggregate() && !expression_resolution_info->hasAggregate()) {
+        expression_resolution_info->parse_aggregate_expression =
+            test_expr_resolution_info.parse_aggregate_expression;
+      }
+
+      ExpressionResolutionInfo table_query_resolution_info(*expression_resolution_info);
+      const std::vector<const Type*> type_hints = { &test_expression->getValueType() };
+      const E::SubqueryExpressionPtr table_query =
+          resolveSubqueryExpression(*in_table_query.table_query(),
+                                    &type_hints,
+                                    &table_query_resolution_info,
+                                    true /* has_single_column */);
+      return E::InTableQuery::Create(test_expression,
+                                     table_query);
+    }
+    case ParsePredicate::kInValueList: {
+      const ParsePredicateInValueList &in_value_list =
+          static_cast<const ParsePredicateInValueList&>(parse_predicate);
+
+      ExpressionResolutionInfo test_expr_resolution_info(*expression_resolution_info);
+      const E::ScalarPtr test_expression =
+          resolveExpression(*in_value_list.test_expression(),
+                            nullptr /* type_hint */,
+                            &test_expr_resolution_info);
+      if (test_expr_resolution_info.hasAggregate() && !expression_resolution_info->hasAggregate()) {
+        expression_resolution_info->parse_aggregate_expression =
+            test_expr_resolution_info.parse_aggregate_expression;
+      }
+
+      std::vector<E::ScalarPtr> match_expressions;
+      for (const ParseExpression &parse_match_expression : *in_value_list.value_list()) {
+        ExpressionResolutionInfo match_expr_resolution_info(*expression_resolution_info);
+        E::ScalarPtr match_expression =
+            resolveExpression(parse_match_expression,
+                              &test_expression->getValueType(),
+                              &match_expr_resolution_info);
+
+        const Comparison &equality_comparison =
+            ComparisonFactory::GetComparison(ComparisonID::kEqual);
+        if (!equality_comparison.canCompareTypes(match_expression->getValueType(),
+                                                 test_expression->getValueType())) {
+          THROW_SQL_ERROR_AT(&parse_match_expression)
+              << "The value expression has the type "
+              << match_expression->getValueType().getName()
+              << ", which cannot be compared with the type of the test expression "
+              << test_expression->getValueType().getName();
+        }
+
+        if (match_expr_resolution_info.hasAggregate() && !expression_resolution_info->hasAggregate()) {
+          expression_resolution_info->parse_aggregate_expression =
+              match_expr_resolution_info.parse_aggregate_expression;
+        }
+        match_expressions.emplace_back(match_expression);
+      }
+      return E::InValueList::Create(test_expression,
+                                    match_expressions);
     }
     default:
       LOG(FATAL) << "Unknown predicate: " << parse_predicate.toString();

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/query_optimizer/resolver/Resolver.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/resolver/Resolver.hpp b/query_optimizer/resolver/Resolver.hpp
index 39b5388..31afe18 100644
--- a/query_optimizer/resolver/Resolver.hpp
+++ b/query_optimizer/resolver/Resolver.hpp
@@ -445,11 +445,14 @@ class Resolver {
    * @param type_hints The type hints for output columns by the subquery.
    * @param expression_resolution_info Resolution info that contains the name
    *        resolver and info to be updated after resolution.
+   * @param has_single_column True if the subquery is expected to return only
+   *        one column in the result.
    */
   expressions::SubqueryExpressionPtr resolveSubqueryExpression(
       const ParseSubqueryExpression &parse_subquery_expression,
       const std::vector<const Type*> *type_hints,
-      ExpressionResolutionInfo *expression_resolution_info);
+      ExpressionResolutionInfo *expression_resolution_info,
+      const bool has_single_column);
 
   /**
    * @brief Resolves a relation name to a pointer to the corresponding

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/query_optimizer/rules/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/CMakeLists.txt b/query_optimizer/rules/CMakeLists.txt
index 03dcc50..3461a5e 100644
--- a/query_optimizer/rules/CMakeLists.txt
+++ b/query_optimizer/rules/CMakeLists.txt
@@ -118,6 +118,7 @@ target_link_libraries(quickstep_queryoptimizer_rules_UnnestSubqueries
                       quickstep_queryoptimizer_expressions_Expression
                       quickstep_queryoptimizer_expressions_ExpressionType
                       quickstep_queryoptimizer_expressions_ExpressionUtil
+                      quickstep_queryoptimizer_expressions_InTableQuery
                       quickstep_queryoptimizer_expressions_LogicalAnd
                       quickstep_queryoptimizer_expressions_LogicalNot
                       quickstep_queryoptimizer_expressions_LogicalOr
@@ -136,6 +137,7 @@ target_link_libraries(quickstep_queryoptimizer_rules_UnnestSubqueries
                       quickstep_queryoptimizer_rules_BottomUpRule
                       quickstep_queryoptimizer_rules_Rule
                       quickstep_types_operations_comparisons_Comparison
+                      quickstep_types_operations_comparisons_ComparisonFactory
                       quickstep_types_operations_comparisons_ComparisonID
                       quickstep_utility_Macros
                       quickstep_utility_SqlError)

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/query_optimizer/rules/UnnestSubqueries.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/UnnestSubqueries.cpp b/query_optimizer/rules/UnnestSubqueries.cpp
index 2dca36e..7852577 100644
--- a/query_optimizer/rules/UnnestSubqueries.cpp
+++ b/query_optimizer/rules/UnnestSubqueries.cpp
@@ -29,6 +29,7 @@
 #include "query_optimizer/expressions/ExprId.hpp"
 #include "query_optimizer/expressions/ExpressionType.hpp"
 #include "query_optimizer/expressions/ExpressionUtil.hpp"
+#include "query_optimizer/expressions/InTableQuery.hpp"
 #include "query_optimizer/expressions/LogicalAnd.hpp"
 #include "query_optimizer/expressions/LogicalNot.hpp"
 #include "query_optimizer/expressions/LogicalOr.hpp"
@@ -45,6 +46,7 @@
 #include "query_optimizer/logical/TopLevelPlan.hpp"
 #include "query_optimizer/rules/Rule.hpp"
 #include "types/operations/comparisons/Comparison.hpp"
+#include "types/operations/comparisons/ComparisonFactory.hpp"
 #include "types/operations/comparisons/ComparisonID.hpp"
 #include "utility/SqlError.hpp"
 
@@ -300,6 +302,7 @@ E::ExpressionPtr UnnestSubqueriesForNonRootLogical::eliminateOuterAttributeRefer
     std::vector<E::AttributeReferencePtr> *probe_join_attributes,
     std::vector<E::AttributeReferencePtr> *build_join_attributes,
     std::vector<E::PredicatePtr> *non_hash_join_predicates) {
+  DCHECK(expression->getExpressionType() != E::ExpressionType::kInTableQuery);
   DCHECK(expression->getExpressionType() != E::ExpressionType::kExists);
   DCHECK(expression->getExpressionType() != E::ExpressionType::kSubqueryExpression);
 
@@ -569,6 +572,13 @@ E::ExpressionPtr UnnestSubqueriesForExpession::applyInternal(
       transformExists(static_cast<const E::Exists&>(*node));
       return E::ExpressionPtr();
     }
+    case E::ExpressionType::kInTableQuery: {
+      if (!allow_exists_or_in) {
+        THROW_SQL_ERROR() << "IN(table query) can only appear in (un-nested) NOT, AND or by itself";
+      }
+      transformInTableQuery(static_cast<const E::InTableQuery&>(*node));
+      return E::ExpressionPtr();
+    }
     case E::ExpressionType::kLogicalNot: {
       const E::LogicalNot &logical_not = static_cast<const E::LogicalNot&>(*node);
       const E::PredicatePtr &operand = logical_not.operand();
@@ -579,6 +589,13 @@ E::ExpressionPtr UnnestSubqueriesForExpession::applyInternal(
         transformExists(static_cast<const E::Exists&>(*operand));
         correlated_query_info_vec_->back().join_type = CorrelatedQueryInfo::JoinType::kLeftAntiJoin;
         return E::PredicatePtr();
+      } else if (operand->getExpressionType() == E::ExpressionType::kInTableQuery) {
+        if (!allow_exists_or_in) {
+          THROW_SQL_ERROR() << "IN(table query) can only appear in (un-nested) NOT, AND or by itself";
+        }
+        transformInTableQuery(static_cast<const E::InTableQuery&>(*operand));
+        correlated_query_info_vec_->back().join_type = CorrelatedQueryInfo::JoinType::kLeftAntiJoin;
+        return E::PredicatePtr();
       }
       const E::ExpressionPtr new_operand =
           applyInternal(false /* allow_exists_or_in */,
@@ -688,6 +705,48 @@ void UnnestSubqueriesForExpession::transformExists(
                                            std::move(non_hash_join_predicates));
 }
 
+void UnnestSubqueriesForExpession::transformInTableQuery(
+    const E::InTableQuery &in_table_query) {
+  std::vector<E::AttributeReferencePtr> probe_join_attributes;
+  std::vector<E::AttributeReferencePtr> build_join_attributes;
+  std::vector<E::PredicatePtr> non_hash_join_predicates;
+  UnnestSubqueriesForNonRootLogical unnest_logical_rule(false,  // scalar_query
+                                                        visible_attributes_from_outer_query_,
+                                                        context_,
+                                                        uncorrelated_subqueries_,
+                                                        &probe_join_attributes,
+                                                        &build_join_attributes,
+                                                        &non_hash_join_predicates);
+  const L::LogicalPtr subquery = in_table_query.table_query()->subquery();
+  const L::LogicalPtr new_subquery = unnest_logical_rule.apply(subquery);
+
+  DCHECK(!new_subquery->getOutputAttributes().empty());
+  const E::AttributeReferencePtr join_attr_in_subquery = subquery->getOutputAttributes()[0];
+
+  E::AttributeReferencePtr test_attribute;
+  if (E::SomeAttributeReference::MatchesWithConditionalCast(in_table_query.test_expression(),
+                                                            &test_attribute)) {
+    probe_join_attributes.emplace_back(test_attribute);
+    build_join_attributes.emplace_back(join_attr_in_subquery);
+  } else {
+    if (!probe_join_attributes.empty()) {
+      non_hash_join_predicates.emplace_back(
+          E::ComparisonExpression::Create(ComparisonFactory::GetComparison(ComparisonID::kEqual),
+                                          in_table_query.test_expression(),
+                                          join_attr_in_subquery));
+    } else {
+      // TODO(qzeng): We can actually add a project to precompute the test expression.
+      THROW_SQL_ERROR() << "Cannot find an equality join predicate for IN";
+    }
+  }
+
+  correlated_query_info_vec_->emplace_back(CorrelatedQueryInfo::JoinType::kLeftSemiJoin,
+                                           new_subquery,
+                                           std::move(probe_join_attributes),
+                                           std::move(build_join_attributes),
+                                           std::move(non_hash_join_predicates));
+}
+
 E::ExpressionPtr DeOuterAttributeReference::applyToNode(const E::ExpressionPtr &input) {
   E::AttributeReferencePtr attr;
   if (E::SomeAttributeReference::MatchesWithConditionalCast(input, &attr) &&

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/query_optimizer/rules/UnnestSubqueries.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/rules/UnnestSubqueries.hpp b/query_optimizer/rules/UnnestSubqueries.hpp
index 1ab48ac..d51dfd5 100644
--- a/query_optimizer/rules/UnnestSubqueries.hpp
+++ b/query_optimizer/rules/UnnestSubqueries.hpp
@@ -41,6 +41,7 @@ class OptimizerContext;
 namespace expressions {
 
 class Exists;
+class InTableQuery;
 
 }
 
@@ -179,8 +180,22 @@ class UnnestSubqueriesForExpession : public Rule<expressions::Expression> {
       const bool allow_exists_or_in,
       const expressions::ExpressionPtr &node);
 
+  /**
+   * @brief Transform an EXIST predicate into a HashLeftSemiJoin and store the
+   *        transformed results into correlated_query_info_vec_
+   *
+   * @param exists_predicate The EXISTS predicate to be transformed.
+   */
   void transformExists(const expressions::Exists &exists_predicate);
 
+  /**
+   * @brief Transform an IN predicate into a HashLeftSemiJoin and store the
+   *        transformed results into correlated_query_info_vec_
+   *
+   * @param in_table_query The IN predicate to be transformed.
+   */
+  void transformInTableQuery(const expressions::InTableQuery &in_table_query);
+
   OptimizerContext *context_;
   std::unordered_map<expressions::ExprId, logical::LogicalPtr> *uncorrelated_subqueries_;
   std::vector<CorrelatedQueryInfo> *correlated_query_info_vec_;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/query_optimizer/tests/execution_generator/Select.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/execution_generator/Select.test b/query_optimizer/tests/execution_generator/Select.test
index 9bfa27c..0618ae2 100644
--- a/query_optimizer/tests/execution_generator/Select.test
+++ b/query_optimizer/tests/execution_generator/Select.test
@@ -764,6 +764,62 @@ WHERE
 +-----------+
 ==
 
+# IN predicate
+SELECT *
+FROM generate_series(1, 5) AS gs(i)
+WHERE i IN (2, 4);
+--
++-----------+
+|i          |
++-----------+
+|          2|
+|          4|
++-----------+
+==
+
+SELECT *
+FROM generate_series(1, 5) AS gs(i)
+WHERE i NOT IN (2, 4);
+--
++-----------+
+|i          |
++-----------+
+|          1|
+|          3|
+|          5|
++-----------+
+==
+
+SELECT *
+FROM generate_series(1, 5) AS gs(i)
+WHERE i NOT IN (i*i-6, CASE WHEN i < 3 THEN 1 ELSE 4 END);
+--
++-----------+
+|i          |
++-----------+
+|          2|
+|          5|
++-----------+
+==
+
+SELECT *
+FROM generate_series(1, 10) AS gs(i)
+WHERE i NOT IN (
+  SELECT *
+  FROM generate_series(2, 10, 2)
+);
+--
++-----------+
+|i          |
++-----------+
+|          1|
+|          3|
+|          5|
+|          7|
+|          9|
++-----------+
+==
+
 # TODO(team): Support uncorrelated queries.
 # SELECT COUNT(*)
 # FROM test

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/query_optimizer/tests/logical_generator/Select.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/logical_generator/Select.test b/query_optimizer/tests/logical_generator/Select.test
index a7a9cf8..c6d4201 100644
--- a/query_optimizer/tests/logical_generator/Select.test
+++ b/query_optimizer/tests/logical_generator/Select.test
@@ -720,3 +720,179 @@ TopLevelPlan
 |   +-AttributeReference[id=1,name=i,relation=,type=Int]
 +-output_attributes=
   +-AttributeReference[id=1,name=i,relation=,type=Int]
+==
+
+# IN predicate
+SELECT char_col
+FROM test
+WHERE int_col IN (1, 2, 3);
+--
+TopLevelPlan
++-plan=Project
+| +-input=Filter
+| | +-input=TableReference[relation_name=Test,relation_alias=test]
+| | | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| | | +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+| | | +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+| | | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+| | | +-AttributeReference[id=5,name=vchar_col,relation=test,
+| | |   type=VarChar(20) NULL]
+| | +-filter_predicate=InValueList
+| |   +-test_expression=AttributeReference[id=0,name=int_col,relation=test,
+| |   | type=Int NULL]
+| |   +-match_expressions=
+| |     +-Literal[value=1,type=Int]
+| |     +-Literal[value=2,type=Int]
+| |     +-Literal[value=3,type=Int]
+| +-project_list=
+|   +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
++-output_attributes=
+  +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+==
+
+SELECT char_col
+FROM test
+WHERE int_col*2 NOT IN (
+        long_col+1,
+        CASE WHEN float_col > 0 THEN 1
+             ELSE double_col END);
+--
+TopLevelPlan
++-plan=Project
+| +-input=Filter
+| | +-input=TableReference[relation_name=Test,relation_alias=test]
+| | | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| | | +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+| | | +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+| | | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+| | | +-AttributeReference[id=5,name=vchar_col,relation=test,
+| | |   type=VarChar(20) NULL]
+| | +-filter_predicate=NOT
+| |   +-InValueList
+| |     +-test_expression=Multiply
+| |     | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| |     | +-Literal[value=2,type=Int]
+| |     +-match_expressions=
+| |       +-Add
+| |       | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| |       | +-Literal[value=1,type=Int]
+| |       +-SearchedCase
+| |         +-else_result_expression=AttributeReference[id=3,name=double_col,
+| |         | relation=test,type=Double NULL]
+| |         +-condition_perdicates=
+| |         | +-Greater
+| |         |   +-AttributeReference[id=2,name=float_col,relation=test,
+| |         |   | type=Float]
+| |         |   +-Literal[value=0,type=Int]
+| |         +-conditional_result_expressions=
+| |           +-Cast[target_type=Double NULL]
+| |             +-operand=Literal[value=1,type=Int]
+| +-project_list=
+|   +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
++-output_attributes=
+  +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+==
+
+SELECT char_col
+FROM test
+WHERE int_col IN (
+  SELECT SUM(long_col) - 10
+  FROM test
+  GROUP BY vchar_col
+);
+--
+TopLevelPlan
++-plan=Project
+| +-input=HashLeftSemiJoin
+| | +-left=TableReference[relation_name=Test,relation_alias=test]
+| | | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| | | +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+| | | +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+| | | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+| | | +-AttributeReference[id=5,name=vchar_col,relation=test,
+| | |   type=VarChar(20) NULL]
+| | +-right=Project
+| | | +-input=Aggregate
+| | | | +-input=TableReference[relation_name=Test,relation_alias=test]
+| | | | | +-AttributeReference[id=6,name=int_col,relation=test,type=Int NULL]
+| | | | | +-AttributeReference[id=7,name=long_col,relation=test,type=Long]
+| | | | | +-AttributeReference[id=8,name=float_col,relation=test,type=Float]
+| | | | | +-AttributeReference[id=9,name=double_col,relation=test,
+| | | | | | type=Double NULL]
+| | | | | +-AttributeReference[id=10,name=char_col,relation=test,type=Char(20)]
+| | | | | +-AttributeReference[id=11,name=vchar_col,relation=test,
+| | | | |   type=VarChar(20) NULL]
+| | | | +-grouping_expressions=
+| | | | | +-AttributeReference[id=11,name=vchar_col,relation=test,
+| | | | |   type=VarChar(20) NULL]
+| | | | +-aggregate_expressions=
+| | | |   +-Alias[id=12,name=,alias=$aggregate0,relation=$aggregate,
+| | | |     type=Long NULL]
+| | | |     +-AggregateFunction[function=SUM]
+| | | |       +-AttributeReference[id=7,name=long_col,relation=test,type=Long]
+| | | +-project_list=
+| | |   +-Alias[id=13,name=,alias=(SUM(long_col)-10),relation=,type=Long NULL]
+| | |     +-Subtract
+| | |       +-AttributeReference[id=12,name=,alias=$aggregate0,
+| | |       | relation=$aggregate,type=Long NULL]
+| | |       +-Literal[value=10,type=Int]
+| | +-left_join_attributes=
+| | | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | +-right_join_attributes=
+| |   +-AttributeReference[id=13,name=,alias=(SUM(long_col)-10),relation=,
+| |     type=Long NULL]
+| +-project_list=
+|   +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
++-output_attributes=
+  +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+==
+
+SELECT char_col
+FROM test
+WHERE int_col NOT IN (
+  SELECT long_col
+  FROM test
+  WHERE long_col IN (1, 2)
+);
+--
+TopLevelPlan
++-plan=Project
+| +-input=HashLeftAntiJoin
+| | +-left=TableReference[relation_name=Test,relation_alias=test]
+| | | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| | | +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+| | | +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+| | | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+| | | +-AttributeReference[id=5,name=vchar_col,relation=test,
+| | |   type=VarChar(20) NULL]
+| | +-right=Project
+| | | +-input=Filter
+| | | | +-input=TableReference[relation_name=Test,relation_alias=test]
+| | | | | +-AttributeReference[id=6,name=int_col,relation=test,type=Int NULL]
+| | | | | +-AttributeReference[id=7,name=long_col,relation=test,type=Long]
+| | | | | +-AttributeReference[id=8,name=float_col,relation=test,type=Float]
+| | | | | +-AttributeReference[id=9,name=double_col,relation=test,
+| | | | | | type=Double NULL]
+| | | | | +-AttributeReference[id=10,name=char_col,relation=test,type=Char(20)]
+| | | | | +-AttributeReference[id=11,name=vchar_col,relation=test,
+| | | | |   type=VarChar(20) NULL]
+| | | | +-filter_predicate=InValueList
+| | | |   +-test_expression=AttributeReference[id=7,name=long_col,relation=test,
+| | | |   | type=Long]
+| | | |   +-match_expressions=
+| | | |     +-Literal[value=1,type=Long]
+| | | |     +-Literal[value=2,type=Long]
+| | | +-project_list=
+| | |   +-AttributeReference[id=7,name=long_col,relation=test,type=Long]
+| | +-left_join_attributes=
+| | | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | +-right_join_attributes=
+| |   +-AttributeReference[id=7,name=long_col,relation=test,type=Long]
+| +-project_list=
+|   +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
++-output_attributes=
+  +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]


[09/24] incubator-quickstep git commit: Minor fixes to getName() for comparisons (#166)

Posted by zu...@apache.org.
Minor fixes to getName() for comparisons (#166)

Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/6dba6e1e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/6dba6e1e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/6dba6e1e

Branch: refs/heads/master
Commit: 6dba6e1e0c7e91a058340569b9a2cf5bb1d995e6
Parents: 476f0ac
Author: Jianqiao Zhu <ji...@cs.wisc.edu>
Authored: Thu Apr 14 22:23:09 2016 -0500
Committer: Jignesh Patel <pa...@users.noreply.github.com>
Committed: Thu Apr 14 22:23:09 2016 -0500

----------------------------------------------------------------------
 parser/tests/TPCH.test                           |  4 ++--
 .../expressions/ComparisonExpression.cpp         | 19 +++----------------
 types/operations/comparisons/ComparisonID.cpp    | 10 ++++++----
 3 files changed, 11 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/6dba6e1e/parser/tests/TPCH.test
----------------------------------------------------------------------
diff --git a/parser/tests/TPCH.test b/parser/tests/TPCH.test
index af300a4..45071e4 100644
--- a/parser/tests/TPCH.test
+++ b/parser/tests/TPCH.test
@@ -803,7 +803,7 @@ SelectStatement
           | +-Equal
           | | +-left_operand=AttributeReference[attribute_name=s_nationkey]
           | | +-right_operand=AttributeReference[attribute_name=n_nationkey]
-          | +-kLike
+          | +-Like
           |   +-left_operand=AttributeReference[attribute_name=p_name]
           |   +-right_operand=Literal
           |     +-StringLiteral[value=%ghost%]
@@ -1045,7 +1045,7 @@ SelectStatement
   |     |     | +-NumericLiteral[numeric_string=0,float_like=false]
   |     |     +-when_clauses=
   |     |       +-SearchedWhenClause
-  |     |         +-condition_predicate=kLike
+  |     |         +-condition_predicate=Like
   |     |         | +-left_operand=AttributeReference[attribute_name=p_type]
   |     |         | +-right_operand=Literal
   |     |         |   +-StringLiteral[value=PROMO%]

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/6dba6e1e/query_optimizer/expressions/ComparisonExpression.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/ComparisonExpression.cpp b/query_optimizer/expressions/ComparisonExpression.cpp
index e88fc4d..5cebf8b 100644
--- a/query_optimizer/expressions/ComparisonExpression.cpp
+++ b/query_optimizer/expressions/ComparisonExpression.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.
@@ -48,22 +50,7 @@ ComparisonExpression::ComparisonExpression(const Comparison &comparison,
 }
 
 std::string ComparisonExpression::getName() const {
-  switch (comparison_.getComparisonID()) {
-    case ComparisonID::kEqual:
-      return "Equal";
-    case ComparisonID::kNotEqual:
-      return "NotEqual";
-    case ComparisonID::kLess:
-      return "Less";
-    case ComparisonID::kLessOrEqual:
-      return "LessOrEqual";
-    case ComparisonID::kGreater:
-      return "Greater";
-    case ComparisonID::kGreaterOrEqual:
-      return "GreaterOrEqual";
-    default:
-      LOG(FATAL) << "Unknown comparison type";
-  }
+  return comparison_.getName();
 }
 
 bool ComparisonExpression::isEqualityComparisonPredicate() const {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/6dba6e1e/types/operations/comparisons/ComparisonID.cpp
----------------------------------------------------------------------
diff --git a/types/operations/comparisons/ComparisonID.cpp b/types/operations/comparisons/ComparisonID.cpp
index be6f4ea..5fa3b83 100644
--- a/types/operations/comparisons/ComparisonID.cpp
+++ b/types/operations/comparisons/ComparisonID.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.
@@ -26,10 +28,10 @@ const char *kComparisonNames[] = {
   "LessOrEqual",
   "Greater",
   "GreaterOrEqual",
-  "kLike",
-  "kNotLike",
-  "kRegexMatch",
-  "kNotRegexMatch"
+  "Like",
+  "NotLike",
+  "RegexMatch",
+  "NotRegexMatch"
 };
 
 const char *kComparisonShortNames[] = {


[18/24] incubator-quickstep git commit: Added hook (not actual code) to BitWeaving. (#169)

Posted by zu...@apache.org.
Added hook (not actual code) to BitWeaving. (#169)

* Added bitweaving as a module.

* Regenerated preprocessed parser files.

* Modified validate_cmake script to allow ignored sections of code.


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/cbd169e5
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/cbd169e5
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/cbd169e5

Branch: refs/heads/master
Commit: cbd169e5a455b6a96e82b57614dabbbd59f7b0a7
Parents: d372584
Author: Marc S <cr...@users.noreply.github.com>
Authored: Sat Apr 16 18:12:42 2016 -0500
Committer: Jignesh Patel <pa...@users.noreply.github.com>
Committed: Sat Apr 16 18:12:42 2016 -0500

----------------------------------------------------------------------
 .gitmodules                                 |    3 +
 CMakeLists.txt                              |    7 +
 expressions/predicate/PredicateCost.hpp     |   14 +-
 parser/ParseIndexProperties.cpp             |    1 +
 parser/ParseIndexProperties.hpp             |   76 +
 parser/ParseStatement.hpp                   |    8 +
 parser/SqlLexer.lpp                         |    1 +
 parser/SqlParser.ypp                        |    8 +-
 parser/preprocessed/SqlLexer_gen.cpp        |  972 +++----
 parser/preprocessed/SqlLexer_gen.hpp        |    2 +-
 parser/preprocessed/SqlParser_gen.cpp       | 3031 +++++++++++-----------
 parser/preprocessed/SqlParser_gen.hpp       |  185 +-
 parser/tests/Index.test                     |    9 +
 query_optimizer/CMakeLists.txt              |    1 +
 query_optimizer/ExecutionGenerator.cpp      |    3 +-
 storage/CMakeLists.txt                      |  140 +
 storage/IndexSubBlockDescriptionFactory.hpp |    9 +-
 storage/StorageBlock.cpp                    |   28 +-
 storage/StorageBlockInfo.hpp                |    2 +
 storage/StorageBlockLayout.proto            |    2 +
 storage/StorageConfig.h.in                  |    1 +
 storage/SubBlockTypeRegistry.cpp            |   22 +
 storage/SubBlockTypeRegistry.hpp            |    4 +
 validate_cmakelists.py                      |   24 +-
 24 files changed, 2460 insertions(+), 2093 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/cbd169e5/.gitmodules
----------------------------------------------------------------------
diff --git a/.gitmodules b/.gitmodules
index 7671b11..cf380b5 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -7,3 +7,6 @@
 [submodule "third_party/googletest"]
 	path = third_party/googletest
 	url = https://github.com/google/googletest
+[submodule "storage/bitweaving"]
+	path = storage/bitweaving
+	url = https://github.com/UWQuickstep/bitweaving.git

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/cbd169e5/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 869d43c..642925f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -645,6 +645,13 @@ if (ENABLE_HDFS)
   include_directories(${LIBHDFS3_INCLUDE_DIR})
 endif()
 
+# Check if the BitWeaving index is included.
+if(EXISTS "${PROJECT_SOURCE_DIR}/storage/bitweaving/BitWeavingIndexSubBlock.hpp")
+  set(QUICKSTEP_HAVE_BITWEAVING TRUE)
+else()
+  set(QUICKSTEP_HAVE_BITWEAVING FALSE)
+endif()
+
 # Add TMB, but only enable the PureMemory implementation.
 set(ENABLE_PUREMEMORY ON CACHE BOOL "Enable PureMemory TMB")
 set(ENABLE_LEVELDB OFF CACHE BOOL "Enable LevelDB TMB")

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/cbd169e5/expressions/predicate/PredicateCost.hpp
----------------------------------------------------------------------
diff --git a/expressions/predicate/PredicateCost.hpp b/expressions/predicate/PredicateCost.hpp
index 68b44fa..b83f64c 100644
--- a/expressions/predicate/PredicateCost.hpp
+++ b/expressions/predicate/PredicateCost.hpp
@@ -35,12 +35,14 @@ namespace predicate_cost {
 // preference for different predicate-evaluation methods. In the future, we may
 // want to use statistics to get more accurate cost estimation.
 static constexpr predicate_cost_t kConstantTime = 0;
-static constexpr predicate_cost_t kBinarySearch = 1;
-static constexpr predicate_cost_t kTreeSearch = 2;
-static constexpr predicate_cost_t kCompressedColumnScan = 3;
-static constexpr predicate_cost_t kColumnScan = 4;
-static constexpr predicate_cost_t kCompressedRowScan = 5;
-static constexpr predicate_cost_t kRowScan = 6;
+static constexpr predicate_cost_t kBitWeavingVScan = 1;
+static constexpr predicate_cost_t kBitWeavingHScan = 2;
+static constexpr predicate_cost_t kBinarySearch = 3;
+static constexpr predicate_cost_t kTreeSearch = 4;
+static constexpr predicate_cost_t kCompressedColumnScan = 5;
+static constexpr predicate_cost_t kColumnScan = 6;
+static constexpr predicate_cost_t kCompressedRowScan = 7;
+static constexpr predicate_cost_t kRowScan = 8;
 static constexpr predicate_cost_t kInfinite = std::numeric_limits<predicate_cost_t>::max();
 
 }  // namespace predicate_cost

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/cbd169e5/parser/ParseIndexProperties.cpp
----------------------------------------------------------------------
diff --git a/parser/ParseIndexProperties.cpp b/parser/ParseIndexProperties.cpp
index 08790b7..fe88513 100644
--- a/parser/ParseIndexProperties.cpp
+++ b/parser/ParseIndexProperties.cpp
@@ -19,6 +19,7 @@
 
 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";

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/cbd169e5/parser/ParseIndexProperties.hpp
----------------------------------------------------------------------
diff --git a/parser/ParseIndexProperties.hpp b/parser/ParseIndexProperties.hpp
index b34346c..9ca1419 100644
--- a/parser/ParseIndexProperties.hpp
+++ b/parser/ParseIndexProperties.hpp
@@ -52,6 +52,8 @@ class IndexProperties {
     kUnimplemented,
     kDuplicateKey,
     kInvalidKey,
+    kInvalidValue,
+    kTypeIsNotString,
     kSizeIsFloat,
     kSizeIsNegative,
     kNumHashesIsFloat,
@@ -173,6 +175,80 @@ class IndexProperties {
 };
 
 /**
+ * @brief Implementation of index properties for a BitWeaving Index (H or V).
+ */
+class BitWeavingIndexProperties : public IndexProperties {
+ public:
+  static const char *kBitWeavingType;  // is of type string.
+
+  /**
+   * @brief Constructor.
+   **/
+  BitWeavingIndexProperties()
+    : IndexProperties(new IndexSubBlockDescription()) {
+    // Default to BITWEAVING_V, custom properties can change this to H.
+    index_sub_block_description_->set_sub_block_type(IndexSubBlockDescription::BITWEAVING_V);
+  }
+
+  ~BitWeavingIndexProperties() override {
+  }
+
+  std::string getReasonForInvalidIndexDescription() const override {
+    switch (invalid_index_type_) {
+      case InvalidIndexType::kNone:
+        return "";
+      case InvalidIndexType::kDuplicateKey:  // Fall through.
+      case InvalidIndexType::kInvalidKey:
+        return "The only valid property for BitWeaving is TYPE.";
+      case InvalidIndexType::kTypeIsNotString:  // Fall through.
+      case InvalidIndexType::kInvalidValue:
+        return "The only valid values for TYPE are V or H.";
+      default:
+        return "Unknown reason";
+    }
+  }
+
+  bool addCustomProperties(const PtrList<ParseKeyValue> *key_value_list) override {
+    if (key_value_list->size() == 0u) {
+      // No properties specified.
+      return true;
+    } else if (key_value_list->size() == 1u) {
+      const ParseKeyValue &key_value = *key_value_list->begin();
+      if (key_value.getKeyValueType() != ParseKeyValue::KeyValueType::kStringString) {
+        setIndexDescriptionAsInvalid(InvalidIndexType::kTypeIsNotString, &key_value);
+        return false;
+      }
+      const std::string key = ToLower(key_value.key()->value());
+      const std::string value = ToLower(
+          static_cast<const ParseKeyStringValue&>(key_value).key()->value());
+      if (key.compare(kBitWeavingType) == 0) {
+        if (value.compare("h") == 0) {
+          index_sub_block_description_->set_sub_block_type(IndexSubBlockDescription::BITWEAVING_H);
+          return true;
+        } else if (value.compare("v") != 0) {
+          setIndexDescriptionAsInvalid(InvalidIndexType::kInvalidValue, &key_value);
+          return false;
+        } else {
+          // If V was specified, then we do nothing because it's set to V by default.
+          return true;
+        }
+      } else {
+        // Incorrect key specified.
+        setIndexDescriptionAsInvalid(InvalidIndexType::kInvalidKey, &key_value);
+        return false;
+      }
+    } else {
+      // More than one key. This must be an error.
+      invalid_index_type_ = InvalidIndexType::kDuplicateKey;
+      return false;
+    }
+  }
+
+ private:
+  DISALLOW_COPY_AND_ASSIGN(BitWeavingIndexProperties);
+};
+
+/**
  * @brief Implementation of index properties for Bloom Filter Index
  */
 class BloomFilterIndexProperties : public IndexProperties {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/cbd169e5/parser/ParseStatement.hpp
----------------------------------------------------------------------
diff --git a/parser/ParseStatement.hpp b/parser/ParseStatement.hpp
index 643643d..65acc68 100644
--- a/parser/ParseStatement.hpp
+++ b/parser/ParseStatement.hpp
@@ -345,6 +345,10 @@ class ParseStatementCreateIndex : public ParseStatement {
       inline_field_names->push_back("index_type");
       const int index_type_enum_val = std::stoi(index_type_->value());
       switch (index_type_enum_val) {
+        case IndexSubBlockType::kBitWeavingV:  // Fall through.
+        case IndexSubBlockType::kBitWeavingH:
+          inline_field_values->push_back("bitweaving");
+          break;
         case IndexSubBlockType::kCSBTree:
           inline_field_values->push_back("cs_b_tree");
           break;
@@ -385,6 +389,10 @@ class ParseStatementCreateIndex : public ParseStatement {
     void initializeIndexType() {
       const int index_type_enum_val = std::stoi(index_type_->value());
       switch (index_type_enum_val) {
+        case IndexSubBlockType::kBitWeavingV:  // Fall through.
+        case IndexSubBlockType::kBitWeavingH:
+          index_properties_.reset(new BitWeavingIndexProperties());
+          break;
         case IndexSubBlockType::kBloomFilter:
           index_properties_.reset(new BloomFilterIndexProperties());
           break;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/cbd169e5/parser/SqlLexer.lpp
----------------------------------------------------------------------
diff --git a/parser/SqlLexer.lpp b/parser/SqlLexer.lpp
index 4ee50ec..5c2e221 100644
--- a/parser/SqlLexer.lpp
+++ b/parser/SqlLexer.lpp
@@ -174,6 +174,7 @@ unsigned_numeric_literal {exact_numeric_literal}|{approximate_numeric_literal}
   "between"          return TOKEN_BETWEEN;
   "bigint"           return TOKEN_BIGINT;
   "bit"              return TOKEN_BIT;
+  "bitweaving"       return TOKEN_BITWEAVING;
   "blockproperties"  return TOKEN_BLOCKPROPERTIES;
   "blocksample"      return TOKEN_BLOCKSAMPLE;
   "bloomfilter"      return TOKEN_BLOOM_FILTER;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/cbd169e5/parser/SqlParser.ypp
----------------------------------------------------------------------
diff --git a/parser/SqlParser.ypp b/parser/SqlParser.ypp
index 70db649..0cf4590 100644
--- a/parser/SqlParser.ypp
+++ b/parser/SqlParser.ypp
@@ -238,6 +238,7 @@ void NotSupported(const YYLTYPE *location, yyscan_t yyscanner, const std::string
 %token TOKEN_ASC;
 %token TOKEN_BIGINT;
 %token TOKEN_BIT;
+%token TOKEN_BITWEAVING;
 %token TOKEN_BLOCKPROPERTIES;
 %token TOKEN_BLOCKSAMPLE;
 %token TOKEN_BLOOM_FILTER;
@@ -985,7 +986,12 @@ key_integer_value:
   };
 
 index_type:
-  TOKEN_BLOOM_FILTER {
+  TOKEN_BITWEAVING {
+    // Defaults to BitWeavingV, but IndexProperties can change this to H.
+    $$ = new quickstep::ParseString(@1.first_line, @1.first_column,
+           std::to_string(quickstep::IndexSubBlockType::kBitWeavingV));
+  }
+  | TOKEN_BLOOM_FILTER {
     $$ = new quickstep::ParseString(@1.first_line, @1.first_column,
            std::to_string(quickstep::IndexSubBlockType::kBloomFilter));
   }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/cbd169e5/parser/preprocessed/SqlLexer_gen.cpp
----------------------------------------------------------------------
diff --git a/parser/preprocessed/SqlLexer_gen.cpp b/parser/preprocessed/SqlLexer_gen.cpp
index 4175e20..d00d51f 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 143
-#define YY_END_OF_BUFFER 144
+#define YY_NUM_RULES 144
+#define YY_END_OF_BUFFER 145
 /* This struct is not used in this scanner,
    but its presence is necessary. */
 struct yy_trans_info
@@ -390,65 +390,66 @@ struct yy_trans_info
 	flex_int32_t yy_verify;
 	flex_int32_t yy_nxt;
 	};
-static yyconst flex_int16_t yy_accept[520] =
+static yyconst flex_int16_t yy_accept[527] =
     {   0,
         0,    0,    0,    0,    0,    0,    0,    0,    0,    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
+        0,    0,  145,    2,    2,  143,  143,  142,  141,  143,
+      120,  116,  119,  116,  116,  139,  112,  109,  113,  138,
+      138,  138,  138,  138,  138,  138,  138,  138,  138,  138,
+      138,  138,  138,  138,  138,  138,  138,  138,  138,  138,
+      138,  138,  138,  117,    4,    5,    5,    3,  135,  135,
+      132,  136,  136,  130,  137,  137,  134,    1,  142,  110,
+      140,  139,  139,  139,    0,  114,  111,  115,  138,  138,
+      138,  138,   10,  138,  138,  138,   22,  138,  138,  138,
+      138,  138,  138,  138,  138,  138,  138,  118,  138,  138,
+
+      138,  138,  138,  138,  138,  138,  138,  138,  138,  138,
+       55,   63,  138,  138,  138,  138,  138,  138,  138,  138,
+      138,   75,   76,  138,  138,  138,  138,  138,  138,  138,
+      138,  138,  138,  138,  138,  138,  138,  138,  138,  138,
+      138,  138,  138,  138,  138,  138,    4,    5,    3,  135,
+      131,  136,  129,  129,  121,  123,  124,  125,  126,  127,
+      128,  129,  137,  133,  140,  139,    0,  139,    6,    7,
+      138,    9,   11,  138,  138,   15,  138,  138,  138,  138,
+      138,  138,  138,  138,  138,  138,  138,  138,  138,  138,
+      138,  138,  138,  138,   42,  138,  138,  138,  138,  138,
+
+      138,  138,  138,  138,  138,  138,  138,  138,  138,  138,
+       59,  138,   65,  138,  138,  138,  138,  138,   71,  138,
+       74,  138,  138,  138,  138,  138,  138,  138,  138,  138,
+      138,  138,  138,  138,   91,   92,  138,  138,  138,  138,
+      138,  138,  138,  138,  138,  138,  138,  138,  138,  121,
+      123,  122,  138,  138,  138,  138,  138,  138,  138,   20,
+       23,  138,  138,  138,   28,  138,  138,   30,  138,  138,
+      138,  138,   36,  138,  138,   40,   41,  138,  138,  138,
+      138,  138,  138,  138,   50,   51,  138,   53,  138,  138,
+      138,  138,  138,   62,   64,   66,   67,   68,  138,   70,
+
+       72,  138,  138,  138,  138,  138,   83,  138,   85,  138,
+      138,  138,  138,  138,  138,  138,   95,   96,   98,  138,
+      138,  138,  138,  138,  138,  105,  138,  107,  138,  121,
+      122,    8,  138,  138,  138,  138,  138,  138,  138,   25,
+      138,  138,  138,  138,  138,  138,  138,  138,  138,  138,
+      138,  138,  138,  138,  138,   46,   47,   48,  138,   52,
+      138,   56,   57,  138,  138,  138,   69,   73,   77,   78,
+      138,  138,  138,   84,  138,  138,   88,  138,  138,  138,
+       94,  138,  138,  138,  138,  102,  138,  138,  106,  138,
+      138,  138,   14,  138,  138,  138,  138,  138,   26,  138,
+
+       29,  138,  138,  138,  138,   34,  138,  138,  138,   39,
+      138,   44,  138,  138,   54,   58,  138,  138,  138,  138,
+      138,  138,   87,  138,   90,  138,  138,  138,  100,  101,
+      103,  138,  138,  138,   13,  138,  138,  138,  138,  138,
+      138,   21,  138,   32,   33,  138,  138,  138,  138,   45,
+       49,   60,  138,  138,   81,   82,  138,  138,  138,  138,
+      138,  104,  138,  138,  138,  138,  138,  138,  138,  138,
+       31,  138,  138,   38,  138,   61,  138,  138,  138,   93,
+      138,  138,  138,   12,  138,  138,  138,  138,   24,  138,
+       35,  138,  138,   79,  138,  138,   97,  138,  108,   16,
+
+      138,  138,  138,   27,   37,  138,   80,   86,  138,  138,
+      138,   18,   19,  138,  138,   99,  138,  138,  138,  138,
+      138,   89,  138,   43,   17,    0
     } ;
 
 static yyconst YY_CHAR yy_ec[256] =
@@ -495,139 +496,141 @@ static yyconst YY_CHAR yy_meta[72] =
         8
     } ;
 
-static yyconst flex_uint16_t yy_base[535] =
+static yyconst flex_uint16_t yy_base[542] =
     {   0,
         0,    1,   46,    0,  117,  163,    2,    3,  128,  132,
-        6,   10,  260, 1157, 1157,    0, 1157,   13, 1157,  241,
-     1157, 1157, 1157,  239,    6,  130,    4, 1157,  202,  124,
+        6,   10,  260, 1177, 1177,    0, 1177,   13, 1177,  241,
+     1177, 1177, 1177,  239,    6,  130,    4, 1177,  202,  124,
       161,  170,  178,  207,  260,   92,  110,  161,   97,  108,
       219,    0,  153,  221,  176,  108,  232,  171,  276,  272,
-      129,  221,  177, 1157,  184,    4,   19,    0,    0,    0,
-      146,    0,    0,  340,    0,    0,  145,    0,   22, 1157,
-        0,  249,  284,  334,   18, 1157, 1157, 1157,    0,  232,
+      129,  221,  177, 1177,  184,    4,   19,    0,    0,    0,
+      146,    0,    0,  340,    0,    0,  145,    0,   22, 1177,
+        0,  249,  284,  334,   18, 1177, 1177, 1177,    0,  232,
       262,  234,  270,  267,  285,  278,    0,  276,  307,  331,
-      291,  307,  299,  347,  313,  312,  325, 1157,  325,  345,
+      291,  307,  299,  347,  313,  312,  325, 1177,  325,  345,
 
       348,  343,  343,  338,  342,  347,  352,  358,  362,  378,
       394,    0,  381,  366,  382,  396,  392,  390,  387,  397,
       404,    0,  407,  392,  397,  398,  408,  409,  407,  447,
       415,  400,  437,  434,  453,  451,  445,  438,  444,  452,
       458,  454,  453,  461,  447,  467,  148,   29,    0,    0,
-     1157,    0, 1157, 1157,   22,   24, 1157, 1157, 1157, 1157,
-     1157,    0,    0, 1157,    0,  474,   26,   28,    0,    0,
-      467,    0,  468,  451,  466,    0,  478,  471,  462,  495,
-      478,  487,  482,  510,  492,  508,  505,  514,  511,  514,
-      498,  517,  505,  518,    0,  523,  506,  508,  510,  511,
-
-      530,  527,  520,  522,  516,  530,  530,  546,  551,  552,
-      559,  551,    0,  549,  550,  566,  563,  566,    0,  563,
-        0,  571,  572,  558,  576,  568,  562,  576,  572,  582,
-      583,  581,   98,  585,    0,  579,  580,  581,  591,  592,
-      597,  597,  614,  608,  602,  624,  614,  621,  612,   30,
-      125,    0,  613,  619,  629,  621,  625,  624,    0,  638,
-      629,  628,  622,    0,  625,  628,  627,  635,  628,  630,
-      640,  649,  646,  655,    0,    0,  656,  653,  679,  676,
-      665,  666,  678,    0,    0,  672,    0,  675,  666,  673,
-      674,  686,    0,    0,    0,    0,    0,  674,    0,  676,
-
-      679,  680,  690,  695,  702,    0,  700,    0,  688,  683,
-      688,  707,  709,  701,  720,    0,  711,    0,  726,  717,
-      719,  736,  739,  737,    0,  741,    0,  734,  136, 1157,
-        0,  744,  744,  730,  736,  745,  750,    0,  742,  739,
-      753,  756,  753,  762,  752,  760,  757,  755,  756,  766,
-      778,  769,  786,    0,    0,    0,  789,    0,  790,    0,
-        0,  781,  797,  781,    0,    0,    0,    0,  784,  791,
-      788,    0,  802,  792,    0,  804,  790,  802,    0,  793,
-      795,  810,  811,    0,  800,  819,    0,  806,  813,  809,
-        0,  806,  826,  819,  809,    0,  840,    0,  841,  834,
-
-      842,  835,    0,  839,  856,  858,    0,   93,    0,  842,
-      849,    0,    0,  846,  864,  857,  847,  843,  855,    0,
-      859,    0,  858,  872,  873,    0,    0,    0,  859,  864,
-      865,    0,  865,  868,  870,  880,  877,    0,  882,    0,
-        0,  894,  895,  885,  893,    0,    0,    0,  901,  902,
-        0,    0,  915,  910,  900,  908,  909,    0,  903,  917,
-      909,  910,  907,  911,  916,    0,  913,  918,    0,  915,
-        0,  922,  932,  925,    0,  923,  924,  935,    0,  939,
-      933,  952,    0,  942,    0,  956,  952,  952,  956,  967,
-        0,  965,    0,  960,  974,  962,    0,    0,  972,    0,
-
-        0,  962,  978,  964,    0,    0,  971,  982,    0,  979,
-      982,  972,  988,  975,    0,  976,    0,    0, 1157, 1041,
-     1051, 1061, 1071, 1081, 1085, 1088, 1094, 1102, 1112, 1122,
-     1132, 1142, 1147, 1149
+     1177,    0, 1177, 1177,   22,   24, 1177, 1177, 1177, 1177,
+     1177,    0,    0, 1177,    0,  474,   26,   28,    0,    0,
+      467,    0,  468,  451,  466,  453,  478,  475,  480,  496,
+      485,  488,  486,  511,  493,  509,  506,  515,  512,  515,
+      499,  518,  507,  519,    0,  524,  507,  511,  511,  512,
+
+      531,  528,  521,  525,  517,  531,  542,  551,  552,  559,
+      560,  555,    0,  550,  551,  567,  564,  567,    0,  564,
+        0,  572,  573,  559,  578,  569,  563,  577,  575,  583,
+      584,  582,   98,  586,    0,  580,  583,  582,  592,  604,
+      602,  598,  621,  609,  606,  625,  615,  622,  613,   30,
+      125,    0,  614,  620,  630,  622,  632,  628,  627,    0,
+      640,  631,  632,  626,    0,  627,  630,  629,  637,  632,
+      634,  642,  662,  663,  661,    0,    0,  664,  661,  684,
+      681,  667,  668,  680,    0,    0,  674,    0,  677,  668,
+      675,  676,  688,    0,    0,    0,    0,    0,  677,    0,
+
+      679,  681,  682,  694,  699,  704,    0,  702,    0,  690,
+      687,  692,  709,  722,  718,  726,    0,  719,    0,  734,
+      722,  724,  738,  741,  739,    0,  743,    0,  736,  136,
+     1177,    0,  746,  746,  732,  752,  739,  750,  754,    0,
+      747,  744,  758,  759,  756,  765,  757,  765,  762,  769,
+      774,  784,  791,  778,  798,    0,    0,    0,  795,    0,
+      796,    0,    0,  784,  800,  784,    0,    0,    0,    0,
+      787,  794,  791,    0,  805,  795,    0,  808,  794,  806,
+        0,  796,  800,  815,  816,    0,  803,  822,    0,  809,
+      818,  814,    0,  807,  823,  845,  838,  834,    0,  854,
+
+        0,  854,  847,  849,  842,    0,  843,  860,  862,    0,
+       93,    0,  846,  853,    0,    0,  850,  868,  862,  852,
+      848,  860,    0,  865,    0,  864,  878,  879,    0,    0,
+        0,  863,  868,  871,    0,  877,  872,  886,  892,  900,
+      903,    0,  908,    0,    0,  912,  909,  899,  901,    0,
+        0,    0,  909,  907,    0,    0,  920,  915,  905,  913,
+      914,    0,  909,  923,  917,  916,  919,  916,  919,  924,
+        0,  921,  926,    0,  923,    0,  930,  940,  944,    0,
+      946,  947,  962,    0,  964,  970,  964,  972,    0,  958,
+        0,  972,  962,  962,  963,  974,    0,  972,    0,    0,
+
+      967,  982,  970,    0,    0,  980,    0,    0,  970,  988,
+      974,    0,    0,  981,  991,    0,  988,  991,  983,  997,
+      984,    0,  996,    0,    0, 1177, 1061, 1071, 1081, 1091,
+     1101, 1105, 1108, 1114, 1122, 1132, 1142, 1152, 1162, 1167,
+     1169
     } ;
 
-static yyconst flex_int16_t yy_def[535] =
+static yyconst flex_int16_t yy_def[542] =
     {   0,
-      520,  520,  519,    3,  521,  521,  522,  522,  523,  523,
-      524,  524,  519,  519,  519,  525,  519,  519,  519,  519,
-      519,  519,  519,  519,  519,  519,  519,  519,  519,  526,
+      527,  527,  526,    3,  528,  528,  529,  529,  530,  530,
+      531,  531,  526,  526,  526,  532,  526,  526,  526,  526,
+      526,  526,  526,  526,  526,  526,  526,  526,  526,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  526,  526,  526,  526,  534,  535,  535,
+      526,  536,  536,  537,  538,  538,  526,  532,  526,  526,
+      539,  526,  526,  526,  526,  526,  526,  526,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  526,  533,  533,
+
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  526,  526,  534,  535,
+      526,  536,  526,  526,  526,  526,  526,  526,  526,  526,
+      526,  540,  538,  526,  539,  526,  526,  526,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  526,
+      526,  541,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  526,
+      526,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,  533,  533,  533,  533,  533,
+      533,  533,  533,  533,  533,    0,  526,  526,  526,  526,
       526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  519,  519,  519,  519,  527,  528,  528,
-      519,  529,  529,  530,  531,  531,  519,  525,  519,  519,
-      532,  519,  519,  519,  519,  519,  519,  519,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  519,  526,  526,
-
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  519,  519,  527,  528,
-      519,  529,  519,  519,  519,  519,  519,  519,  519,  519,
-      519,  533,  531,  519,  532,  519,  519,  519,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  519,
-      519,  534,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  519,  519,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-
-      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
-      526,  526,  526,  526,  526,  526,  526,  526,    0,  519,
-      519,  519,  519,  519,  519,  519,  519,  519,  519,  519,
-      519,  519,  519,  519
+      526
     } ;
 
-static yyconst flex_uint16_t yy_nxt[1229] =
+static yyconst flex_uint16_t yy_nxt[1249] =
     {   0,
-      519,  519,   15,   15,   60,   60,  148,  148,   66,   61,
-       61,   67,   66,  519,   69,   67,   69,   72,   72,   76,
-       77,  148,  148,   69,  519,   69,  167,  167,  519,  168,
+      526,  526,   15,   15,   60,   60,  148,  148,   66,   61,
+       61,   67,   66,  526,   69,   67,   69,   72,   72,   76,
+       77,  148,  148,   69,  526,   69,  167,  167,  526,  168,
       168,  148,  148,  250,  251,  251,  251,  168,  168,  168,
-      168,  329,  251,  519,   16,   16,   17,   18,   19,   18,
+      168,  330,  251,  526,   16,   16,   17,   18,   19,   18,
        20,   21,   22,   23,   22,   24,   25,   26,   26,   17,
        27,   28,   29,   30,   31,   32,   33,   34,   35,   36,
        37,   38,   39,   40,   41,   42,   43,   44,   45,   46,
@@ -637,8 +640,8 @@ static yyconst flex_uint16_t yy_nxt[1229] =
        38,   39,   40,   41,   42,   43,   44,   45,   46,   47,
        48,   49,   50,   51,   52,   42,   53,   17,   55,   56,
        57,   17,   17,   17,   17,   17,  109,  110,  113,  114,
-       63,   17,   17,   17,   63,   61,  251,  251,  445,   61,
-       73,   74,   74,  312,   80,  128,  143,  251,  251,  147,
+       63,   17,   17,   17,   63,   61,  251,  251,  449,   61,
+       73,   74,   74,  313,   80,  128,  143,  251,  251,  147,
       164,   75,   81,  151,   82,  109,  110,  113,  114,   83,
        17,   17,   17,   17,   55,   56,   57,   17,   17,   17,
        17,   17,   64,   80,  128,  143,   64,   17,   17,   17,
@@ -650,17 +653,17 @@ static yyconst flex_uint16_t yy_nxt[1229] =
       111,  133,  125,   89,   93,  112,  126,  146,   94,  134,
        90,   87,   95,   91,   92,   99,  115,  100,   96,  127,
       116,   97,  101,  121,  117,  144,  145,  102,   71,  129,
-      118,  122,  169,  130,  172,  123,   70,  131,  124,  519,
-       72,   72,  519,  132,   99,  115,  100,  519,  519,  116,
+      118,  122,  169,  130,  172,  123,   70,  131,  124,  526,
+       72,   72,  526,  132,   99,  115,  100,  526,  526,  116,
        75,  101,  121,  117,  144,  145,  102,  103,  129,  118,
       122,  169,  130,  172,  123,  104,  131,  124,  105,  173,
       170,  106,  132,  135,  107,  166,  166,  108,  171,   75,
 
       136,  137,  140,  174,  141,   75,  103,  142,  175,  177,
-      138,  178,  184,  139,  104,  519,  519,  105,  173,  170,
+      138,  178,  184,  139,  104,  526,  526,  105,  173,  170,
       106,  176,  135,  107,  179,  185,  108,  171,  180,  136,
       137,  140,  174,  141,   75,  186,  142,  175,  177,  138,
-      178,  184,  139,  154,   73,   74,   74,  519,  191,  192,
+      178,  184,  139,  154,   73,   74,   74,  526,  191,  192,
       176,  155,  156,  179,  185,   75,  193,  180,  157,  181,
       194,  182,  158,  183,  186,  195,  187,  196,  197,  188,
       159,  199,  200,  201,  160,  189,  161,  191,  192,  198,
@@ -671,59 +674,59 @@ static yyconst flex_uint16_t yy_nxt[1229] =
       202,  190,  203,  206,  208,  204,  207,  214,  215,  216,
       218,  217,  205,  219,  209,  220,  221,  222,  223,  210,
       211,  224,  225,  226,  227,  212,  213,  228,  232,  233,
-      519,  519,  206,  208,  519,  207,  214,  215,  216,  218,
+      526,  526,  206,  208,  526,  207,  214,  215,  216,  218,
       217,  236,  219,  209,  220,  221,  222,  223,  210,  211,
       224,  225,  226,  227,  229,  234,  228,  232,  233,  230,
       231,  237,  238,  235,  239,  240,  241,  242,  243,  244,
       236,  245,  247,  248,  249,  166,  166,  246,  253,  254,
-      255,  256,  259,  229,  234,   75,  260,  257,  230,  231,
+      255,  256,  257,  229,  234,   75,  260,  258,  230,  231,
 
-      237,  238,  235,  239,  240,  241,  242,  243,  244,  258,
+      237,  238,  235,  239,  240,  241,  242,  243,  244,  259,
       245,  247,  248,  249,  261,  262,  246,  253,  254,  255,
-      256,  259,  263,  264,   75,  260,  257,  265,  266,  267,
-      268,  269,  270,  272,  273,  274,  271,  275,  258,  276,
+      256,  257,  263,  264,   75,  260,  258,  265,  266,  267,
+      268,  269,  270,  271,  273,  274,  275,  272,  259,  276,
       277,  278,  279,  261,  262,  280,  281,  282,  283,  284,
       285,  263,  264,  286,  287,  288,  265,  266,  267,  268,
-      269,  270,  272,  273,  274,  271,  275,  289,  276,  277,
+      269,  270,  271,  273,  274,  275,  272,  289,  276,  277,
       278,  279,  290,  291,  280,  281,  282,  283,  284,  285,
-      292,  294,  286,  287,  288,  295,  296,  297,  298,  299,
-      293,  300,  301,  302,  303,  304,  289,  305,  306,  307,
-
-      308,  290,  291,  309,  310,  311,  313,  314,  315,  292,
-      294,  316,  317,  318,  295,  296,  297,  298,  299,  293,
-      300,  301,  302,  303,  304,  319,  305,  306,  307,  308,
-      320,  321,  309,  310,  311,  313,  314,  315,  322,  323,
-      316,  317,  318,  324,  325,  327,  328,  331,  326,  332,
+      292,  293,  286,  287,  288,  295,  296,  297,  298,  299,
+      300,  294,  301,  302,  303,  304,  289,  305,  306,  307,
+
+      308,  290,  291,  309,  310,  311,  312,  314,  315,  292,
+      293,  316,  317,  318,  295,  296,  297,  298,  299,  300,
+      294,  301,  302,  303,  304,  319,  305,  306,  307,  308,
+      320,  321,  309,  310,  311,  312,  314,  315,  322,  323,
+      316,  317,  318,  324,  325,  326,  328,  329,  332,  327,
       333,  334,  335,  336,  319,  337,  338,  339,  340,  320,
       321,  341,  342,  343,  344,  345,  346,  322,  323,  347,
-      348,  349,  324,  325,  327,  328,  331,  326,  332,  333,
+      348,  349,  324,  325,  326,  328,  329,  332,  327,  333,
       334,  335,  336,  350,  337,  338,  339,  340,  351,  352,
       341,  342,  343,  344,  345,  346,  353,  354,  347,  348,
 
       349,  355,  356,  357,  358,  359,  360,  361,  362,  363,
-      365,  366,  350,  367,  368,  369,  370,  351,  352,  371,
-      364,  372,  373,  374,  375,  353,  354,  376,  377,  378,
-      355,  356,  357,  358,  359,  360,  361,  362,  363,  365,
-      366,  379,  367,  368,  369,  370,  380,  381,  371,  364,
-      372,  373,  374,  375,  382,  383,  376,  377,  378,  384,
-      385,  386,  387,  388,  389,  390,  391,  394,  392,  395,
-      379,  393,  396,  397,  398,  380,  381,  399,  400,  401,
+      364,  365,  350,  367,  368,  369,  370,  351,  352,  371,
+      372,  373,  366,  374,  375,  353,  354,  376,  377,  378,
+      355,  356,  357,  358,  359,  360,  361,  362,  363,  364,
+      365,  379,  367,  368,  369,  370,  380,  381,  371,  372,
+      373,  366,  374,  375,  382,  383,  376,  377,  378,  384,
+      385,  386,  387,  388,  389,  390,  391,  392,  393,  394,
+      379,  395,  397,  398,  396,  380,  381,  399,  400,  401,
       402,  403,  404,  382,  383,  405,  406,  407,  384,  385,
-      386,  387,  388,  389,  390,  391,  394,  392,  395,  408,
+      386,  387,  388,  389,  390,  391,  392,  393,  394,  408,
 
-      393,  396,  397,  398,  409,  410,  399,  400,  401,  402,
+      395,  397,  398,  396,  409,  410,  399,  400,  401,  402,
       403,  404,  411,  412,  405,  406,  407,  413,  414,  415,
       416,  417,  418,  419,  420,  421,  422,  423,  408,  424,
       425,  426,  427,  409,  410,  428,  429,  430,  431,  432,
       433,  411,  412,  434,  435,  436,  413,  414,  415,  416,
       417,  418,  419,  420,  421,  422,  423,  437,  424,  425,
       426,  427,  438,  439,  428,  429,  430,  431,  432,  433,
-      440,  441,  434,  435,  436,  442,  443,  444,  446,  447,
-      448,  449,  450,  451,  452,  453,  437,  454,  455,  456,
+      440,  441,  434,  435,  436,  442,  443,  444,  445,  446,
+      447,  448,  450,  451,  452,  453,  437,  454,  455,  456,
       457,  438,  439,  458,  459,  460,  461,  462,  463,  440,
 
-      441,  464,  465,  466,  442,  443,  444,  446,  447,  448,
-      449,  450,  451,  452,  453,  467,  454,  455,  456,  457,
+      441,  464,  465,  466,  442,  443,  444,  445,  446,  447,
+      448,  450,  451,  452,  453,  467,  454,  455,  456,  457,
       468,  469,  458,  459,  460,  461,  462,  463,  470,  471,
       464,  465,  466,  472,  473,  474,  475,  476,  477,  478,
       479,  480,  481,  482,  467,  483,  484,  485,  486,  468,
@@ -734,33 +737,35 @@ static yyconst flex_uint16_t yy_nxt[1229] =
       495,  501,  502,  503,  504,  505,  506,  507,  508,  509,
 
       510,  511,  496,  512,  513,  514,  515,  497,  498,  516,
-      517,  518,  519,  519,  519,  499,  500,  519,  519,  519,
+      517,  518,  519,  520,  521,  499,  500,  522,  523,  524,
       501,  502,  503,  504,  505,  506,  507,  508,  509,  510,
-      511,  519,  512,  513,  514,  515,  519,  519,  516,  517,
-      518,   14,   14,   14,   14,   14,   14,   14,   14,   14,
+      511,  525,  512,  513,  514,  515,  526,  526,  516,  517,
+      518,  519,  520,  521,  526,  526,  522,  523,  524,  526,
+      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
+      525,   14,   14,   14,   14,   14,   14,   14,   14,   14,
        14,   58,   58,   58,   58,   58,   58,   58,   58,   58,
        58,   59,   59,   59,   59,   59,   59,   59,   59,   59,
        59,   62,   62,   62,   62,   62,   62,   62,   62,   62,
+
        62,   65,   65,   65,   65,   65,   65,   65,   65,   65,
-       65,   68,   68,   79,   79,   79,  519,   79,  149,  149,
-
-      149,  149,  150,  150,  150,  519,  150,  150,  150,  150,
-      150,  150,  152,  152,  152,  519,  152,  152,  152,  152,
-      519,  152,  153,  153,  153,  153,  153,  153,  153,  153,
-      153,  153,  163,  163,  519,  163,  163,  163,  163,  163,
-      163,  163,  165,  519,  165,  165,  165,  165,  165,  165,
-      165,  165,  252,  252,  330,  330,   13,  519,  519,  519,
-      519,  519,  519,  519,  519,  519,  519,  519,  519,  519,
-      519,  519,  519,  519,  519,  519,  519,  519,  519,  519,
-      519,  519,  519,  519,  519,  519,  519,  519,  519,  519,
-      519,  519,  519,  519,  519,  519,  519,  519,  519,  519,
-
-      519,  519,  519,  519,  519,  519,  519,  519,  519,  519,
-      519,  519,  519,  519,  519,  519,  519,  519,  519,  519,
-      519,  519,  519,  519,  519,  519,  519,  519
+       65,   68,   68,   79,   79,   79,  526,   79,  149,  149,
+      149,  149,  150,  150,  150,  526,  150,  150,  150,  150,
+      150,  150,  152,  152,  152,  526,  152,  152,  152,  152,
+      526,  152,  153,  153,  153,  153,  153,  153,  153,  153,
+      153,  153,  163,  163,  526,  163,  163,  163,  163,  163,
+      163,  163,  165,  526,  165,  165,  165,  165,  165,  165,
+      165,  165,  252,  252,  331,  331,   13,  526,  526,  526,
+      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
+      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
+
+      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
+      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
+      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
+      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
+      526,  526,  526,  526,  526,  526,  526,  526
     } ;
 
-static yyconst flex_int16_t yy_chk[1229] =
+static yyconst flex_int16_t yy_chk[1249] =
     {   0,
         0,    0,    1,    2,    7,    8,   56,   56,   11,    7,
         8,   11,   12,    0,   18,   12,   18,   25,   25,   27,
@@ -776,8 +781,8 @@ static yyconst flex_int16_t yy_chk[1229] =
         3,    3,    3,    3,    3,    3,    3,    3,    3,    3,
         3,    3,    3,    3,    3,    3,    3,    5,    5,    5,
         5,    5,    5,    5,    5,    5,   36,   37,   39,   40,
-        9,    5,    5,    5,   10,    9,  251,  251,  408,   10,
-       26,   26,   26,  233,   30,   46,   51,  329,  329,  147,
+        9,    5,    5,    5,   10,    9,  251,  251,  411,   10,
+       26,   26,   26,  233,   30,   46,   51,  330,  330,  147,
        67,   26,   30,   61,   30,   36,   37,   39,   40,   30,
         5,    5,    5,    6,    6,    6,    6,    6,    6,    6,
         6,    6,    9,   30,   46,   51,   10,    6,    6,    6,
@@ -815,92 +820,94 @@ static yyconst flex_int16_t yy_chk[1229] =
       125,  126,  127,  128,  130,  133,  129,  131,  132,  130,
       130,  135,  136,  133,  137,  138,  139,  140,  141,  142,
       134,  143,  144,  145,  146,  166,  166,  143,  171,  173,
-      174,  175,  178,  130,  133,  166,  179,  177,  130,  130,
+      174,  175,  176,  130,  133,  166,  178,  177,  130,  130,
 
       135,  136,  133,  137,  138,  139,  140,  141,  142,  177,
-      143,  144,  145,  146,  180,  181,  143,  171,  173,  174,
-      175,  178,  182,  183,  166,  179,  177,  184,  185,  186,
-      187,  188,  189,  190,  191,  192,  189,  193,  177,  194,
-      196,  197,  198,  180,  181,  199,  200,  201,  202,  203,
-      204,  182,  183,  205,  206,  207,  184,  185,  186,  187,
-      188,  189,  190,  191,  192,  189,  193,  208,  194,  196,
-      197,  198,  209,  210,  199,  200,  201,  202,  203,  204,
-      211,  212,  205,  206,  207,  214,  215,  216,  217,  218,
-      211,  220,  222,  223,  224,  225,  208,  226,  227,  228,
-
-      229,  209,  210,  230,  231,  232,  234,  236,  237,  211,
-      212,  238,  239,  240,  214,  215,  216,  217,  218,  211,
-      220,  222,  223,  224,  225,  241,  226,  227,  228,  229,
-      242,  243,  230,  231,  232,  234,  236,  237,  244,  245,
-      238,  239,  240,  246,  247,  248,  249,  253,  247,  254,
-      255,  256,  257,  258,  241,  260,  261,  262,  263,  242,
-      243,  265,  266,  267,  268,  269,  270,  244,  245,  271,
-      272,  273,  246,  247,  248,  249,  253,  247,  254,  255,
-      256,  257,  258,  274,  260,  261,  262,  263,  277,  278,
-      265,  266,  267,  268,  269,  270,  279,  280,  271,  272,
-
-      273,  281,  282,  283,  286,  288,  289,  290,  291,  292,
-      298,  300,  274,  301,  302,  303,  304,  277,  278,  305,
-      292,  307,  309,  310,  311,  279,  280,  312,  313,  314,
-      281,  282,  283,  286,  288,  289,  290,  291,  292,  298,
-      300,  315,  301,  302,  303,  304,  317,  319,  305,  292,
-      307,  309,  310,  311,  320,  321,  312,  313,  314,  322,
-      323,  324,  326,  328,  332,  333,  334,  336,  335,  337,
-      315,  335,  339,  340,  341,  317,  319,  342,  343,  344,
-      345,  346,  347,  320,  321,  348,  349,  350,  322,  323,
-      324,  326,  328,  332,  333,  334,  336,  335,  337,  351,
-
-      335,  339,  340,  341,  352,  353,  342,  343,  344,  345,
-      346,  347,  357,  359,  348,  349,  350,  362,  363,  364,
-      369,  370,  371,  373,  374,  376,  377,  378,  351,  380,
-      381,  382,  383,  352,  353,  385,  386,  388,  389,  390,
-      392,  357,  359,  393,  394,  395,  362,  363,  364,  369,
-      370,  371,  373,  374,  376,  377,  378,  397,  380,  381,
-      382,  383,  399,  400,  385,  386,  388,  389,  390,  392,
-      401,  402,  393,  394,  395,  404,  405,  406,  410,  411,
-      414,  415,  416,  417,  418,  419,  397,  421,  423,  424,
-      425,  399,  400,  429,  430,  431,  433,  434,  435,  401,
-
-      402,  436,  437,  439,  404,  405,  406,  410,  411,  414,
-      415,  416,  417,  418,  419,  442,  421,  423,  424,  425,
-      443,  444,  429,  430,  431,  433,  434,  435,  445,  449,
-      436,  437,  439,  450,  453,  454,  455,  456,  457,  459,
-      460,  461,  462,  463,  442,  464,  465,  467,  468,  443,
-      444,  470,  472,  473,  474,  476,  477,  445,  449,  478,
-      480,  481,  450,  453,  454,  455,  456,  457,  459,  460,
-      461,  462,  463,  482,  464,  465,  467,  468,  484,  486,
-      470,  472,  473,  474,  476,  477,  487,  488,  478,  480,
-      481,  489,  490,  492,  494,  495,  496,  499,  502,  503,
-
-      504,  507,  482,  508,  510,  511,  512,  484,  486,  513,
-      514,  516,    0,    0,    0,  487,  488,    0,    0,    0,
-      489,  490,  492,  494,  495,  496,  499,  502,  503,  504,
-      507,    0,  508,  510,  511,  512,    0,    0,  513,  514,
-      516,  520,  520,  520,  520,  520,  520,  520,  520,  520,
-      520,  521,  521,  521,  521,  521,  521,  521,  521,  521,
-      521,  522,  522,  522,  522,  522,  522,  522,  522,  522,
-      522,  523,  523,  523,  523,  523,  523,  523,  523,  523,
-      523,  524,  524,  524,  524,  524,  524,  524,  524,  524,
-      524,  525,  525,  526,  526,  526,    0,  526,  527,  527,
-
-      527,  527,  528,  528,  528,    0,  528,  528,  528,  528,
-      528,  528,  529,  529,  529,    0,  529,  529,  529,  529,
-        0,  529,  530,  530,  530,  530,  530,  530,  530,  530,
-      530,  530,  531,  531,    0,  531,  531,  531,  531,  531,
-      531,  531,  532,    0,  532,  532,  532,  532,  532,  532,
-      532,  532,  533,  533,  534,  534,  519,  519,  519,  519,
-      519,  519,  519,  519,  519,  519,  519,  519,  519,  519,
-      519,  519,  519,  519,  519,  519,  519,  519,  519,  519,
-      519,  519,  519,  519,  519,  519,  519,  519,  519,  519,
-      519,  519,  519,  519,  519,  519,  519,  519,  519,  519,
-
-      519,  519,  519,  519,  519,  519,  519,  519,  519,  519,
-      519,  519,  519,  519,  519,  519,  519,  519,  519,  519,
-      519,  519,  519,  519,  519,  519,  519,  519
+      143,  144,  145,  146,  179,  180,  143,  171,  173,  174,
+      175,  176,  181,  182,  166,  178,  177,  183,  184,  185,
+      186,  187,  188,  189,  190,  191,  192,  189,  177,  193,
+      194,  196,  197,  179,  180,  198,  199,  200,  201,  202,
+      203,  181,  182,  204,  205,  206,  183,  184,  185,  186,
+      187,  188,  189,  190,  191,  192,  189,  207,  193,  194,
+      196,  197,  208,  209,  198,  199,  200,  201,  202,  203,
+      210,  211,  204,  205,  206,  212,  214,  215,  216,  217,
+      218,  211,  220,  222,  223,  224,  207,  225,  226,  227,
+
+      228,  208,  209,  229,  230,  231,  232,  234,  236,  210,
+      211,  237,  238,  239,  212,  214,  215,  216,  217,  218,
+      211,  220,  222,  223,  224,  240,  225,  226,  227,  228,
+      241,  242,  229,  230,  231,  232,  234,  236,  243,  244,
+      237,  238,  239,  245,  246,  247,  248,  249,  253,  247,
+      254,  255,  256,  257,  240,  258,  259,  261,  262,  241,
+      242,  263,  264,  266,  267,  268,  269,  243,  244,  270,
+      271,  272,  245,  246,  247,  248,  249,  253,  247,  254,
+      255,  256,  257,  273,  258,  259,  261,  262,  274,  275,
+      263,  264,  266,  267,  268,  269,  278,  279,  270,  271,
+
+      272,  280,  281,  282,  283,  284,  287,  289,  290,  291,
+      292,  293,  273,  299,  301,  302,  303,  274,  275,  304,
+      305,  306,  293,  308,  310,  278,  279,  311,  312,  313,
+      280,  281,  282,  283,  284,  287,  289,  290,  291,  292,
+      293,  314,  299,  301,  302,  303,  315,  316,  304,  305,
+      306,  293,  308,  310,  318,  320,  311,  312,  313,  321,
+      322,  323,  324,  325,  327,  329,  333,  334,  335,  336,
+      314,  337,  338,  339,  337,  315,  316,  341,  342,  343,
+      344,  345,  346,  318,  320,  347,  348,  349,  321,  322,
+      323,  324,  325,  327,  329,  333,  334,  335,  336,  350,
+
+      337,  338,  339,  337,  351,  352,  341,  342,  343,  344,
+      345,  346,  353,  354,  347,  348,  349,  355,  359,  361,
+      364,  365,  366,  371,  372,  373,  375,  376,  350,  378,
+      379,  380,  382,  351,  352,  383,  384,  385,  387,  388,
+      390,  353,  354,  391,  392,  394,  355,  359,  361,  364,
+      365,  366,  371,  372,  373,  375,  376,  395,  378,  379,
+      380,  382,  396,  397,  383,  384,  385,  387,  388,  390,
+      398,  400,  391,  392,  394,  402,  403,  404,  405,  407,
+      408,  409,  413,  414,  417,  418,  395,  419,  420,  421,
+      422,  396,  397,  424,  426,  427,  428,  432,  433,  398,
+
+      400,  434,  436,  437,  402,  403,  404,  405,  407,  408,
+      409,  413,  414,  417,  418,  438,  419,  420,  421,  422,
+      439,  440,  424,  426,  427,  428,  432,  433,  441,  443,
+      434,  436,  437,  446,  447,  448,  449,  453,  454,  457,
+      458,  459,  460,  461,  438,  463,  464,  465,  466,  439,
+      440,  467,  468,  469,  470,  472,  473,  441,  443,  475,
+      477,  478,  446,  447,  448,  449,  453,  454,  457,  458,
+      459,  460,  461,  479,  463,  464,  465,  466,  481,  482,
+      467,  468,  469,  470,  472,  473,  483,  485,  475,  477,
+      478,  486,  487,  488,  490,  492,  493,  494,  495,  496,
+
+      498,  501,  479,  502,  503,  506,  509,  481,  482,  510,
+      511,  514,  515,  517,  518,  483,  485,  519,  520,  521,
+      486,  487,  488,  490,  492,  493,  494,  495,  496,  498,
+      501,  523,  502,  503,  506,  509,    0,    0,  510,  511,
+      514,  515,  517,  518,    0,    0,  519,  520,  521,    0,
+        0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
+      523,  527,  527,  527,  527,  527,  527,  527,  527,  527,
+      527,  528,  528,  528,  528,  528,  528,  528,  528,  528,
+      528,  529,  529,  529,  529,  529,  529,  529,  529,  529,
+      529,  530,  530,  530,  530,  530,  530,  530,  530,  530,
+
+      530,  531,  531,  531,  531,  531,  531,  531,  531,  531,
+      531,  532,  532,  533,  533,  533,    0,  533,  534,  534,
+      534,  534,  535,  535,  535,    0,  535,  535,  535,  535,
+      535,  535,  536,  536,  536,    0,  536,  536,  536,  536,
+        0,  536,  537,  537,  537,  537,  537,  537,  537,  537,
+      537,  537,  538,  538,    0,  538,  538,  538,  538,  538,
+      538,  538,  539,    0,  539,  539,  539,  539,  539,  539,
+      539,  539,  540,  540,  541,  541,  526,  526,  526,  526,
+      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
+      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
+
+      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
+      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
+      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
+      526,  526,  526,  526,  526,  526,  526,  526,  526,  526,
+      526,  526,  526,  526,  526,  526,  526,  526
     } ;
 
 /* Table of booleans, true if rule could match eol. */
-static yyconst flex_int32_t yy_rule_can_match_eol[144] =
+static yyconst flex_int32_t yy_rule_can_match_eol[145] =
     {   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 +915,8 @@ static yyconst flex_int32_t yy_rule_can_match_eol[144] =
     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, 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, 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.
@@ -1025,7 +1032,7 @@ class UnaryOperation;
 
 
 
-#line 1029 "SqlLexer_gen.cpp"
+#line 1036 "SqlLexer_gen.cpp"
 
 #define INITIAL 0
 #define CONDITION_SQL 1
@@ -1316,7 +1323,7 @@ YY_DECL
 #line 127 "../SqlLexer.lpp"
 
 
-#line 1320 "SqlLexer_gen.cpp"
+#line 1327 "SqlLexer_gen.cpp"
 
 	while ( /*CONSTCOND*/1 )		/* loops until end-of-file is reached */
 		{
@@ -1343,13 +1350,13 @@ yy_match:
 			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 				{
 				yy_current_state = (int) yy_def[yy_current_state];
-				if ( yy_current_state >= 520 )
+				if ( yy_current_state >= 527 )
 					yy_c = yy_meta[(unsigned int) yy_c];
 				}
 			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
 			++yy_cp;
 			}
-		while ( yy_current_state != 519 );
+		while ( yy_current_state != 526 );
 		yy_cp = yyg->yy_last_accepting_cpos;
 		yy_current_state = yyg->yy_last_accepting_state;
 
@@ -1488,37 +1495,37 @@ return TOKEN_BIT;
 case 16:
 YY_RULE_SETUP
 #line 177 "../SqlLexer.lpp"
-return TOKEN_BLOCKPROPERTIES;
+return TOKEN_BITWEAVING;
 	YY_BREAK
 case 17:
 YY_RULE_SETUP
 #line 178 "../SqlLexer.lpp"
-return TOKEN_BLOCKSAMPLE;
+return TOKEN_BLOCKPROPERTIES;
 	YY_BREAK
 case 18:
 YY_RULE_SETUP
 #line 179 "../SqlLexer.lpp"
-return TOKEN_BLOOM_FILTER;
+return TOKEN_BLOCKSAMPLE;
 	YY_BREAK
 case 19:
 YY_RULE_SETUP
 #line 180 "../SqlLexer.lpp"
-return TOKEN_CASE;
+return TOKEN_BLOOM_FILTER;
 	YY_BREAK
 case 20:
 YY_RULE_SETUP
 #line 181 "../SqlLexer.lpp"
-return TOKEN_CSB_TREE;
+return TOKEN_CASE;
 	YY_BREAK
 case 21:
 YY_RULE_SETUP
 #line 182 "../SqlLexer.lpp"
-return TOKEN_BY;
+return TOKEN_CSB_TREE;
 	YY_BREAK
 case 22:
 YY_RULE_SETUP
 #line 183 "../SqlLexer.lpp"
-return TOKEN_CHARACTER;
+return TOKEN_BY;
 	YY_BREAK
 case 23:
 YY_RULE_SETUP
@@ -1528,62 +1535,62 @@ return TOKEN_CHARACTER;
 case 24:
 YY_RULE_SETUP
 #line 185 "../SqlLexer.lpp"
-return TOKEN_CHECK;
+return TOKEN_CHARACTER;
 	YY_BREAK
 case 25:
 YY_RULE_SETUP
 #line 186 "../SqlLexer.lpp"
-return TOKEN_COLUMN;
+return TOKEN_CHECK;
 	YY_BREAK
 case 26:
 YY_RULE_SETUP
 #line 187 "../SqlLexer.lpp"
-return TOKEN_CONSTRAINT;
+return TOKEN_COLUMN;
 	YY_BREAK
 case 27:
 YY_RULE_SETUP
 #line 188 "../SqlLexer.lpp"
-return TOKEN_COPY;
+return TOKEN_CONSTRAINT;
 	YY_BREAK
 case 28:
 YY_RULE_SETUP
 #line 189 "../SqlLexer.lpp"
-return TOKEN_CREATE;
+return TOKEN_COPY;
 	YY_BREAK
 case 29:
 YY_RULE_SETUP
 #line 190 "../SqlLexer.lpp"
-return TOKEN_DATE;
+return TOKEN_CREATE;
 	YY_BREAK
 case 30:
 YY_RULE_SETUP
 #line 191 "../SqlLexer.lpp"
-return TOKEN_DATETIME;
+return TOKEN_DATE;
 	YY_BREAK
 case 31:
 YY_RULE_SETUP
 #line 192 "../SqlLexer.lpp"
-return TOKEN_DECIMAL;
+return TOKEN_DATETIME;
 	YY_BREAK
 case 32:
 YY_RULE_SETUP
 #line 193 "../SqlLexer.lpp"
-return TOKEN_DEFAULT;
+return TOKEN_DECIMAL;
 	YY_BREAK
 case 33:
 YY_RULE_SETUP
 #line 194 "../SqlLexer.lpp"
-return TOKEN_DELETE;
+return TOKEN_DEFAULT;
 	YY_BREAK
 case 34:
 YY_RULE_SETUP
 #line 195 "../SqlLexer.lpp"
-return TOKEN_DELIMITER;
+return TOKEN_DELETE;
 	YY_BREAK
 case 35:
 YY_RULE_SETUP
 #line 196 "../SqlLexer.lpp"
-return TOKEN_DESC;
+return TOKEN_DELIMITER;
 	YY_BREAK
 case 36:
 YY_RULE_SETUP
@@ -1593,112 +1600,112 @@ return TOKEN_DESC;
 case 37:
 YY_RULE_SETUP
 #line 198 "../SqlLexer.lpp"
-return TOKEN_DISTINCT;
+return TOKEN_DESC;
 	YY_BREAK
 case 38:
 YY_RULE_SETUP
 #line 199 "../SqlLexer.lpp"
-return TOKEN_DOUBLE;
+return TOKEN_DISTINCT;
 	YY_BREAK
 case 39:
 YY_RULE_SETUP
 #line 200 "../SqlLexer.lpp"
-return TOKEN_DROP;
+return TOKEN_DOUBLE;
 	YY_BREAK
 case 40:
 YY_RULE_SETUP
 #line 201 "../SqlLexer.lpp"
-return TOKEN_ELSE;
+return TOKEN_DROP;
 	YY_BREAK
 case 41:
 YY_RULE_SETUP
 #line 202 "../SqlLexer.lpp"
-return TOKEN_END;
+return TOKEN_ELSE;
 	YY_BREAK
 case 42:
 YY_RULE_SETUP
 #line 203 "../SqlLexer.lpp"
-return TOKEN_ESCAPE_STRINGS;
+return TOKEN_END;
 	YY_BREAK
 case 43:
 YY_RULE_SETUP
 #line 204 "../SqlLexer.lpp"
-return TOKEN_EXISTS;
+return TOKEN_ESCAPE_STRINGS;
 	YY_BREAK
 case 44:
 YY_RULE_SETUP
 #line 205 "../SqlLexer.lpp"
-return TOKEN_EXTRACT;
+return TOKEN_EXISTS;
 	YY_BREAK
 case 45:
 YY_RULE_SETUP
 #line 206 "../SqlLexer.lpp"
-return TOKEN_FALSE;
+return TOKEN_EXTRACT;
 	YY_BREAK
 case 46:
 YY_RULE_SETUP
 #line 207 "../SqlLexer.lpp"
-return TOKEN_FIRST;
+return TOKEN_FALSE;
 	YY_BREAK
 case 47:
 YY_RULE_SETUP
 #line 208 "../SqlLexer.lpp"
-return TOKEN_FLOAT;
+return TOKEN_FIRST;
 	YY_BREAK
 case 48:
 YY_RULE_SETUP
 #line 209 "../SqlLexer.lpp"
-return TOKEN_FOREIGN;
+return TOKEN_FLOAT;
 	YY_BREAK
 case 49:
 YY_RULE_SETUP
 #line 210 "../SqlLexer.lpp"
-return TOKEN_FROM;
+return TOKEN_FOREIGN;
 	YY_BREAK
 case 50:
 YY_RULE_SETUP
 #line 211 "../SqlLexer.lpp"
-return TOKEN_FULL;
+return TOKEN_FROM;
 	YY_BREAK
 case 51:
 YY_RULE_SETUP
 #line 212 "../SqlLexer.lpp"
-return TOKEN_GROUP;
+return TOKEN_FULL;
 	YY_BREAK
 case 52:
 YY_RULE_SETUP
 #line 213 "../SqlLexer.lpp"
-return TOKEN_HASH;
+return TOKEN_GROUP;
 	YY_BREAK
 case 53:
 YY_RULE_SETUP
 #line 214 "../SqlLexer.lpp"
-return TOKEN_HAVING;
+return TOKEN_HASH;
 	YY_BREAK
 case 54:
 YY_RULE_SETUP
 #line 215 "../SqlLexer.lpp"
-return TOKEN_IN;
+return TOKEN_HAVING;
 	YY_BREAK
 case 55:
 YY_RULE_SETUP
 #line 216 "../SqlLexer.lpp"
-return TOKEN_INDEX;
+return TOKEN_IN;
 	YY_BREAK
 case 56:
 YY_RULE_SETUP
 #line 217 "../SqlLexer.lpp"
-return TOKEN_INNER;
+return TOKEN_INDEX;
 	YY_BREAK
 case 57:
 YY_RULE_SETUP
 #line 218 "../SqlLexer.lpp"
-return TOKEN_INSERT;
+return TOKEN_INNER;
 	YY_BREAK
 case 58:
 YY_RULE_SETUP
 #line 219 "../SqlLexer.lpp"
-return TOKEN_INTEGER;
+return TOKEN_INSERT;
 	YY_BREAK
 case 59:
 YY_RULE_SETUP
@@ -1708,252 +1715,252 @@ return TOKEN_INTEGER;
 case 60:
 YY_RULE_SETUP
 #line 221 "../SqlLexer.lpp"
-return TOKEN_INTERVAL;
+return TOKEN_INTEGER;
 	YY_BREAK
 case 61:
 YY_RULE_SETUP
 #line 222 "../SqlLexer.lpp"
-return TOKEN_INTO;
+return TOKEN_INTERVAL;
 	YY_BREAK
 case 62:
 YY_RULE_SETUP
 #line 223 "../SqlLexer.lpp"
-return TOKEN_IS;
+return TOKEN_INTO;
 	YY_BREAK
 case 63:
 YY_RULE_SETUP
 #line 224 "../SqlLexer.lpp"
-return TOKEN_JOIN;
+return TOKEN_IS;
 	YY_BREAK
 case 64:
 YY_RULE_SETUP
 #line 225 "../SqlLexer.lpp"
-return TOKEN_KEY;
+return TOKEN_JOIN;
 	YY_BREAK
 case 65:
 YY_RULE_SETUP
 #line 226 "../SqlLexer.lpp"
-return TOKEN_LAST;
+return TOKEN_KEY;
 	YY_BREAK
 case 66:
 YY_RULE_SETUP
 #line 227 "../SqlLexer.lpp"
-return TOKEN_LEFT;
+return TOKEN_LAST;
 	YY_BREAK
 case 67:
 YY_RULE_SETUP
 #line 228 "../SqlLexer.lpp"
-return TOKEN_LIKE;
+return TOKEN_LEFT;
 	YY_BREAK
 case 68:
 YY_RULE_SETUP
 #line 229 "../SqlLexer.lpp"
-return TOKEN_LIMIT;
+return TOKEN_LIKE;
 	YY_BREAK
 case 69:
 YY_RULE_SETUP
 #line 230 "../SqlLexer.lpp"
-return TOKEN_LONG;
+return TOKEN_LIMIT;
 	YY_BREAK
 case 70:
 YY_RULE_SETUP
 #line 231 "../SqlLexer.lpp"
-return TOKEN_NOT;
+return TOKEN_LONG;
 	YY_BREAK
 case 71:
 YY_RULE_SETUP
 #line 232 "../SqlLexer.lpp"
-return TOKEN_NULL;
+return TOKEN_NOT;
 	YY_BREAK
 case 72:
 YY_RULE_SETUP
 #line 233 "../SqlLexer.lpp"
-return TOKEN_NULLS;
+return TOKEN_NULL;
 	YY_BREAK
 case 73:
 YY_RULE_SETUP
 #line 234 "../SqlLexer.lpp"
-return TOKEN_OFF;
+return TOKEN_NULLS;
 	YY_BREAK
 case 74:
 YY_RULE_SETUP
 #line 235 "../SqlLexer.lpp"
-return TOKEN_ON;
+return TOKEN_OFF;
 	YY_BREAK
 case 75:
 YY_RULE_SETUP
 #line 236 "../SqlLexer.lpp"
-return TOKEN_OR;
+return TOKEN_ON;
 	YY_BREAK
 case 76:
 YY_RULE_SETUP
 #line 237 "../SqlLexer.lpp"
-return TOKEN_ORDER;
+return TOKEN_OR;
 	YY_BREAK
 case 77:
 YY_RULE_SETUP
 #line 238 "../SqlLexer.lpp"
-return TOKEN_OUTER;
+return TOKEN_ORDER;
 	YY_BREAK
 case 78:
 YY_RULE_SETUP
 #line 239 "../SqlLexer.lpp"
-return TOKEN_PARTITION;
+return TOKEN_OUTER;
 	YY_BREAK
 case 79:
 YY_RULE_SETUP
 #line 240 "../SqlLexer.lpp"
-return TOKEN_PARTITIONS;
+return TOKEN_PARTITION;
 	YY_BREAK
 case 80:
 YY_RULE_SETUP
 #line 241 "../SqlLexer.lpp"
-return TOKEN_PERCENT;
+return TOKEN_PARTITIONS;
 	YY_BREAK
 case 81:
 YY_RULE_SETUP
 #line 242 "../SqlLexer.lpp"
-return TOKEN_PRIMARY;
+return TOKEN_PERCENT;
 	YY_BREAK
 case 82:
 YY_RULE_SETUP
 #line 243 "../SqlLexer.lpp"
-return TOKEN_QUIT;
+return TOKEN_PRIMARY;
 	YY_BREAK
 case 83:
 YY_RULE_SETUP
 #line 244 "../SqlLexer.lpp"
-return TOKEN_RANGE;
+return TOKEN_QUIT;
 	YY_BREAK
 case 84:
 YY_RULE_SETUP
 #line 245 "../SqlLexer.lpp"
-return TOKEN_REAL;
+return TOKEN_RANGE;
 	YY_BREAK
 case 85:
 YY_RULE_SETUP
 #line 246 "../SqlLexer.lpp"
-return TOKEN_REFERENCES;
+return TOKEN_REAL;
 	YY_BREAK
 case 86:
 YY_RULE_SETUP
 #line 247 "../SqlLexer.lpp"
-return TOKEN_REGEXP;
+return TOKEN_REFERENCES;
 	YY_BREAK
 case 87:
 YY_RULE_SETUP
 #line 248 "../SqlLexer.lpp"
-return TOKEN_RIGHT;
+return TOKEN_REGEXP;
 	YY_BREAK
 case 88:
 YY_RULE_SETUP
 #line 249 "../SqlLexer.lpp"
-return TOKEN_ROW_DELIMITER;
+return TOKEN_RIGHT;
 	YY_BREAK
 case 89:
 YY_RULE_SETUP
 #line 250 "../SqlLexer.lpp"
-return TOKEN_SELECT;
+return TOKEN_ROW_DELIMITER;
 	YY_BREAK
 case 90:
 YY_RULE_SETUP
 #line 251 "../SqlLexer.lpp"
-return TOKEN_SET;
+return TOKEN_SELECT;
 	YY_BREAK
 case 91:
 YY_RULE_SETUP
 #line 252 "../SqlLexer.lpp"
-return TOKEN_SMA;
+return TOKEN_SET;
 	YY_BREAK
 case 92:
 YY_RULE_SETUP
 #line 253 "../SqlLexer.lpp"
-return TOKEN_SMALLINT;
+return TOKEN_SMA;
 	YY_BREAK
 case 93:
 YY_RULE_SETUP
 #line 254 "../SqlLexer.lpp"
-return TOKEN_TABLE;
+return TOKEN_SMALLINT;
 	YY_BREAK
 case 94:
 YY_RULE_SETUP
 #line 255 "../SqlLexer.lpp"
-return TOKEN_THEN;
+return TOKEN_TABLE;
 	YY_BREAK
 case 95:
 YY_RULE_SETUP
 #line 256 "../SqlLexer.lpp"
-return TOKEN_TIME;
+return TOKEN_THEN;
 	YY_BREAK
 case 96:
 YY_RULE_SETUP
 #line 257 "../SqlLexer.lpp"
-return TOKEN_TIMESTAMP;
+return TOKEN_TIME;
 	YY_BREAK
 case 97:
 YY_RULE_SETUP
 #line 258 "../SqlLexer.lpp"
-return TOKEN_TRUE;
+return TOKEN_TIMESTAMP;
 	YY_BREAK
 case 98:
 YY_RULE_SETUP
 #line 259 "../SqlLexer.lpp"
-return TOKEN_TUPLESAMPLE;
+return TOKEN_TRUE;
 	YY_BREAK
 case 99:
 YY_RULE_SETUP
 #line 260 "../SqlLexer.lpp"
-return TOKEN_UNIQUE;
+return TOKEN_TUPLESAMPLE;
 	YY_BREAK
 case 100:
 YY_RULE_SETUP
 #line 261 "../SqlLexer.lpp"
-return TOKEN_UPDATE;
+return TOKEN_UNIQUE;
 	YY_BREAK
 case 101:
 YY_RULE_SETUP
 #line 262 "../SqlLexer.lpp"
-return TOKEN_USING;
+return TOKEN_UPDATE;
 	YY_BREAK
 case 102:
 YY_RULE_SETUP
 #line 263 "../SqlLexer.lpp"
-return TOKEN_VALUES;
+return TOKEN_USING;
 	YY_BREAK
 case 103:
 YY_RULE_SETUP
 #line 264 "../SqlLexer.lpp"
-return TOKEN_VARCHAR;
+return TOKEN_VALUES;
 	YY_BREAK
 case 104:
 YY_RULE_SETUP
 #line 265 "../SqlLexer.lpp"
-return TOKEN_WHEN;
+return TOKEN_VARCHAR;
 	YY_BREAK
 case 105:
 YY_RULE_SETUP
 #line 266 "../SqlLexer.lpp"
-return TOKEN_WHERE;
+return TOKEN_WHEN;
 	YY_BREAK
 case 106:
 YY_RULE_SETUP
 #line 267 "../SqlLexer.lpp"
-return TOKEN_WITH;
+return TOKEN_WHERE;
 	YY_BREAK
 case 107:
 YY_RULE_SETUP
 #line 268 "../SqlLexer.lpp"
-return TOKEN_YEARMONTH;
+return TOKEN_WITH;
 	YY_BREAK
 case 108:
 YY_RULE_SETUP
-#line 270 "../SqlLexer.lpp"
-return TOKEN_EQ;
+#line 269 "../SqlLexer.lpp"
+return TOKEN_YEARMONTH;
 	YY_BREAK
 case 109:
 YY_RULE_SETUP
 #line 271 "../SqlLexer.lpp"
-return TOKEN_NEQ;
+return TOKEN_EQ;
 	YY_BREAK
 case 110:
 YY_RULE_SETUP
@@ -1963,56 +1970,61 @@ return TOKEN_NEQ;
 case 111:
 YY_RULE_SETUP
 #line 273 "../SqlLexer.lpp"
-return TOKEN_LT;
+return TOKEN_NEQ;
 	YY_BREAK
 case 112:
 YY_RULE_SETUP
 #line 274 "../SqlLexer.lpp"
-return TOKEN_GT;
+return TOKEN_LT;
 	YY_BREAK
 case 113:
 YY_RULE_SETUP
 #line 275 "../SqlLexer.lpp"
-return TOKEN_LEQ;
+return TOKEN_GT;
 	YY_BREAK
 case 114:
 YY_RULE_SETUP
 #line 276 "../SqlLexer.lpp"
-return TOKEN_GEQ;
+return TOKEN_LEQ;
 	YY_BREAK
 case 115:
 YY_RULE_SETUP
-#line 278 "../SqlLexer.lpp"
-return yytext[0];
+#line 277 "../SqlLexer.lpp"
+return TOKEN_GEQ;
 	YY_BREAK
 case 116:
 YY_RULE_SETUP
 #line 279 "../SqlLexer.lpp"
 return yytext[0];
 	YY_BREAK
+case 117:
+YY_RULE_SETUP
+#line 280 "../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 117:
+case 118:
 YY_RULE_SETUP
-#line 285 "../SqlLexer.lpp"
+#line 286 "../SqlLexer.lpp"
 {
     yylval->string_value_ = new quickstep::ParseString(yylloc->first_line, yylloc->first_column);
     BEGIN(CONDITION_STRING_SINGLE_QUOTED_ESCAPED);
   }
 	YY_BREAK
-case 118:
+case 119:
 YY_RULE_SETUP
-#line 290 "../SqlLexer.lpp"
+#line 291 "../SqlLexer.lpp"
 {
     yylval->string_value_ = new quickstep::ParseString(yylloc->first_line, yylloc->first_column);
     BEGIN(CONDITION_STRING_SINGLE_QUOTED);
   }
 	YY_BREAK
-case 119:
+case 120:
 YY_RULE_SETUP
-#line 295 "../SqlLexer.lpp"
+#line 296 "../SqlLexer.lpp"
 {
     yylval->string_value_ = new quickstep::ParseString(yylloc->first_line, yylloc->first_column);
     BEGIN(CONDITION_STRING_DOUBLE_QUOTED);
@@ -2024,7 +2036,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 304 "../SqlLexer.lpp"
+#line 305 "../SqlLexer.lpp"
 {
     delete yylval->string_value_;
     BEGIN(INITIAL);
@@ -2035,9 +2047,9 @@ case YY_STATE_EOF(CONDITION_STRING_DOUBLE_QUOTED):
 
 /* Process escape sequences. */
 
-case 120:
+case 121:
 YY_RULE_SETUP
-#line 314 "../SqlLexer.lpp"
+#line 315 "../SqlLexer.lpp"
 {
     /* Octal code */
     unsigned int code;
@@ -2051,9 +2063,9 @@ YY_RULE_SETUP
     yylval->string_value_->push_back(code);
   }
 	YY_BREAK
-case 121:
+case 122:
 YY_RULE_SETUP
-#line 326 "../SqlLexer.lpp"
+#line 327 "../SqlLexer.lpp"
 {
     /* Hexadecimal code */
     unsigned int code;
@@ -2061,9 +2073,9 @@ YY_RULE_SETUP
     yylval->string_value_->push_back(code);
   }
 	YY_BREAK
-case 122:
+case 123:
 YY_RULE_SETUP
-#line 332 "../SqlLexer.lpp"
+#line 333 "../SqlLexer.lpp"
 {
     /* A numeric escape sequence that isn't correctly specified. */
     delete yylval->string_value_;
@@ -2072,58 +2084,58 @@ YY_RULE_SETUP
     return TOKEN_LEX_ERROR;
   }
 	YY_BREAK
-case 123:
+case 124:
 YY_RULE_SETUP
-#line 339 "../SqlLexer.lpp"
+#line 340 "../SqlLexer.lpp"
 {
     /* Backspace */
     yylval->string_value_->push_back('\b');
   }
 	YY_BREAK
-case 124:
+case 125:
 YY_RULE_SETUP
-#line 343 "../SqlLexer.lpp"
+#line 344 "../SqlLexer.lpp"
 {
     /* Form-feed */
     yylval->string_value_->push_back('\f');
   }
 	YY_BREAK
-case 125:
+case 126:
 YY_RULE_SETUP
-#line 347 "../SqlLexer.lpp"
+#line 348 "../SqlLexer.lpp"
 {
     /* Newline */
     yylval->string_value_->push_back('\n');
   }
 	YY_BREAK
-case 126:
+case 127:
 YY_RULE_SETUP
-#line 351 "../SqlLexer.lpp"
+#line 352 "../SqlLexer.lpp"
 {
     /* Carriage-return */
     yylval->string_value_->push_back('\r');
   }
 	YY_BREAK
-case 127:
+case 128:
 YY_RULE_SETUP
-#line 355 "../SqlLexer.lpp"
+#line 356 "../SqlLexer.lpp"
 {
     /* Horizontal Tab */
     yylval->string_value_->push_back('\t');
   }
 	YY_BREAK
-case 128:
-/* rule 128 can match eol */
+case 129:
+/* rule 129 can match eol */
 YY_RULE_SETUP
-#line 359 "../SqlLexer.lpp"
+#line 360 "../SqlLexer.lpp"
 {
     /* Any other character (including actual newline or carriage return) */
     yylval->string_value_->push_back(yytext[1]);
   }
 	YY_BREAK
-case 129:
+case 130:
 YY_RULE_SETUP
-#line 363 "../SqlLexer.lpp"
+#line 364 "../SqlLexer.lpp"
 {
     /* This should only be encountered right before an EOF. */
     delete yylval->string_value_;
@@ -2134,17 +2146,17 @@ YY_RULE_SETUP
 	YY_BREAK
 
 
-case 130:
+case 131:
 YY_RULE_SETUP
-#line 373 "../SqlLexer.lpp"
+#line 374 "../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 131:
+case 132:
 YY_RULE_SETUP
-#line 377 "../SqlLexer.lpp"
+#line 378 "../SqlLexer.lpp"
 {
     /* End string */
     BEGIN(CONDITION_SQL);
@@ -2153,17 +2165,17 @@ YY_RULE_SETUP
 	YY_BREAK
 
 
-case 132:
+case 133:
 YY_RULE_SETUP
-#line 385 "../SqlLexer.lpp"
+#line 386 "../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 133:
+case 134:
 YY_RULE_SETUP
-#line 389 "../SqlLexer.lpp"
+#line 390 "../SqlLexer.lpp"
 {
     /* End string */
     BEGIN(CONDITION_SQL);
@@ -2171,94 +2183,94 @@ YY_RULE_SETUP
   }
 	YY_BREAK
 
-case 134:
-/* rule 134 can match eol */
+case 135:
+/* rule 135 can match eol */
 YY_RULE_SETUP
-#line 396 "../SqlLexer.lpp"
+#line 397 "../SqlLexer.lpp"
 {
   /* Scan up to a quote. */
   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 401 "../SqlLexer.lpp"
+#line 402 "../SqlLexer.lpp"
 {
   /* Scan up to a quote or escape sequence. */
   yylval->string_value_->append(yytext, yyleng);
 }
 	YY_BREAK
-case 136:
-/* rule 136 can match eol */
+case 137:
+/* rule 137 can match eol */
 YY_RULE_SETUP
-#line 406 "../SqlLexer.lpp"
+#line 407 "../SqlLexer.lpp"
 {
   /* Scan up to a quote. */
   yylval->string_value_->append(yytext, yyleng);
 }
 	YY_BREAK
 
-case 137:
+case 138:
 YY_RULE_SETUP
-#line 412 "../SqlLexer.lpp"
+#line 413 "../SqlLexer.lpp"
 {
     yylval->string_value_ = new quickstep::ParseString(
         yylloc->first_line, yylloc->first_column, std::string(yytext, yyleng));
     return TOKEN_NAME;
   }
 	YY_BREAK
-case 138:
+case 139:
 YY_RULE_SETUP
-#line 418 "../SqlLexer.lpp"
+#line 419 "../SqlLexer.lpp"
 {
     yylval->numeric_literal_value_ = new quickstep::NumericParseLiteralValue(
         yylloc->first_line, yylloc->first_column, yytext);
     return TOKEN_UNSIGNED_NUMVAL;
   }
 	YY_BREAK
-case 139:
+case 140:
 YY_RULE_SETUP
-#line 424 "../SqlLexer.lpp"
+#line 425 "../SqlLexer.lpp"
 /* comment */
 	YY_BREAK
-case 140:
-/* rule 140 can match eol */
+case 141:
+/* rule 141 can match eol */
 YY_RULE_SETUP
-#line 426 "../SqlLexer.lpp"
+#line 427 "../SqlLexer.lpp"
 { yycolumn = 0; }
 	YY_BREAK
-case 141:
+case 142:
 YY_RULE_SETUP
-#line 428 "../SqlLexer.lpp"
+#line 429 "../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 432 "../SqlLexer.lpp"
+#line 433 "../SqlLexer.lpp"
 {
   /* All conditions except for mutli-state string extracting conditions. */
   BEGIN(INITIAL);
   return TOKEN_EOF;
 }
 	YY_BREAK
-case 142:
+case 143:
 YY_RULE_SETUP
-#line 438 "../SqlLexer.lpp"
+#line 439 "../SqlLexer.lpp"
 {
   BEGIN(INITIAL);
   quickstep_yyerror(NULL, yyscanner, NULL, "illegal character");
   return TOKEN_LEX_ERROR;
 }
 	YY_BREAK
-case 143:
+case 144:
 YY_RULE_SETUP
-#line 444 "../SqlLexer.lpp"
+#line 445 "../SqlLexer.lpp"
 YY_FATAL_ERROR( "flex scanner jammed" );
 	YY_BREAK
-#line 2262 "SqlLexer_gen.cpp"
+#line 2274 "SqlLexer_gen.cpp"
 
 	case YY_END_OF_BUFFER:
 		{
@@ -2552,7 +2564,7 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 			{
 			yy_current_state = (int) yy_def[yy_current_state];
-			if ( yy_current_state >= 520 )
+			if ( yy_current_state >= 527 )
 				yy_c = yy_meta[(unsigned int) yy_c];
 			}
 		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
@@ -2581,11 +2593,11 @@ static int yy_get_next_buffer (yyscan_t yyscanner)
 	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
 		{
 		yy_current_state = (int) yy_def[yy_current_state];
-		if ( yy_current_state >= 520 )
+		if ( yy_current_state >= 527 )
 			yy_c = yy_meta[(unsigned int) yy_c];
 		}
 	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
-	yy_is_jam = (yy_current_state == 519);
+	yy_is_jam = (yy_current_state == 526);
 
 	(void)yyg;
 	return yy_is_jam ? 0 : yy_current_state;
@@ -3419,7 +3431,7 @@ void quickstep_yyfree (void * ptr , yyscan_t yyscanner)
 
 #define YYTABLES_NAME "yytables"
 
-#line 444 "../SqlLexer.lpp"
+#line 445 "../SqlLexer.lpp"
 
 
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/cbd169e5/parser/preprocessed/SqlLexer_gen.hpp
----------------------------------------------------------------------
diff --git a/parser/preprocessed/SqlLexer_gen.hpp b/parser/preprocessed/SqlLexer_gen.hpp
index 39d4cc0..de44998 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 444 "../SqlLexer.lpp"
+#line 445 "../SqlLexer.lpp"
 
 
 #line 367 "SqlLexer_gen.hpp"


[13/24] incubator-quickstep git commit: Adds support for IN predicate (#167)

Posted by zu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/parser/preprocessed/SqlParser_gen.cpp
----------------------------------------------------------------------
diff --git a/parser/preprocessed/SqlParser_gen.cpp b/parser/preprocessed/SqlParser_gen.cpp
index fd050a9..0937d33 100644
--- a/parser/preprocessed/SqlParser_gen.cpp
+++ b/parser/preprocessed/SqlParser_gen.cpp
@@ -1,8 +1,8 @@
-/* A Bison parser, made by GNU Bison 3.0.2.  */
+/* A Bison parser, made by GNU Bison 3.0.4.  */
 
 /* Bison implementation for Yacc-like parsers in C
 
-   Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
+   Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -44,7 +44,7 @@
 #define YYBISON 1
 
 /* Bison version.  */
-#define YYBISON_VERSION "3.0.2"
+#define YYBISON_VERSION "3.0.4"
 
 /* Skeleton name.  */
 #define YYSKELETON_NAME "yacc.c"
@@ -119,6 +119,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"
@@ -148,7 +149,7 @@ typedef struct YYLTYPE {
 // Needed for Bison 2.6 and higher, which do not automatically provide this typedef.
 typedef void* yyscan_t;
 
-#line 152 "SqlParser_gen.cpp" /* yacc.c:339  */
+#line 153 "SqlParser_gen.cpp" /* yacc.c:339  */
 
 # ifndef YY_NULLPTR
 #  if defined __cplusplus && 201103L <= __cplusplus
@@ -246,64 +247,65 @@ extern int quickstep_yydebug;
     TOKEN_GROUP = 318,
     TOKEN_HASH = 319,
     TOKEN_HAVING = 320,
-    TOKEN_INDEX = 321,
-    TOKEN_INNER = 322,
-    TOKEN_INSERT = 323,
-    TOKEN_INTEGER = 324,
-    TOKEN_INTERVAL = 325,
-    TOKEN_INTO = 326,
-    TOKEN_JOIN = 327,
-    TOKEN_KEY = 328,
-    TOKEN_LAST = 329,
-    TOKEN_LEFT = 330,
-    TOKEN_LIMIT = 331,
-    TOKEN_LONG = 332,
-    TOKEN_NULL = 333,
-    TOKEN_NULLS = 334,
-    TOKEN_OFF = 335,
-    TOKEN_ON = 336,
-    TOKEN_ORDER = 337,
-    TOKEN_OUTER = 338,
-    TOKEN_PARTITION = 339,
-    TOKEN_PARTITIONS = 340,
-    TOKEN_PERCENT = 341,
-    TOKEN_PRIMARY = 342,
-    TOKEN_QUIT = 343,
-    TOKEN_RANGE = 344,
-    TOKEN_REAL = 345,
-    TOKEN_REFERENCES = 346,
-    TOKEN_RIGHT = 347,
-    TOKEN_ROW_DELIMITER = 348,
-    TOKEN_SELECT = 349,
-    TOKEN_SET = 350,
-    TOKEN_SMA = 351,
-    TOKEN_SMALLINT = 352,
-    TOKEN_TABLE = 353,
-    TOKEN_THEN = 354,
-    TOKEN_TIME = 355,
-    TOKEN_TIMESTAMP = 356,
-    TOKEN_TRUE = 357,
-    TOKEN_TUPLESAMPLE = 358,
-    TOKEN_UNIQUE = 359,
-    TOKEN_UPDATE = 360,
-    TOKEN_USING = 361,
-    TOKEN_VALUES = 362,
-    TOKEN_VARCHAR = 363,
-    TOKEN_WHEN = 364,
-    TOKEN_WHERE = 365,
-    TOKEN_WITH = 366,
-    TOKEN_YEARMONTH = 367,
-    TOKEN_EOF = 368,
-    TOKEN_LEX_ERROR = 369
+    TOKEN_IN = 321,
+    TOKEN_INDEX = 322,
+    TOKEN_INNER = 323,
+    TOKEN_INSERT = 324,
+    TOKEN_INTEGER = 325,
+    TOKEN_INTERVAL = 326,
+    TOKEN_INTO = 327,
+    TOKEN_JOIN = 328,
+    TOKEN_KEY = 329,
+    TOKEN_LAST = 330,
+    TOKEN_LEFT = 331,
+    TOKEN_LIMIT = 332,
+    TOKEN_LONG = 333,
+    TOKEN_NULL = 334,
+    TOKEN_NULLS = 335,
+    TOKEN_OFF = 336,
+    TOKEN_ON = 337,
+    TOKEN_ORDER = 338,
+    TOKEN_OUTER = 339,
+    TOKEN_PARTITION = 340,
+    TOKEN_PARTITIONS = 341,
+    TOKEN_PERCENT = 342,
+    TOKEN_PRIMARY = 343,
+    TOKEN_QUIT = 344,
+    TOKEN_RANGE = 345,
+    TOKEN_REAL = 346,
+    TOKEN_REFERENCES = 347,
+    TOKEN_RIGHT = 348,
+    TOKEN_ROW_DELIMITER = 349,
+    TOKEN_SELECT = 350,
+    TOKEN_SET = 351,
+    TOKEN_SMA = 352,
+    TOKEN_SMALLINT = 353,
+    TOKEN_TABLE = 354,
+    TOKEN_THEN = 355,
+    TOKEN_TIME = 356,
+    TOKEN_TIMESTAMP = 357,
+    TOKEN_TRUE = 358,
+    TOKEN_TUPLESAMPLE = 359,
+    TOKEN_UNIQUE = 360,
+    TOKEN_UPDATE = 361,
+    TOKEN_USING = 362,
+    TOKEN_VALUES = 363,
+    TOKEN_VARCHAR = 364,
+    TOKEN_WHEN = 365,
+    TOKEN_WHERE = 366,
+    TOKEN_WITH = 367,
+    TOKEN_YEARMONTH = 368,
+    TOKEN_EOF = 369,
+    TOKEN_LEX_ERROR = 370
   };
 #endif
 
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-typedef union YYSTYPE YYSTYPE;
+
 union YYSTYPE
 {
-#line 116 "../SqlParser.ypp" /* yacc.c:355  */
+#line 117 "../SqlParser.ypp" /* yacc.c:355  */
 
   quickstep::ParseString *string_value_;
 
@@ -393,8 +395,10 @@ union YYSTYPE
   quickstep::PtrVector<quickstep::ParseSubqueryTableReference> *with_list_;
   quickstep::ParseSubqueryTableReference *with_list_element_;
 
-#line 397 "SqlParser_gen.cpp" /* yacc.c:355  */
+#line 399 "SqlParser_gen.cpp" /* yacc.c:355  */
 };
+
+typedef union YYSTYPE YYSTYPE;
 # define YYSTYPE_IS_TRIVIAL 1
 # define YYSTYPE_IS_DECLARED 1
 #endif
@@ -420,13 +424,13 @@ int quickstep_yyparse (yyscan_t yyscanner, quickstep::ParseStatement **parsedSta
 #endif /* !YY_QUICKSTEP_YY_SQLPARSER_GEN_HPP_INCLUDED  */
 
 /* Copy the second part of user declarations.  */
-#line 206 "../SqlParser.ypp" /* yacc.c:358  */
+#line 207 "../SqlParser.ypp" /* yacc.c:358  */
 
 /* This header needs YYSTYPE, which is defined by the %union directive above */
 #include "SqlLexer_gen.hpp"
 void NotSupported(const YYLTYPE *location, yyscan_t yyscanner, const std::string &feature);
 
-#line 430 "SqlParser_gen.cpp" /* yacc.c:358  */
+#line 434 "SqlParser_gen.cpp" /* yacc.c:358  */
 
 #ifdef short
 # undef short
@@ -670,21 +674,21 @@ union yyalloc
 /* YYFINAL -- State number of the termination state.  */
 #define YYFINAL  47
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   1038
+#define YYLAST   1093
 
 /* YYNTOKENS -- Number of terminals.  */
-#define YYNTOKENS  126
+#define YYNTOKENS  127
 /* YYNNTS -- Number of nonterminals.  */
 #define YYNNTS  95
 /* YYNRULES -- Number of rules.  */
-#define YYNRULES  250
+#define YYNRULES  254
 /* YYNSTATES -- Number of states.  */
-#define YYNSTATES  486
+#define YYNSTATES  496
 
 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
    by yylex, with out-of-bounds checking.  */
 #define YYUNDEFTOK  2
-#define YYMAXUTOK   369
+#define YYMAXUTOK   370
 
 #define YYTRANSLATE(YYX)                                                \
   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -694,11 +698,11 @@ union yyalloc
 static const yytype_uint8 yytranslate[] =
 {
        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     121,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+     122,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,   125,     2,     2,
-     122,   123,    23,    21,   124,    22,    27,    24,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,   120,
+       2,     2,     2,     2,     2,     2,     2,   126,     2,     2,
+     123,   124,    23,    21,   125,    22,    27,    24,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,   121,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
@@ -729,39 +733,40 @@ static const yytype_uint8 yytranslate[] =
       80,    81,    82,    83,    84,    85,    86,    87,    88,    89,
       90,    91,    92,    93,    94,    95,    96,    97,    98,    99,
      100,   101,   102,   103,   104,   105,   106,   107,   108,   109,
-     110,   111,   112,   113,   114,   115,   116,   117,   118,   119
+     110,   111,   112,   113,   114,   115,   116,   117,   118,   119,
+     120
 };
 
 #if YYDEBUG
   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
 static const yytype_uint16 yyrline[] =
 {
-       0,   567,   567,   571,   575,   579,   583,   586,   593,   596,
-     599,   602,   605,   608,   611,   614,   617,   620,   626,   632,
-     639,   645,   652,   661,   666,   675,   680,   685,   689,   695,
-     700,   703,   706,   711,   714,   717,   720,   723,   726,   729,
-     732,   735,   738,   750,   753,   756,   774,   794,   797,   800,
-     805,   810,   816,   822,   831,   835,   841,   844,   849,   854,
-     859,   866,   873,   877,   883,   886,   891,   894,   899,   902,
-     907,   910,   929,   933,   939,   943,   949,   952,   955,   960,
-     963,   970,   975,   986,   990,   994,  1000,  1003,  1009,  1017,
-    1020,  1023,  1029,  1034,  1037,  1042,  1046,  1050,  1054,  1060,
-    1065,  1070,  1074,  1080,  1086,  1089,  1094,  1099,  1103,  1109,
-    1115,  1121,  1124,  1128,  1134,  1137,  1142,  1146,  1152,  1155,
-    1158,  1163,  1168,  1171,  1177,  1181,  1187,  1193,  1199,  1205,
-    1211,  1217,  1223,  1229,  1237,  1242,  1245,  1248,  1253,  1257,
-    1261,  1264,  1268,  1273,  1276,  1281,  1284,  1289,  1293,  1299,
-    1302,  1307,  1310,  1315,  1318,  1323,  1326,  1345,  1349,  1355,
-    1362,  1365,  1368,  1373,  1376,  1379,  1385,  1388,  1393,  1398,
-    1407,  1412,  1421,  1426,  1429,  1434,  1437,  1442,  1448,  1454,
-    1457,  1460,  1468,  1471,  1476,  1479,  1484,  1487,  1492,  1495,
-    1498,  1501,  1504,  1507,  1512,  1516,  1520,  1523,  1528,  1533,
-    1536,  1541,  1545,  1551,  1556,  1560,  1566,  1571,  1574,  1579,
-    1583,  1589,  1592,  1595,  1598,  1610,  1614,  1633,  1648,  1652,
-    1658,  1661,  1666,  1670,  1677,  1680,  1683,  1686,  1689,  1692,
-    1695,  1698,  1701,  1704,  1709,  1720,  1723,  1728,  1731,  1734,
-    1740,  1744,  1750,  1753,  1761,  1764,  1767,  1770,  1776,  1781,
-    1786
+       0,   569,   569,   573,   577,   581,   585,   588,   595,   598,
+     601,   604,   607,   610,   613,   616,   619,   622,   628,   634,
+     641,   647,   654,   663,   668,   677,   682,   687,   691,   697,
+     702,   705,   708,   713,   716,   719,   722,   725,   728,   731,
+     734,   737,   740,   752,   755,   758,   776,   796,   799,   802,
+     807,   812,   818,   824,   833,   837,   843,   846,   851,   856,
+     861,   868,   875,   879,   885,   888,   893,   896,   901,   904,
+     909,   912,   931,   935,   941,   945,   951,   954,   957,   962,
+     965,   972,   977,   988,   992,   996,  1002,  1005,  1011,  1019,
+    1022,  1025,  1031,  1036,  1039,  1044,  1048,  1052,  1056,  1062,
+    1067,  1072,  1076,  1082,  1088,  1091,  1096,  1101,  1105,  1111,
+    1117,  1123,  1126,  1130,  1136,  1139,  1144,  1148,  1154,  1157,
+    1160,  1165,  1170,  1173,  1179,  1183,  1189,  1195,  1201,  1207,
+    1213,  1219,  1225,  1231,  1239,  1244,  1247,  1250,  1255,  1259,
+    1263,  1266,  1270,  1275,  1278,  1283,  1286,  1291,  1295,  1301,
+    1304,  1309,  1312,  1317,  1320,  1325,  1328,  1347,  1351,  1357,
+    1364,  1367,  1370,  1375,  1378,  1381,  1387,  1390,  1395,  1400,
+    1409,  1414,  1423,  1428,  1431,  1436,  1439,  1444,  1450,  1456,
+    1459,  1462,  1465,  1468,  1471,  1477,  1486,  1489,  1494,  1497,
+    1502,  1505,  1510,  1513,  1516,  1519,  1522,  1525,  1530,  1534,
+    1538,  1541,  1546,  1551,  1554,  1559,  1563,  1569,  1574,  1578,
+    1584,  1589,  1592,  1597,  1601,  1607,  1610,  1613,  1616,  1628,
+    1632,  1651,  1666,  1670,  1676,  1679,  1684,  1688,  1695,  1698,
+    1701,  1704,  1707,  1710,  1713,  1716,  1719,  1722,  1727,  1738,
+    1741,  1746,  1749,  1752,  1758,  1762,  1768,  1771,  1779,  1782,
+    1785,  1788,  1794,  1799,  1804
 };
 #endif
 
@@ -786,7 +791,7 @@ static const char *const yytname[] =
   "TOKEN_DROP", "TOKEN_ELSE", "TOKEN_END", "TOKEN_ESCAPE_STRINGS",
   "TOKEN_EXISTS", "TOKEN_EXTRACT", "TOKEN_FALSE", "TOKEN_FIRST",
   "TOKEN_FLOAT", "TOKEN_FOREIGN", "TOKEN_FROM", "TOKEN_FULL",
-  "TOKEN_GROUP", "TOKEN_HASH", "TOKEN_HAVING", "TOKEN_INDEX",
+  "TOKEN_GROUP", "TOKEN_HASH", "TOKEN_HAVING", "TOKEN_IN", "TOKEN_INDEX",
   "TOKEN_INNER", "TOKEN_INSERT", "TOKEN_INTEGER", "TOKEN_INTERVAL",
   "TOKEN_INTO", "TOKEN_JOIN", "TOKEN_KEY", "TOKEN_LAST", "TOKEN_LEFT",
   "TOKEN_LIMIT", "TOKEN_LONG", "TOKEN_NULL", "TOKEN_NULLS", "TOKEN_OFF",
@@ -850,14 +855,14 @@ static const yytype_uint16 yytoknum[] =
      340,   341,   342,   343,   344,   345,   346,   347,   348,   349,
      350,   351,   352,   353,   354,   355,   356,   357,   358,   359,
      360,   361,   362,   363,   364,   365,   366,   367,   368,   369,
-      59,    10,    40,    41,    44,    37
+     370,    59,    10,    40,    41,    44,    37
 };
 # endif
 
-#define YYPACT_NINF -223
+#define YYPACT_NINF -222
 
 #define yypact_value_is_default(Yystate) \
-  (!!((Yystate) == (-223)))
+  (!!((Yystate) == (-222)))
 
 #define YYTABLE_NINF -1
 
@@ -868,55 +873,56 @@ static const yytype_uint16 yytoknum[] =
      STATE-NUM.  */
 static const yytype_int16 yypact[] =
 {
-     367,  -223,  -223,   -29,   233,    -6,    18,    34,    35,  -223,
-     138,   233,   233,  -223,    94,   132,  -223,  -223,  -223,  -223,
-    -223,  -223,  -223,  -223,  -223,  -223,   -20,  -223,   111,   165,
-     233,  -223,  -223,    98,   233,   233,   233,   233,   233,  -223,
-    -223,   564,    72,    52,  -223,   185,   103,  -223,  -223,  -223,
-     118,  -223,  -223,  -223,  -223,    68,   231,   167,   125,   142,
-    -223,    76,  -223,  -223,   256,   260,  -223,  -223,  -223,   627,
-     139,  -223,   213,  -223,  -223,   160,  -223,  -223,   287,  -223,
-    -223,  -223,  -223,  -223,  -223,   179,   228,   753,   300,   241,
-     187,  -223,   234,    33,  -223,  -223,  -223,  -223,  -223,  -223,
-    -223,   816,   -16,   233,   233,   204,   233,   233,   199,   237,
-     205,   233,   233,   501,  -223,  -223,   206,   233,  -223,  -223,
-    -223,   501,    49,   -28,  -223,   302,  -223,   233,  -223,   329,
-    -223,    30,  -223,    17,   142,   753,  -223,  -223,   233,   753,
-    -223,  -223,  -223,  -223,   753,   260,  -223,   233,   415,    81,
-    -223,   330,  -223,   248,  -223,   153,  -223,   248,   233,    27,
-     233,   233,   226,  -223,   245,  -223,   161,   908,   690,   204,
-     501,   342,   344,  -223,  -223,  1016,   335,   879,   163,    16,
-     753,    -2,  -223,   753,  -223,   299,   246,   305,   249,  -223,
-      56,  -223,   102,    56,   -18,   306,  -223,  -223,    33,  -223,
-    -223,   250,   753,  -223,   269,   171,   233,  -223,   753,   252,
-    -223,   233,  -223,  -223,   255,   301,   303,   261,  -223,  -223,
-    -223,   121,   233,   267,    27,   233,  -223,    26,  -223,  -223,
-       7,    28,   501,   501,   254,  -223,  -223,  -223,  -223,  -223,
-    -223,  -223,  -223,   753,   753,    15,  -223,   173,   272,   753,
-      51,  -223,   327,   269,  -223,  -223,   753,  -223,   233,  -223,
-    -223,   -13,   309,   233,     5,   113,    17,  -223,   147,  -223,
-    -223,   381,   382,    56,   351,   321,  -223,   175,  -223,   753,
-    -223,   269,  -223,  -223,   501,   270,   271,   233,   389,    99,
-     189,  -223,   191,   368,    43,  -223,   275,   284,  -223,   318,
-     280,   879,  -223,   326,   233,  -223,  -223,    26,  -223,  -223,
-     344,  -223,  -223,  -223,   753,   224,   269,   322,  -223,  -223,
-     879,   285,   269,   753,  -223,    37,  -223,   233,   331,   233,
-     -19,   233,   332,   233,   333,  -223,  -223,   315,   320,  -223,
-     753,   501,   328,  -223,   269,     8,   233,   233,   193,  -223,
-    -223,  -223,  -223,  -223,  -223,  -223,   141,  -223,   233,  -223,
-    -223,  -223,   292,    27,   390,   337,  -223,   501,  -223,  -223,
-     294,  -223,   257,   753,  -223,  -223,   879,   269,  -223,    -8,
-     233,    -3,   501,    24,   233,    54,   233,  -223,  -223,   293,
-     342,   385,   348,  -223,   207,   210,  -223,   425,    99,  -223,
-     233,  -223,  -223,   310,   392,  -223,     9,   233,   753,   269,
-     216,   501,    59,   501,   342,   501,    79,   501,    80,   753,
-     426,  -223,   338,  -223,  -223,  -223,   221,  -223,  -223,  -223,
-    -223,     6,   233,   101,  -223,   312,   269,  -223,   342,   501,
-     342,   342,   501,   342,   501,   317,  -223,   188,  -223,   233,
-    -223,   233,  -223,  -223,   233,  -223,   235,  -223,  -223,   324,
-    -223,   342,   342,   342,   753,  -223,  -223,   355,   336,  -223,
-     238,  -223,   233,  -223,    22,  -223,   233,  -223,   240,  -223,
-    -223,   242,   352,  -223,   437,  -223
+     139,  -222,  -222,   -64,   168,    17,    40,   -27,     6,  -222,
+      25,   168,   168,  -222,   176,   116,  -222,  -222,  -222,  -222,
+    -222,  -222,  -222,  -222,  -222,  -222,    -6,  -222,   154,   179,
+     168,  -222,  -222,   122,   168,   168,   168,   168,   168,  -222,
+    -222,   576,    95,   118,  -222,   210,    88,  -222,  -222,  -222,
+     190,  -222,  -222,  -222,  -222,   145,   252,   184,   142,   162,
+    -222,    97,  -222,  -222,   276,   278,  -222,  -222,  -222,   640,
+     164,  -222,   222,  -222,  -222,   177,  -222,  -222,   291,  -222,
+    -222,  -222,  -222,  -222,  -222,   193,   235,   832,   335,   290,
+     236,  -222,   268,    37,  -222,  -222,  -222,  -222,  -222,  -222,
+    -222,   896,   -12,   168,   168,   242,   168,   168,   249,   251,
+     250,   168,   168,   512,  -222,  -222,   246,   168,  -222,  -222,
+    -222,   512,     3,   -20,  -222,   364,  -222,   168,  -222,   366,
+    -222,    36,  -222,    12,   162,   832,  -222,  -222,   168,   832,
+    -222,  -222,  -222,  -222,   832,   278,  -222,   168,   425,   111,
+    -222,   369,  -222,   275,  -222,   178,  -222,   275,   168,   105,
+     168,   168,   263,  -222,   265,  -222,   180,   975,   704,   242,
+     512,   374,   381,  -222,  -222,   405,   371,   942,   182,    14,
+     832,   -18,  -222,   832,  -222,   334,   269,   328,   272,  -222,
+     188,  -222,   136,   188,   -19,   329,  -222,  -222,    37,  -222,
+    -222,   277,   832,  -222,   288,   189,   168,  -222,   832,   280,
+    -222,   168,  -222,  -222,   279,   320,   326,   283,  -222,  -222,
+    -222,   170,   168,   295,   105,   168,  -222,    31,  -222,  -222,
+       2,    34,   512,   512,   133,  -222,  -222,  -222,  -222,  -222,
+    -222,  -222,  -222,   832,   285,   832,    33,  -222,   194,   296,
+     832,    50,  -222,   353,   288,  -222,  -222,   832,  -222,   168,
+    -222,  -222,    86,   336,   168,   173,   186,    12,  -222,   171,
+    -222,  -222,   406,   421,   188,   394,   365,  -222,   196,  -222,
+     832,  -222,   288,  -222,  -222,   512,   311,   315,   168,   434,
+      23,   198,  -222,   201,   413,   -10,  -222,   316,   325,  -222,
+     359,   321,   942,  -222,   370,   168,  -222,  -222,    31,  -222,
+    -222,   381,  -222,  -222,  -222,   832,   322,   203,   768,  -222,
+     288,   367,  -222,  -222,   942,   327,   288,   832,  -222,    41,
+    -222,   168,   375,   168,   -45,   168,   376,   168,   378,  -222,
+    -222,   360,   372,  -222,   832,   512,   373,  -222,   288,    13,
+     168,   168,   212,  -222,  -222,  -222,  -222,  -222,  -222,  -222,
+     207,  -222,   168,  -222,  -222,  -222,   339,   105,   428,   377,
+    -222,   512,  -222,  -222,   345,  -222,   259,   768,  -222,   832,
+     214,  -222,  -222,   942,   288,  -222,   -13,   168,    -5,   512,
+       0,   168,    11,   168,  -222,  -222,   344,   374,   431,   393,
+    -222,   218,   220,  -222,   472,    23,  -222,   168,  -222,  -222,
+     358,   444,  -222,    15,   168,   832,   224,   288,  -222,   226,
+     512,    46,   512,   374,   512,    66,   512,    75,   832,   477,
+    -222,   388,  -222,  -222,  -222,   228,  -222,  -222,  -222,  -222,
+       7,   168,    92,  -222,   363,   288,  -222,  -222,   374,   512,
+     374,   374,   512,   374,   512,   368,  -222,    43,  -222,   168,
+    -222,   168,  -222,  -222,   168,  -222,   230,  -222,  -222,   379,
+    -222,   374,   374,   374,   832,  -222,  -222,   403,   380,  -222,
+     239,  -222,   168,  -222,   143,  -222,   168,  -222,   254,  -222,
+    -222,   260,   399,  -222,   484,  -222
 };
 
   /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
@@ -924,50 +930,51 @@ static const yytype_int16 yypact[] =
      means the default is an error.  */
 static const yytype_uint8 yydefact[] =
 {
-       0,     6,   250,     0,     0,     0,     0,     0,     0,    18,
+       0,     6,   254,     0,     0,     0,     0,     0,     0,    18,
      111,     0,     0,     7,     0,     0,    15,     8,    10,    11,
-      13,    14,     9,    17,    12,    16,     0,   104,     0,   248,
-       0,   242,   243,     0,     0,     0,     0,     0,     0,   112,
+      13,    14,     9,    17,    12,    16,     0,   104,     0,   252,
+       0,   246,   247,     0,     0,     0,     0,     0,     0,   112,
      113,     0,     0,   106,   107,     0,   145,     1,     3,     2,
-       0,   105,     5,     4,   249,     0,     0,     0,     0,   166,
-      25,     0,   215,   212,     0,   234,   114,    40,    29,     0,
+       0,   105,     5,     4,   253,     0,     0,     0,     0,   166,
+      25,     0,   219,   216,     0,   238,   114,    40,    29,     0,
        0,    30,    31,    34,    36,     0,    37,    39,     0,    41,
-     211,    35,    38,    32,    33,     0,     0,     0,     0,     0,
-     115,   116,   120,   183,   185,   187,   190,   191,   192,   189,
-     188,     0,   220,     0,     0,     0,     0,     0,     0,     0,
-      93,     0,     0,     0,   100,   167,     0,     0,    90,   213,
-     214,     0,     0,   207,   204,     0,    43,     0,   216,     0,
-      44,     0,   217,     0,   166,     0,   235,   236,     0,     0,
-     119,   238,   239,   237,     0,     0,   186,     0,     0,   166,
-     102,     0,   108,     0,   109,     0,   240,     0,     0,     0,
+     215,    35,    38,    32,    33,     0,     0,     0,     0,     0,
+     115,   116,   120,   187,   189,   191,   194,   195,   196,   193,
+     192,     0,   224,     0,     0,     0,     0,     0,     0,     0,
+      93,     0,     0,     0,   100,   167,     0,     0,    90,   217,
+     218,     0,     0,   211,   208,     0,    43,     0,   220,     0,
+      44,     0,   221,     0,   166,     0,   239,   240,     0,     0,
+     119,   242,   243,   241,     0,     0,   190,     0,     0,   166,
+     102,     0,   108,     0,   109,     0,   244,     0,     0,     0,
        0,     0,     0,    92,    66,    27,     0,     0,     0,     0,
-       0,   168,   170,   172,   174,     0,   188,     0,     0,     0,
-       0,   207,   201,     0,   205,     0,     0,     0,     0,   193,
-       0,   147,   122,   142,   135,   149,   117,   118,   182,   184,
-     221,     0,     0,   194,   209,     0,     0,    99,     0,     0,
+       0,   168,   170,   172,   174,     0,   192,     0,     0,     0,
+       0,   211,   205,     0,   209,     0,     0,     0,     0,   197,
+       0,   147,   122,   142,   135,   149,   117,   118,   186,   188,
+     225,     0,     0,   198,   213,     0,     0,    99,     0,     0,
      146,     0,    91,    19,     0,     0,     0,     0,    20,    21,
       22,     0,     0,     0,    64,     0,    42,    56,   173,   181,
-       0,     0,     0,     0,     0,   224,   226,   227,   228,   229,
-     225,   230,   232,     0,     0,     0,   218,     0,     0,     0,
-       0,   202,     0,   208,   200,    45,     0,    46,     0,   138,
-     143,     0,     0,     0,     0,     0,     0,   121,   123,   125,
-     141,     0,     0,   140,     0,   151,   195,     0,   196,     0,
-     101,   103,   134,   241,     0,     0,     0,     0,     0,     0,
-       0,   222,     0,   220,     0,    63,    65,    68,    28,     0,
-       0,     0,    47,     0,     0,    49,    55,    57,    26,   180,
-     169,   171,   231,   233,     0,     0,   179,     0,   178,    89,
-       0,     0,   206,     0,   199,     0,   144,     0,     0,     0,
-       0,     0,     0,     0,     0,   148,   124,     0,     0,   139,
-       0,     0,   153,   197,   210,     0,     0,     0,     0,    95,
-     246,   247,   245,   244,    96,    94,     0,    67,     0,    83,
-      84,    85,    86,     0,     0,    70,    48,     0,    51,    50,
-       0,    54,     0,     0,   177,   219,     0,   203,   198,     0,
-       0,     0,     0,     0,     0,     0,     0,   136,   137,   150,
-     152,     0,   155,    61,     0,     0,    58,     0,     0,   223,
-       0,    24,    62,     0,     0,    23,     0,     0,     0,   175,
-       0,     0,     0,     0,   127,     0,     0,     0,     0,     0,
-       0,   110,     0,    59,    97,    98,     0,    74,    76,    77,
-      78,     0,     0,     0,    52,     0,   176,    88,   133,     0,
+       0,     0,     0,     0,     0,   228,   230,   231,   232,   233,
+     229,   234,   236,     0,     0,     0,     0,   222,     0,     0,
+       0,     0,   206,     0,   212,   204,    45,     0,    46,     0,
+     138,   143,     0,     0,     0,     0,     0,     0,   121,   123,
+     125,   141,     0,     0,   140,     0,   151,   199,     0,   200,
+       0,   101,   103,   134,   245,     0,     0,     0,     0,     0,
+       0,     0,   226,     0,   224,     0,    63,    65,    68,    28,
+       0,     0,     0,    47,     0,     0,    49,    55,    57,    26,
+     180,   169,   171,   235,   237,     0,     0,     0,     0,   182,
+     179,     0,   178,    89,     0,     0,   210,     0,   203,     0,
+     144,     0,     0,     0,     0,     0,     0,     0,     0,   148,
+     124,     0,     0,   139,     0,     0,   153,   201,   214,     0,
+       0,     0,     0,    95,   250,   251,   249,   248,    96,    94,
+       0,    67,     0,    83,    84,    85,    86,     0,     0,    70,
+      48,     0,    51,    50,     0,    54,     0,     0,   184,     0,
+       0,   177,   223,     0,   207,   202,     0,     0,     0,     0,
+       0,     0,     0,     0,   136,   137,   150,   152,     0,   155,
+      61,     0,     0,    58,     0,     0,   227,     0,    24,    62,
+       0,     0,    23,     0,     0,     0,     0,   175,   183,     0,
+       0,     0,     0,   127,     0,     0,     0,     0,     0,     0,
+     110,     0,    59,    97,    98,     0,    74,    76,    77,    78,
+       0,     0,     0,    52,     0,   176,   185,    88,   133,     0,
      126,   129,     0,   131,     0,   154,   157,   160,   156,     0,
       87,     0,    82,    80,     0,    79,     0,    72,    73,     0,
       53,   132,   128,   130,     0,   161,   162,   163,     0,    75,
@@ -978,31 +985,31 @@ static const yytype_uint8 yydefact[] =
   /* YYPGOTO[NTERM-NUM].  */
 static const yytype_int16 yypgoto[] =
 {
-    -223,  -223,  -223,  -223,  -223,  -223,  -223,  -223,  -136,  -223,
-     286,   144,  -223,  -223,  -222,  -223,  -223,  -223,  -223,  -223,
-    -223,    20,     3,  -223,  -223,  -223,  -223,  -223,  -223,  -223,
-    -223,  -223,  -223,  -223,  -223,   251,  -223,  -223,  -223,   357,
-      -7,  -223,  -223,  -223,   339,  -223,  -223,  -223,   197,   -78,
-    -223,   201,  -156,    -9,  -223,  -223,  -223,  -223,  -223,  -223,
-      -5,  -223,  -223,    63,  -223,   -93,   239,   247,   307,   -21,
-     334,   340,   377,  -128,  -223,  -223,  -223,   311,  -223,   358,
-     313,  -198,  -168,   106,  -107,  -223,  -223,  -223,  -223,  -223,
-    -116,    -4,    88,  -223,  -223
+    -222,  -222,  -222,  -222,  -222,  -222,  -222,  -222,  -139,  -222,
+     330,   187,  -222,  -222,  -221,  -222,  -222,  -222,  -222,  -222,
+    -222,    51,    35,  -222,  -222,  -222,  -222,  -222,  -222,  -222,
+    -222,  -222,  -222,  -222,  -222,   292,  -222,  -222,  -222,   390,
+       9,  -222,  -222,  -222,   385,  -222,  -222,  -222,   237,  -100,
+    -222,   232,  -173,   -11,  -222,  -222,  -222,  -222,  -222,  -222,
+      30,  -222,  -222,   -58,  -222,   -92,   273,   274,   342,    -3,
+     384,   382,   410,  -129,  -222,  -222,  -222,   331,  -222,   391,
+     332,  -196,  -175,   132,   -54,  -222,  -222,  -222,  -222,  -222,
+    -105,    -4,   119,  -222,  -222
 };
 
   /* YYDEFGOTO[NTERM-NUM].  */
 static const yytype_int16 yydefgoto[] =
 {
       -1,    14,    15,    16,    17,    18,    19,    20,   165,   166,
-      88,   306,   307,   308,   218,   296,   297,   223,   365,   405,
-     459,   426,   427,   428,   429,   430,   362,   401,    21,    22,
-     163,   290,    23,    24,   149,   150,    25,    26,    43,    44,
-      27,    41,    89,    90,    91,   134,   267,   268,   269,   190,
-     273,   191,   259,   260,   192,   275,   342,   392,   421,   445,
-     446,   467,   475,   114,   115,   171,   172,   173,   174,   175,
+      88,   307,   308,   309,   218,   297,   298,   223,   369,   412,
+     469,   435,   436,   437,   438,   439,   366,   408,    21,    22,
+     163,   291,    23,    24,   149,   150,    25,    26,    43,    44,
+     209,    41,    89,    90,    91,   134,   268,   269,   270,   190,
+     274,   191,   260,   261,   192,   276,   346,   399,   430,   455,
+     456,   477,   485,   114,   115,   171,   172,   173,   174,   175,
       93,    94,    95,    96,    97,    98,   181,   182,   123,   124,
-     185,   205,    99,   247,   100,   292,   244,   101,   139,   144,
-     155,   102,   354,    28,    29
+     185,   205,    99,   248,   100,   293,   245,   101,   139,   144,
+     155,   102,   358,    28,    29
 };
 
   /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
@@ -1010,304 +1017,317 @@ static const yytype_int16 yydefgoto[] =
      number is the opposite.  If YYTABLE_NINF, syntax error.  */
 static const yytype_uint16 yytable[] =
 {
-      33,   178,   295,    45,   277,   193,   176,    42,    46,   246,
-      31,   147,    32,   452,   176,   232,   232,   232,   271,    51,
-      92,    31,   213,    32,   232,   317,    55,   154,   179,   183,
-      57,    58,    59,    60,    61,   453,   299,   270,   234,   235,
-     236,   237,   238,   239,   240,   241,   242,   243,   122,   136,
-     137,   136,   137,    50,   118,   183,   141,   142,   136,   137,
-      31,   176,    32,   176,   327,    34,   131,   382,   300,   214,
-     136,   137,   136,   137,    30,   328,   301,   230,   411,    10,
-     359,   360,   331,   413,    36,   479,   121,   258,   140,   298,
-     272,   229,   215,   332,    47,    45,   108,    35,   318,   151,
-      46,   480,   156,   157,   148,   211,   148,   164,   167,   302,
-     415,    38,   180,   156,    92,   291,   211,   339,   303,   216,
-     249,   211,   304,   187,   109,   176,   176,   204,   454,   194,
-     309,   393,   434,   368,   197,   305,   217,    37,   193,   153,
-     417,   402,   389,   200,   361,   439,   209,   330,   211,   231,
-     212,   189,   375,   189,   167,   323,   219,   220,   143,   250,
-     378,   350,   253,   180,    56,   442,   444,    39,    54,   261,
-     457,   348,   103,   288,   262,    10,   104,   176,   211,   263,
-     289,   204,   264,   211,   351,   352,    46,   281,   116,    46,
-     333,   345,    40,   397,   107,   458,   113,   195,   117,   265,
-     398,   334,   151,   211,   211,   206,   353,   283,   246,   136,
-     137,   379,   207,   381,   261,   383,   105,   385,   293,   262,
-     465,   167,   315,   316,   263,   106,   266,   264,   322,    52,
-     394,   395,    53,   373,   176,   325,   110,    31,    31,    32,
-      32,   466,   158,   159,   265,   136,   137,   112,   390,   326,
-      48,   399,    49,   111,    46,   136,   137,   113,   344,   156,
-     176,   125,   194,   119,   412,   138,   408,   120,   416,    46,
-     418,   312,   313,   314,   406,   176,   210,   211,   136,   137,
-     160,   161,   127,   156,   224,   225,   248,   211,   126,   414,
-     136,   137,   128,   372,   278,   279,   319,   320,   343,   279,
-     370,   129,   377,   130,   176,   132,   176,   133,   176,   186,
-     176,   135,   355,   356,   357,   358,   396,   211,   438,   204,
-     440,   162,   441,   156,   443,   156,   153,   156,   177,   156,
-     422,   211,   176,   423,   211,   176,   188,   176,   470,   437,
-     320,   208,   156,   156,   450,   451,   461,    10,   221,   462,
-     232,   463,   409,   233,   293,   245,   478,   254,   471,   451,
-     481,   477,   211,   482,   211,   483,   211,   222,     1,   255,
-       2,   256,   257,   276,   274,   282,   156,   284,   294,   285,
-     156,   286,   156,   287,   321,   324,   329,   436,   337,   338,
-     340,   341,   346,   347,   349,   147,   431,     3,   447,   363,
-     364,   366,   367,   435,   369,   374,   387,   376,   380,   384,
-     386,   388,     4,     5,   400,   391,   407,   279,     6,    31,
-      62,    32,    63,     7,   419,   403,   404,   455,   431,   420,
-     424,   433,   432,   448,   449,   460,    64,    65,   201,   474,
-       8,   464,   484,   447,   485,   468,   472,   431,    67,    68,
-     156,   371,   456,   227,   469,    69,    70,   280,   476,   473,
-       9,   152,    71,    72,    73,   336,    10,   335,   156,   202,
-      74,   310,   156,   198,   196,   228,    75,    11,   146,    76,
-     311,   184,   410,    12,   199,    13,   425,     0,     0,    77,
-      78,     0,   251,     0,   252,     0,     0,    79,    80,     0,
-       0,     0,     0,     0,     0,    31,    62,    32,    63,     0,
-      81,   168,     0,     0,     0,     0,     0,    82,     0,     0,
-      83,    84,    64,    65,     0,     0,     0,     0,    85,     0,
-       0,     0,    86,     0,    67,    68,     0,    87,   203,     0,
-       0,    69,    70,     0,     0,     0,     0,     0,    71,    72,
-      73,     0,     0,     0,     0,     0,    74,     0,     0,     0,
-       0,   169,    75,     0,     0,    76,     0,     0,    31,    62,
-      32,    63,     0,     0,     0,    77,    78,     0,     0,     0,
-       0,     0,     0,    79,    80,    64,    65,    66,     0,     0,
-       0,     0,     0,     0,     0,     0,    81,    67,    68,     0,
-       0,     0,     0,    82,    69,    70,    83,    84,     0,     0,
-       0,    71,    72,    73,    85,     0,     0,     0,    86,    74,
-       0,     0,     0,   170,     0,    75,     0,     0,    76,     0,
-       0,    31,    62,    32,    63,     0,     0,     0,    77,    78,
-       0,     0,     0,     0,     0,     0,    79,    80,    64,    65,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,    81,
-      67,    68,     0,     0,     0,     0,    82,    69,    70,    83,
-      84,     0,     0,     0,    71,    72,    73,    85,     0,     0,
-       0,    86,    74,     0,     0,     0,    87,     0,    75,     0,
-       0,    76,     0,     0,    31,    62,    32,    63,     0,     0,
+      33,    45,   247,   296,   193,   154,   278,    42,    46,    27,
+     232,    31,   178,    32,   462,   147,    31,   272,    32,   213,
+     271,   232,   232,   232,   136,   137,    55,   363,   364,   179,
+      57,    58,    59,    60,    61,    51,   463,   183,    92,   183,
+      30,   300,   389,   321,   234,   235,   236,   237,   238,   239,
+     240,   241,   242,   243,    39,   136,   137,   136,   137,   176,
+     141,   142,   136,   137,   136,   137,   122,   176,    50,   229,
+     118,   136,   137,   301,   420,   475,   195,    37,   230,    40,
+     211,   302,   422,    38,   131,   354,   299,   424,   140,    34,
+     273,   207,   365,    45,    10,   121,   476,   180,   426,   151,
+      46,   343,   156,   157,   148,   244,    36,   164,   167,   355,
+     356,   148,   211,   156,   176,   303,   176,   322,   180,   250,
+     211,    35,   380,   187,   304,   211,   310,   372,   305,   194,
+     464,   357,    92,   449,   197,   153,   211,   400,   193,   443,
+       1,   306,     2,   200,   319,   204,   409,   214,   396,   382,
+     313,   314,   315,   452,   167,   327,   219,   220,   189,   334,
+     189,   467,   454,   143,   331,   385,   212,   231,   292,     3,
+     215,   211,    31,   108,    32,   332,    47,   251,   176,   176,
+     254,   416,    54,   352,     4,     5,    46,   468,    56,    46,
+       6,   211,    31,   349,    32,     7,   103,    10,   216,   204,
+     211,   109,   151,   262,   316,   282,   489,   284,   247,   263,
+     116,   106,   379,     8,   264,   217,   378,   265,   294,   259,
+     117,   167,   289,   490,   136,   137,   386,   113,   388,   290,
+     390,   176,   392,     9,   266,    48,   206,    49,   262,    10,
+     317,   105,   320,   104,   263,   401,   402,   326,   330,   264,
+      11,   335,   265,   397,   329,    46,    12,   110,    13,   404,
+     156,   267,   336,   194,   337,   112,   405,   107,   415,   266,
+      46,   111,    31,    52,    32,   338,    53,   348,   113,   413,
+     136,   137,   421,   119,   156,   120,   425,   125,   427,   136,
+     137,   176,   158,   159,   160,   161,   128,   423,   126,   138,
+     127,   374,   210,   211,   224,   225,   249,   211,   406,   136,
+     137,   130,   376,   279,   280,   204,   129,   176,   323,   324,
+     347,   280,   359,   360,   384,   361,   362,   156,   448,   156,
+     450,   156,   451,   156,   453,   176,   403,   211,   418,   280,
+     132,   204,   431,   211,   432,   211,   156,   156,   446,   280,
+     447,   324,   460,   461,   481,   461,   133,   471,   294,   480,
+     472,   135,   473,   487,   211,   153,   176,   162,   176,   177,
+     176,   186,   176,   188,   204,    10,   417,   488,   492,   211,
+     208,   491,   232,   156,   493,   211,   221,   156,   222,   156,
+     233,   246,   255,   256,   257,   176,   258,   275,   176,   286,
+     176,   277,   285,   440,   283,   287,   288,   295,   318,   325,
+     444,   328,   445,   341,   333,   234,   235,   236,   237,   238,
+     239,   240,   241,   242,   243,   457,   136,   137,   342,    31,
+      62,    32,    63,   344,   350,   345,   465,   440,   351,   353,
+     147,   367,   368,   370,   371,   377,    64,    65,   201,   373,
+     383,   381,   394,   387,   391,   478,   393,   440,    67,    68,
+     156,   398,   407,   410,   395,    69,    70,   411,   414,   280,
+     428,   457,    71,    72,    73,   429,   244,   433,   156,   202,
+      74,   441,   156,   442,   458,   459,    75,   470,   484,    76,
+     494,   495,   466,   474,   152,   375,   479,   227,   281,   339,
+      77,    78,   482,   486,   483,   311,   340,   312,    79,    80,
+     228,   146,   252,   253,   184,   419,    31,    62,    32,    63,
+     196,    81,   168,   198,   434,     0,   199,     0,    82,     0,
+       0,    83,    84,    64,    65,     0,     0,     0,     0,    85,
+       0,     0,     0,    86,     0,    67,    68,     0,    87,   203,
+       0,     0,    69,    70,     0,     0,     0,     0,     0,    71,
+      72,    73,     0,     0,     0,     0,     0,    74,     0,     0,
+       0,     0,   169,    75,     0,     0,    76,     0,     0,     0,
+      31,    62,    32,    63,     0,     0,     0,    77,    78,     0,
+       0,     0,     0,     0,     0,    79,    80,    64,    65,    66,
+       0,     0,     0,     0,     0,     0,     0,     0,    81,    67,
+      68,     0,     0,     0,     0,    82,    69,    70,    83,    84,
+       0,     0,     0,    71,    72,    73,    85,     0,     0,     0,
+      86,    74,     0,     0,     0,   170,     0,    75,     0,     0,
+      76,     0,     0,     0,    31,    62,    32,    63,     0,     0,
        0,    77,    78,     0,     0,     0,     0,     0,     0,    79,
       80,    64,    65,     0,     0,     0,     0,     0,     0,     0,
        0,     0,    81,    67,    68,     0,     0,     0,     0,    82,
       69,    70,    83,    84,     0,     0,     0,    71,    72,    73,
-      85,   121,     0,     0,    86,    74,     0,     0,     0,    87,
-     169,    75,     0,     0,    76,     0,     0,    31,    62,    32,
-      63,     0,     0,     0,    77,    78,     0,     0,     0,     0,
-       0,     0,    79,    80,    64,    65,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,    81,    67,    68,     0,     0,
-       0,     0,    82,    69,    70,    83,    84,     0,     0,     0,
-      71,    72,    73,    85,     0,     0,     0,    86,    74,     0,
-       0,     0,   170,     0,    75,     0,     0,    76,     0,     0,
+      85,     0,     0,     0,    86,    74,     0,     0,     0,    87,
+       0,    75,     0,     0,    76,     0,     0,     0,    31,    62,
+      32,    63,     0,     0,     0,    77,    78,     0,     0,     0,
+       0,     0,     0,    79,    80,    64,    65,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,    81,    67,    68,     0,
+       0,     0,     0,    82,    69,    70,    83,    84,     0,     0,
+       0,    71,    72,    73,    85,   121,     0,     0,    86,    74,
+       0,     0,     0,    87,   169,    75,     0,     0,    76,     0,
+       0,     0,    31,    62,    32,    63,     0,     0,     0,    77,
+      78,     0,     0,     0,     0,     0,     0,    79,    80,    64,
+      65,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+      81,    67,    68,     0,     0,     0,     0,    82,    69,    70,
+      83,    84,     0,     0,     0,    71,    72,    73,    85,     0,
+       0,     0,    86,    74,     0,     0,     0,   170,     0,    75,
+       0,     0,    76,     0,     0,     0,    31,    62,    32,    63,
+       0,     0,     0,    77,    78,     0,     0,     0,     0,     0,
+       0,    79,    80,    64,    65,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,    81,    67,    68,     0,    10,     0,
+       0,    82,    69,    70,    83,    84,     0,     0,     0,    71,
+      72,    73,    85,     0,     0,     0,    86,    74,     0,     0,
+       0,    87,     0,    75,     0,     0,    76,     0,     0,     0,
       31,    62,    32,    63,     0,     0,     0,    77,    78,     0,
        0,     0,     0,     0,     0,    79,    80,    64,   145,     0,
        0,     0,     0,     0,     0,     0,     0,     0,    81,    67,
       68,     0,     0,     0,     0,    82,    69,    70,    83,    84,
-       0,     0,     0,    71,    72,    73,    85,     0,     0,     0,
+       0,     0,     0,    71,    72,    73,    85,    62,     0,    63,
       86,    74,     0,     0,     0,    87,     0,    75,     0,     0,
-      76,     0,     0,     0,    62,     0,    63,     0,     0,     0,
-      77,    78,     0,     0,     0,     0,     0,     0,    79,    80,
-      64,   145,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,    81,    67,    68,     0,     0,     0,     0,    82,     0,
-      70,    83,    84,     0,     0,     0,    71,    72,    73,    85,
-       0,     0,     0,    86,    74,     0,     0,     0,    87,     0,
-       0,    67,    68,    76,     0,     0,     0,     0,     0,    70,
-       0,     0,     0,    77,    78,    71,    72,    73,     0,     0,
-       0,    79,    80,    74,     0,     0,     0,     0,     0,     0,
-       0,     0,    76,     0,    81,     0,     0,     0,     0,     0,
-       0,    82,    77,   226,    83,    84,     0,     0,     0,     0,
-      79,     0,    85,     0,     0,     0,    86,     0,     0,     0,
-       0,     0,     0,    81,     0,     0,     0,     0,     0,     0,
-      82,     0,     0,    83,    84,     0,     0,     0,     0,     0,
-       0,    85,     0,     0,     0,    86,   234,   235,   236,   237,
-     238,   239,   240,   241,   242,   243,     0,   136,   137
+      76,     0,     0,    64,   145,     0,     0,     0,     0,     0,
+       0,    77,    78,     0,     0,    67,    68,     0,     0,    79,
+      80,     0,     0,    70,     0,     0,     0,     0,     0,    71,
+      72,    73,    81,     0,     0,     0,     0,    74,     0,    82,
+       0,     0,    83,    84,     0,     0,    76,     0,    67,    68,
+      85,     0,     0,     0,    86,     0,    70,    77,    78,    87,
+       0,     0,    71,    72,    73,    79,    80,     0,     0,     0,
+      74,     0,     0,     0,     0,     0,     0,     0,    81,    76,
+       0,     0,     0,     0,     0,    82,     0,     0,    83,    84,
+      77,   226,     0,     0,     0,     0,    85,     0,    79,     0,
+      86,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,    81,     0,     0,     0,     0,     0,     0,    82,     0,
+       0,    83,    84,     0,     0,     0,     0,     0,     0,    85,
+       0,     0,     0,    86
 };
 
 static const yytype_int16 yycheck[] =
 {
-       4,   117,   224,    12,   202,   133,   113,    11,    12,   177,
-       4,    27,     6,     7,   121,     8,     8,     8,    36,    26,
-      41,     4,   158,     6,     8,    10,    30,   105,   121,    57,
-      34,    35,    36,    37,    38,    29,    10,   193,    10,    11,
-      12,    13,    14,    15,    16,    17,    18,    19,    69,    21,
-      22,    21,    22,    73,    61,    57,    23,    24,    21,    22,
-       4,   168,     6,   170,    77,    71,    87,    86,    42,    42,
-      21,    22,    21,    22,   103,    88,    50,   170,    86,    99,
-      37,    38,    77,    86,    66,    63,   114,    31,    92,   225,
-     108,   169,    65,    88,     0,   104,    28,   103,    83,   103,
-     104,    79,   106,   107,   122,   124,   122,   111,   112,    83,
-      86,    76,   114,   117,   135,   222,   124,   273,    92,    92,
-     104,   124,    96,   127,    56,   232,   233,   148,   122,   133,
-     123,   123,   123,   301,   138,   109,   109,   103,   266,   122,
-      86,   363,   340,   147,   101,    86,   153,   263,   124,   170,
-     157,   123,   320,   123,   158,   104,   160,   161,   125,   180,
-     123,    62,   183,   114,    66,    86,    86,    29,     3,    67,
-      69,   287,   100,    52,    72,    99,   124,   284,   124,    77,
-      59,   202,    80,   124,    85,    86,   190,   208,   112,   193,
-      77,   284,    54,    52,    76,    94,   115,   134,   122,    97,
-      59,    88,   206,   124,   124,   124,   107,   211,   376,    21,
-      22,   327,   149,   329,    67,   331,    31,   333,   222,    72,
-      32,   225,   243,   244,    77,   122,   124,    80,   249,   118,
-     346,   347,   121,     9,   341,   256,     5,     4,     4,     6,
-       6,    53,    43,    44,    97,    21,    22,   122,   341,   258,
-     118,   358,   120,    86,   258,    21,    22,   115,   279,   263,
-     367,   122,   266,     7,   380,    31,     9,     7,   384,   273,
-     386,    17,    18,    19,   367,   382,   123,   124,    21,    22,
-      43,    44,   122,   287,   123,   124,   123,   124,    75,   382,
-      21,    22,     5,   314,   123,   124,   123,   124,   123,   124,
-     304,   122,   323,    75,   411,     5,   413,    66,   415,     7,
-     417,   124,   123,   124,   123,   124,   123,   124,   411,   340,
-     413,   116,   415,   327,   417,   329,   122,   331,   122,   333,
-     123,   124,   439,   123,   124,   442,     7,   444,   454,   123,
-     124,    11,   346,   347,   123,   124,   439,    99,   122,   442,
-       8,   444,   373,     9,   358,    20,   472,    58,   123,   124,
-     476,   123,   124,   123,   124,   123,   124,   122,     1,   123,
-       3,    66,   123,   123,    68,   123,   380,   122,   111,    78,
-     384,    78,   386,   122,   112,    58,    77,   408,     7,     7,
-      39,    70,   122,   122,     5,    27,   400,    30,   419,   124,
-     116,    83,   122,   407,    78,    83,    91,   122,    77,    77,
-      77,    91,    45,    46,   122,    87,   122,   124,    51,     4,
-       5,     6,     7,    56,    39,    35,    89,   431,   432,    81,
-       5,    39,   122,     7,    96,   123,    21,    22,    23,    84,
-      73,   124,    90,   464,     7,   449,   122,   451,    33,    34,
-     454,   307,   432,   167,   451,    40,    41,   206,   122,   464,
-      93,   104,    47,    48,    49,   268,    99,   266,   472,    54,
-      55,   232,   476,   139,   135,   168,    61,   110,   101,    64,
-     233,   123,   376,   116,   144,   118,   398,    -1,    -1,    74,
-      75,    -1,   181,    -1,   181,    -1,    -1,    82,    83,    -1,
-      -1,    -1,    -1,    -1,    -1,     4,     5,     6,     7,    -1,
-      95,    10,    -1,    -1,    -1,    -1,    -1,   102,    -1,    -1,
-     105,   106,    21,    22,    -1,    -1,    -1,    -1,   113,    -1,
-      -1,    -1,   117,    -1,    33,    34,    -1,   122,   123,    -1,
-      -1,    40,    41,    -1,    -1,    -1,    -1,    -1,    47,    48,
-      49,    -1,    -1,    -1,    -1,    -1,    55,    -1,    -1,    -1,
-      -1,    60,    61,    -1,    -1,    64,    -1,    -1,     4,     5,
-       6,     7,    -1,    -1,    -1,    74,    75,    -1,    -1,    -1,
-      -1,    -1,    -1,    82,    83,    21,    22,    23,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    95,    33,    34,    -1,
-      -1,    -1,    -1,   102,    40,    41,   105,   106,    -1,    -1,
-      -1,    47,    48,    49,   113,    -1,    -1,    -1,   117,    55,
-      -1,    -1,    -1,   122,    -1,    61,    -1,    -1,    64,    -1,
-      -1,     4,     5,     6,     7,    -1,    -1,    -1,    74,    75,
-      -1,    -1,    -1,    -1,    -1,    -1,    82,    83,    21,    22,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    95,
-      33,    34,    -1,    -1,    -1,    -1,   102,    40,    41,   105,
-     106,    -1,    -1,    -1,    47,    48,    49,   113,    -1,    -1,
-      -1,   117,    55,    -1,    -1,    -1,   122,    -1,    61,    -1,
-      -1,    64,    -1,    -1,     4,     5,     6,     7,    -1,    -1,
-      -1,    74,    75,    -1,    -1,    -1,    -1,    -1,    -1,    82,
-      83,    21,    22,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    95,    33,    34,    -1,    -1,    -1,    -1,   102,
-      40,    41,   105,   106,    -1,    -1,    -1,    47,    48,    49,
-     113,   114,    -1,    -1,   117,    55,    -1,    -1,    -1,   122,
-      60,    61,    -1,    -1,    64,    -1,    -1,     4,     5,     6,
-       7,    -1,    -1,    -1,    74,    75,    -1,    -1,    -1,    -1,
-      -1,    -1,    82,    83,    21,    22,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    95,    33,    34,    -1,    -1,
-      -1,    -1,   102,    40,    41,   105,   106,    -1,    -1,    -1,
-      47,    48,    49,   113,    -1,    -1,    -1,   117,    55,    -1,
-      -1,    -1,   122,    -1,    61,    -1,    -1,    64,    -1,    -1,
-       4,     5,     6,     7,    -1,    -1,    -1,    74,    75,    -1,
-      -1,    -1,    -1,    -1,    -1,    82,    83,    21,    22,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    95,    33,
-      34,    -1,    -1,    -1,    -1,   102,    40,    41,   105,   106,
-      -1,    -1,    -1,    47,    48,    49,   113,    -1,    -1,    -1,
-     117,    55,    -1,    -1,    -1,   122,    -1,    61,    -1,    -1,
-      64,    -1,    -1,    -1,     5,    -1,     7,    -1,    -1,    -1,
-      74,    75,    -1,    -1,    -1,    -1,    -1,    -1,    82,    83,
-      21,    22,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    95,    33,    34,    -1,    -1,    -1,    -1,   102,    -1,
-      41,   105,   106,    -1,    -1,    -1,    47,    48,    49,   113,
-      -1,    -1,    -1,   117,    55,    -1,    -1,    -1,   122,    -1,
-      -1,    33,    34,    64,    -1,    -1,    -1,    -1,    -1,    41,
-      -1,    -1,    -1,    74,    75,    47,    48,    49,    -1,    -1,
-      -1,    82,    83,    55,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    64,    -1,    95,    -1,    -1,    -1,    -1,    -1,
-      -1,   102,    74,    75,   105,   106,    -1,    -1,    -1,    -1,
-      82,    -1,   113,    -1,    -1,    -1,   117,    -1,    -1,    -1,
-      -1,    -1,    -1,    95,    -1,    -1,    -1,    -1,    -1,    -1,
-     102,    -1,    -1,   105,   106,    -1,    -1,    -1,    -1,    -1,
-      -1,   113,    -1,    -1,    -1,   117,    10,    11,    12,    13,
-      14,    15,    16,    17,    18,    19,    -1,    21,    22
+       4,    12,   177,   224,   133,   105,   202,    11,    12,     0,
+       8,     4,   117,     6,     7,    27,     4,    36,     6,   158,
+     193,     8,     8,     8,    21,    22,    30,    37,    38,   121,
+      34,    35,    36,    37,    38,    26,    29,    57,    41,    57,
+     104,    10,    87,    10,    10,    11,    12,    13,    14,    15,
+      16,    17,    18,    19,    29,    21,    22,    21,    22,   113,
+      23,    24,    21,    22,    21,    22,    69,   121,    74,   169,
+      61,    21,    22,    42,    87,    32,   134,   104,   170,    54,
+     125,    50,    87,    77,    87,    62,   225,    87,    92,    72,
+     109,   149,   102,   104,   100,   115,    53,   115,    87,   103,
+     104,   274,   106,   107,   123,    71,    66,   111,   112,    86,
+      87,   123,   125,   117,   168,    84,   170,    84,   115,   105,
+     125,   104,   318,   127,    93,   125,   124,   302,    97,   133,
+     123,   108,   135,    87,   138,   123,   125,   124,   267,   124,
+       1,   110,     3,   147,   244,   148,   367,    42,   344,   324,
+      17,    18,    19,    87,   158,   105,   160,   161,   124,   264,
+     124,    69,    87,   126,    78,   124,   157,   170,   222,    30,
+      65,   125,     4,    28,     6,    89,     0,   180,   232,   233,
+     183,   377,     3,   288,    45,    46,   190,    95,    66,   193,
+      51,   125,     4,   285,     6,    56,   101,   100,    93,   202,
+     125,    56,   206,    67,    71,   208,    63,   211,   383,    73,
+     113,   123,     9,    74,    78,   110,   316,    81,   222,    31,
+     123,   225,    52,    80,    21,    22,   331,   116,   333,    59,
+     335,   285,   337,    94,    98,   119,   125,   121,    67,   100,
+     243,    31,   245,   125,    73,   350,   351,   250,   259,    78,
+     111,    78,    81,   345,   257,   259,   117,     5,   119,    52,
+     264,   125,    89,   267,    78,   123,    59,    77,     9,    98,
+     274,    87,     4,   119,     6,    89,   122,   280,   116,   371,
+      21,    22,   387,     7,   288,     7,   391,   123,   393,    21,
+      22,   345,    43,    44,    43,    44,     5,   389,    76,    31,
+     123,   305,   124,   125,   124,   125,   124,   125,   362,    21,
+      22,    76,   315,   124,   125,   318,   123,   371,   124,   125,
+     124,   125,   124,   125,   327,   124,   125,   331,   420,   333,
+     422,   335,   424,   337,   426,   389,   124,   125,   124,   125,
+       5,   344,   124,   125,   124,   125,   350,   351,   124,   125,
+     124,   125,   124,   125,   124,   125,    66,   449,   362,   464,
+     452,   125,   454,   124,   125,   123,   420,   117,   422,   123,
+     424,     7,   426,     7,   377,   100,   379,   482,   124,   125,
+      11,   486,     8,   387,   124,   125,   123,   391,   123,   393,
+       9,    20,    58,   124,    66,   449,   124,    68,   452,    79,
+     454,   124,   123,   407,   124,    79,   123,   112,   123,   113,
+     414,    58,   415,     7,    78,    10,    11,    12,    13,    14,
+      15,    16,    17,    18,    19,   428,    21,    22,     7,     4,
+       5,     6,     7,    39,   123,    70,   440,   441,   123,     5,
+      27,   125,   117,    84,   123,   123,    21,    22,    23,    79,
+     123,    84,    92,    78,    78,   459,    78,   461,    33,    34,
+     464,    88,   123,    35,    92,    40,    41,    90,   123,   125,
+      39,   474,    47,    48,    49,    82,    71,     5,   482,    54,
+      55,   123,   486,    39,     7,    97,    61,   124,    85,    64,
+      91,     7,   441,   125,   104,   308,   461,   167,   206,   267,
+      75,    76,   123,   123,   474,   232,   269,   233,    83,    84,
+     168,   101,   181,   181,   123,   383,     4,     5,     6,     7,
+     135,    96,    10,   139,   405,    -1,   144,    -1,   103,    -1,
+      -1,   106,   107,    21,    22,    -1,    -1,    -1,    -1,   114,
+      -1,    -1,    -1,   118,    -1,    33,    34,    -1,   123,   124,
+      -1,    -1,    40,    41,    -1,    -1,    -1,    -1,    -1,    47,
+      48,    49,    -1,    -1,    -1,    -1,    -1,    55,    -1,    -1,
+      -1,    -1,    60,    61,    -1,    -1,    64,    -1,    -1,    -1,
+       4,     5,     6,     7,    -1,    -1,    -1,    75,    76,    -1,
+      -1,    -1,    -1,    -1,    -1,    83,    84,    21,    22,    23,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    96,    33,
+      34,    -1,    -1,    -1,    -1,   103,    40,    41,   106,   107,
+      -1,    -1,    -1,    47,    48,    49,   114,    -1,    -1,    -1,
+     118,    55,    -1,    -1,    -1,   123,    -1,    61,    -1,    -1,
+      64,    -1,    -1,    -1,     4,     5,     6,     7,    -1,    -1,
+      -1,    75,    76,    -1,    -1,    -1,    -1,    -1,    -1,    83,
+      84,    21,    22,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    96,    33,    34,    -1,    -1,    -1,    -1,   103,
+      40,    41,   106,   107,    -1,    -1,    -1,    47,    48,    49,
+     114,    -1,    -1,    -1,   118,    55,    -1,    -1,    -1,   123,
+      -1,    61,    -1,    -1,    64,    -1,    -1,    -1,     4,     5,
+       6,     7,    -1,    -1,    -1,    75,    76,    -1,    -1,    -1,
+      -1,    -1,    -1,    83,    84,    21,    22,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    96,    33,    34,    -1,
+      -1,    -1,    -1,   103,    40,    41,   106,   107,    -1,    -1,
+      -1,    47,    48,    49,   114,   115,    -1,    -1,   118,    55,
+      -1,    -1,    -1,   123,    60,    61,    -1,    -1,    64,    -1,
+      -1,    -1,     4,     5,     6,     7,    -1,    -1,    -1,    75,
+      76,    -1,    -1,    -1,    -1,    -1,    -1,    83,    84,    21,
+      22,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      96,    33,    34,    -1,    -1,    -1,    -1,   103,    40,    41,
+     106,   107,    -1,    -1,    -1,    47,    48,    49,   114,    -1,
+      -1,    -1,   118,    55,    -1,    -1,    -1,   123,    -1,    61,
+      -1,    -1,    64,    -1,    -1,    -1,     4,     5,     6,     7,
+      -1,    -1,    -1,    75,    76,    -1,    -1,    -1,    -1,    -1,
+      -1,    83,    84,    21,    22,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    96,    33,    34,    -1,   100,    -1,
+      -1,   103,    40,    41,   106,   107,    -1,    -1,    -1,    47,
+      48,    49,   114,    -1,    -1,    -1,   118,    55,    -1,    -1,
+      -1,   123,    -1,    61,    -1,    -1,    64,    -1,    -1,    -1,
+       4,     5,     6,     7,    -1,    -1,    -1,    75,    76,    -1,
+      -1,    -1,    -1,    -1,    -1,    83,    84,    21,    22,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    96,    33,
+      34,    -1,    -1,    -1,    -1,   103,    40,    41,   106,   107,
+      -1,    -1,    -1,    47,    48,    49,   114,     5,    -1,     7,
+     118,    55,    -1,    -1,    -1,   123,    -1,    61,    -1,    -1,
+      64,    -1,    -1,    21,    22,    -1,    -1,    -1,    -1,    -1,
+      -1,    75,    76,    -1,    -1,    33,    34,    -1,    -1,    83,
+      84,    -1,    -1,    41,    -1,    -1,    -1,    -1,    -1,    47,
+      48,    49,    96,    -1,    -1,    -1,    -1,    55,    -1,   103,
+      -1,    -1,   106,   107,    -1,    -1,    64,    -1,    33,    34,
+     114,    -1,    -1,    -1,   118,    -1,    41,    75,    76,   123,
+      -1,    -1,    47,    48,    49,    83,    84,    -1,    -1,    -1,
+      55,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    96,    64,
+      -1,    -1,    -1,    -1,    -1,   103,    -1,    -1,   106,   107,
+      75,    76,    -1,    -1,    -1,    -1,   114,    -1,    83,    -1,
+     118,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    96,    -1,    -1,    -1,    -1,    -1,    -1,   103,    -1,
+      -1,   106,   107,    -1,    -1,    -1,    -1,    -1,    -1,   114,
+      -1,    -1,    -1,   118
 };
 
   /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
      symbol of state STATE-NUM.  */
 static const yytype_uint8 yystos[] =
 {
-       0,     1,     3,    30,    45,    46,    51,    56,    73,    93,
-      99,   110,   116,   118,   127,   128,   129,   130,   131,   132,
-     133,   154,   155,   158,   159,   162,   163,   166,   219,   220,
-     103,     4,     6,   217,    71,   103,    66,   103,    76,    29,
-      54,   167,   217,   164,   165,   179,   217,     0,   118,   120,
-      73,   166,   118,   121,     3,   217,    66,   217,   217,   217,
-     217,   217,     5,     7,    21,    22,    23,    33,    34,    40,
-      41,    47,    48,    49,    55,    61,    64,    74,    75,    82,
-      83,    95,   102,   105,   106,   113,   117,   122,   136,   168,
-     169,   170,   195,   196,   197,   198,   199,   200,   201,   208,
-     210,   213,   217,   100,   124,    31,   122,    76,    28,    56,
-       5,    86,   122,   115,   189,   190,   112,   122,   166,     7,
-       7,   114,   195,   204,   205,   122,    75,   122,     5,   122,
-      75,   195,     5,    66,   171,   124,    21,    22,    31,   214,
-     217,    23,    24,   125,   215,    22,   198,    27,   122,   160,
-     161,   217,   165,   122,   175,   216,   217,   217,    43,    44,
-      43,    44,   116,   156,   217,   134,   135,   217,    10,    60,
-     122,   191,   192,   193,   194,   195,   210,   122,   216,   191,
-     114,   202,   203,    57,   205,   206,     7,   217,     7,   123,
-     175,   177,   180,   199,   217,   189,   170,   217,   196,   197,
-     217,    23,    54,   123,   195,   207,   124,   189,    11,   166,
-     123,   124,   166,   134,    42,    65,    92,   109,   140,   217,
-     217,   122,   122,   143,   123,   124,    75,   136,   194,   175,
-     191,   195,     8,     9,    10,    11,    12,    13,    14,    15,
-      16,    17,    18,    19,   212,    20,   208,   209,   123,   104,
-     195,   203,   206,   195,    58,   123,    66,   123,    31,   178,
-     179,    67,    72,    77,    80,    97,   124,   172,   173,   174,
-     178,    36,   108,   176,    68,   181,   123,   207,   123,   124,
-     161,   195,   123,   217,   122,    78,    78,   122,    52,    59,
-     157,   210,   211,   217,   111,   140,   141,   142,   134,    10,
-      42,    50,    83,    92,    96,   109,   137,   138,   139,   123,
-     192,   193,    17,    18,    19,   195,   195,    10,    83,   123,
-     124,   112,   195,   104,    58,   195,   179,    77,    88,    77,
-     216,    77,    88,    77,    88,   177,   174,     7,     7,   178,
-      39,    70,   182,   123,   195,   191,   122,   122,   216,     5,
-      62,    85,    86,   107,   218,   123,   124,   123,   124,    37,
-      38,   101,   152,   124,   116,   144,    83,   122,   208,    78,
-     217,   137,   195,     9,    83,   208,   122,   195,   123,   216,
-      77,   216,    86,   216,    77,   216,    77,    91,    91,   207,
-     191,    87,   183,   123,   216,   216,   123,    52,    59,   210,
-     122,   153,   140,    35,    89,   145,   191,   122,     9,   195,
-     209,    86,   216,    86,   191,    86,   216,    86,   216,    39,
-      81,   184,   123,   123,     5,   218,   147,   148,   149,   150,
-     151,   217,   122,    39,   123,   217,   195,   123,   191,    86,
-     191,   191,    86,   191,    86,   185,   186,   195,     7,    96,
-     123,   124,     7,    29,   122,   217,   147,    69,    94,   146,
-     123,   191,   191,   191,   124,    32,    53,   187,   217,   148,
-     216,   123,   122,   186,    84,   188,   122,   123,   216,    63,
-      79,   216,   123,   123,    90,     7
+       0,     1,     3,    30,    45,    46,    51,    56,    74,    94,
+     100,   111,   117,   119,   128,   129,   130,   131,   132,   133,
+     134,   155,   156,   159,   160,   163,   164,   167,   220,   221,
+     104,     4,     6,   218,    72,   104,    66,   104,    77,    29,
+      54,   168,   218,   165,   166,   180,   218,     0,   119,   121,
+      74,   167,   119,   122,     3,   218,    66,   218,   218,   218,
+     218,   218,     5,     7,    21,    22,    23,    33,    34,    40,
+      41,    47,    48,    49,    55,    61,    64,    75,    76,    83,
+      84,    96,   103,   106,   107,   114,   118,   123,   137,   169,
+     170,   171,   196,   197,   198,   199,   200,   201,   202,   209,
+     211,   214,   218,   101,   125,    31,   123,    77,    28,    56,
+       5,    87,   123,   116,   190,   191,   113,   123,   167,     7,
+       7,   115,   196,   205,   206,   123,    76,   123,     5,   123,
+      76,   196,     5,    66,   172,   125,    21,    22,    31,   215,
+     218,    23,    24,   126,   216,    22,   199,    27,   123,   161,
+     162,   218,   166,   123,   176,   217,   218,   218,    43,    44,
+      43,    44,   117,   157,   218,   135,   136,   218,    10,    60,
+     123,   192,   193,   194,   195,   196,   211,   123,   217,   192,
+     115,   203,   204,    57,   206,   207,     7,   218,     7,   124,
+     176,   178,   181,   200,   218,   190,   171,   218,   197,   198,
+     218,    23,    54,   124,   196,   208,   125,   190,    11,   167,
+     124,   125,   167,   135,    42,    65,    93,   110,   141,   218,
+     218,   123,   123,   144,   124,   125,    76,   137,   195,   176,
+     192,   196,     8,     9,    10,    11,    12,    13,    14,    15,
+      16,    17,    18,    19,    71,   213,    20,   209,   210,   124,
+     105,   196,   204,   207,   196,    58,   124,    66,   124,    31,
+     179,   180,    67,    73,    78,    81,    98,   125,   173,   174,
+     175,   179,    36,   109,   177,    68,   182,   124,   208,   124,
+     125,   162,   196,   124,   218,   123,    79,    79,   123,    52,
+      59,   158,   211,   212,   218,   112,   141,   142,   143,   135,
+      10,    42,    50,    84,    93,    97,   110,   138,   139,   140,
+     124,   193,   194,    17,    18,    19,    71,   196,   123,   176,
+     196,    10,    84,   124,   125,   113,   196,   105,    58,   196,
+     180,    78,    89,    78,   217,    78,    89,    78,    89,   178,
+     175,     7,     7,   179,    39,    70,   183,   124,   196,   192,
+     123,   123,   217,     5,    62,    86,    87,   108,   219,   124,
+     125,   124,   125,    37,    38,   102,   153,   125,   117,   145,
+      84,   123,   209,    79,   218,   138,   196,   123,   176,     9,
+     208,    84,   209,   123,   196,   124,   217,    78,   217,    87,
+     217,    78,   217,    78,    92,    92,   208,   192,    88,   184,
+     124,   217,   217,   124,    52,    59,   211,   123,   154,   141,
+      35,    90,   146,   192,   123,     9,   208,   196,   124,   210,
+      87,   217,    87,   192,    87,   217,    87,   217,    39,    82,
+     185,   124,   124,     5,   219,   148,   149,   150,   151,   152,
+     218,   123,    39,   124,   218,   196,   124,   124,   192,    87,
+     192,   192,    87,   192,    87,   186,   187,   196,     7,    97,
+     124,   125,     7,    29,   123,   218,   148,    69,    95,   147,
+     124,   192,   192,   192,   125,    32,    53,   188,   218,   149,
+     217,   124,   123,   187,    85,   189,   123,   124,   217,    63,
+      80,   217,   124,   124,    91,     7
 };
 
   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
 static const yytype_uint8 yyr1[] =
 {
-       0,   126,   127,   127,   127,   127,   127,   127,   128,   128,
-     128,   128,   128,   128,   128,   128,   128,   128,   129,   130,
-     130,   130,   130,   131,   132,   133,   134,   135,   135,   136,
-     136,   136,   136,   136,   136,   136,   136,   136,   136,   136,
-     136,   136,   136,   136,   136,   136,   136,   137,   137,   137,
-     137,   137,   137,   137,   138,   138,   139,   139,   140,   140,
-     140,   140,   141,   141,   142,   142,   143,   143,   144,   144,
-     145,   145,   146,   146,   147,   147,   148,   148,   148,   149,
-     149,   150,   151,   152,   152,   152,   153,   153,   154,   154,
-     154,   154,   155,   156,   156,   157,   157,   157,   157,   158,
-     159,   160,   160,   161,   162,   162,   163,   164,   164,   165,
-     166,   167,   167,   167,   168,   168,   169,   169,   170,   170,
-     170,   171,   172,   172,   173,   173,   174,   174,   174,   174,
-     174,   174,   174,   174,   175,   176,   176,   176,   177,   177,
-     177,   177,   177,   178,   178,   179,   179,   180,   180,   181,
-     181,   182,   182,   183,   183,   184,   184,   185,   185,   186,
-     187,   187,   187,   188,   188,   188,   189,   189,   190,   191,
-     191,   192,   192,   193,   193,   194,   194,   194,   194,   194,
-     194,   194,   195,   195,   196,   196,   197,   197,   198,   198,
-     198,   198,   198,   198,   199,   199,   199,   199,   200,   201,
-     201,   202,   202,   203,   204,   204,   205,   206,   206,   207,
-     207,   208,   208,   208,   208,   208,   208,   208,   209,   209,
-     210,   210,   211,   211,   212,   212,   212,   212,   212,   212,
-     212,   212,   212,   212,   213,   214,   214,   215,   215,   215,
-     216,   216,   217,   217,   218,   218,   218,   218,   219,   220,
-     220
+       0,   127,   128,   128,   128,   128,   128,   128,   129,   129,
+     129,   129,   129,   129,   129,   129,   129,   129,   130,   131,
+     131,   131,   131,   132,   133,   134,   135,   136,   136,   137,
+     137,   137,   137,   137,   137,   137,   137,   137,   137,   137,
+     137,   137,   137,   137,   137,   137,   137,   138,   138,   138,
+     138,   138,   138,   138,   139,   139,   140,   140,   141,   141,
+     141,   141,   142,   142,   143,   143,   144,   144,   145,   145,
+     146,   146,   147,   147,   148,   148,   149,   149,   149,   150,
+     150,   151,   152,   153,   153,   153,   154,   154,   155,   155,
+     155,   155,   156,   157,   157,   158,   158,   158,   158,   159,
+     160,   161,   161,   162,   163,   163,   164,   165,   165,   166,
+     167,   168,   168,   168,   169,   169,   170,   170,   171,   171,
+     171,   172,   173,   173,   174,   174,   175,   175,   175,   175,
+     175,   175,   175,   175,   176,   177,   177,   177,   178,   178,
+     178,   178,   178,   179,   179,   180,   180,   181,   181,   182,
+     182,   183,   183,   184,   184,   185,   185,   186,   186,   187,
+     188,   188,   188,   189,   189,   189,   190,   190,   191,   192,
+     192,   193,   193,   194,   194,   195,   195,   195,   195,   195,
+     195,   195,   195,   195,   195,   195,   196,   196,   197,   197,
+     198,   198,   199,   199,   199,   199,   199,   199,   200,   200,
+     200,   200,   201,   202,   202,   203,   203,   204,   205,   205,
+     206,   207,   207,   208,   208,   209,   209,   209,   209,   209,
+     209,   209,   210,   210,   211,   211,   212,   212,   213,   213,
+     213,   213,   213,   213,   213,   213,   213,   213,   214,   215,
+     215,   216,   216,   216,   217,   217,   218,   218,   219,   219,
+     219,   219,   220,   221,   221
 };
 
   /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
@@ -1331,14 +1351,14 @@ static const yytype_uint8 yyr2[] =
        3,     0,     2,     0,     3,     0,     2,     1,     3,     3,
        0,     1,     1,     0,     2,     2,     0,     1,     2,     3,
        1,     3,     1,     2,     1,     5,     6,     4,     3,     3,
-       3,     2,     3,     1,     3,     1,     2,     1,     1,     1,
-       1,     1,     1,     3,     3,     4,     4,     5,     6,     5,
-       4,     1,     2,     4,     1,     2,     4,     0,     2,     1,
-       3,     1,     1,     2,     2,     1,     2,     2,     1,     3,
-       1,     3,     1,     3,     1,     1,     1,     1,     1,     1,
-       1,     2,     1,     2,     1,     1,     1,     1,     1,     1,
-       1,     3,     1,     1,     1,     1,     1,     1,     2,     2,
-       0
+       3,     2,     3,     5,     4,     6,     3,     1,     3,     1,
+       2,     1,     1,     1,     1,     1,     1,     3,     3,     4,
+       4,     5,     6,     5,     4,     1,     2,     4,     1,     2,
+       4,     0,     2,     1,     3,     1,     1,     2,     2,     1,
+       2,     2,     1,     3,     1,     3,     1,     3,     1,     1,
+       1,     1,     1,     1,     1,     2,     1,     2,     1,     1,
+       1,     1,     1,     1,     1,     3,     1,     1,     1,     1,
+       1,     1,     2,     2,     0
 };
 
 
@@ -1835,893 +1855,893 @@ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocatio
   switch (yytype)
     {
           case 3: /* TOKEN_COMMAND  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 1845 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1865 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 4: /* TOKEN_NAME  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 1855 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1875 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 5: /* TOKEN_STRING_SINGLE_QUOTED  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 1865 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1885 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 6: /* TOKEN_STRING_DOUBLE_QUOTED  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 1875 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1895 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 7: /* TOKEN_UNSIGNED_NUMVAL  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).numeric_literal_value_) != nullptr) {
     delete ((*yyvaluep).numeric_literal_value_);
   }
 }
-#line 1885 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1905 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 128: /* sql_statement  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 129: /* sql_statement  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).statement_) != nullptr) {
     delete ((*yyvaluep).statement_);
   }
 }
-#line 1895 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1915 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 129: /* quit_statement  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 130: /* quit_statement  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).quit_statement_) != nullptr) {
     delete ((*yyvaluep).quit_statement_);
   }
 }
-#line 1905 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1925 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 130: /* alter_table_statement  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 131: /* alter_table_statement  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).statement_) != nullptr) {
     delete ((*yyvaluep).statement_);
   }
 }
-#line 1915 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1935 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 131: /* create_table_statement  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 132: /* create_table_statement  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).create_table_statement_) != nullptr) {
     delete ((*yyvaluep).create_table_statement_);
   }
 }
-#line 1925 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1945 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 132: /* create_index_statement  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 133: /* create_index_statement  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).statement_) != nullptr) {
     delete ((*yyvaluep).statement_);
   }
 }
-#line 1935 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1955 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 133: /* drop_table_statement  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 134: /* drop_table_statement  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).drop_table_statement_) != nullptr) {
     delete ((*yyvaluep).drop_table_statement_);
   }
 }
-#line 1945 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1965 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 134: /* column_def  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 135: /* column_def  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).attribute_definition_) != nullptr) {
     delete ((*yyvaluep).attribute_definition_);
   }
 }
-#line 1955 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1975 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 135: /* column_def_commalist  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 136: /* column_def_commalist  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).attribute_definition_list_) != nullptr) {
     delete ((*yyvaluep).attribute_definition_list_);
   }
 }
-#line 1965 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1985 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 136: /* data_type  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 137: /* data_type  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).data_type_) != nullptr) {
     delete ((*yyvaluep).data_type_);
   }
 }
-#line 1975 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1995 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 137: /* column_constraint_def  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 138: /* column_constraint_def  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).column_constraint_) != nullptr) {
     delete ((*yyvaluep).column_constraint_);
   }
 }
-#line 1985 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2005 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 138: /* column_constraint_def_list  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 139: /* column_constraint_def_list  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).column_constraint_list_) != nullptr) {
     delete ((*yyvaluep).column_constraint_list_);
   }
 }
-#line 1995 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2015 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 139: /* opt_column_constraint_def_list  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 140: /* opt_column_constraint_def_list  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).column_constraint_list_) != nullptr) {
     delete ((*yyvaluep).column_constraint_list_);
   }
 }
-#line 2005 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2025 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 143: /* opt_column_list  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 144: /* opt_column_list  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).attribute_list_) != nullptr) {
     delete ((*yyvaluep).attribute_list_);
   }
 }
-#line 2015 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2035 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 144: /* opt_block_properties  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 145: /* opt_block_properties  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).block_properties_) != nullptr) {
     delete ((*yyvaluep).block_properties_);
   }
 }
-#line 2025 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2045 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 145: /* opt_partition_clause  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 146: /* opt_partition_clause  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).partition_clause_) != nullptr) {
     delete ((*yyvaluep).partition_clause_);
   }
 }
-#line 2035 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2055 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 146: /* partition_type  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 147: /* partition_type  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 2045 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2065 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 147: /* key_value_list  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 148: /* key_value_list  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_value_list_) != nullptr) {
     delete ((*yyvaluep).key_value_list_);
   }
 }
-#line 2055 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2075 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 148: /* key_value  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 149: /* key_value  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_value_) != nullptr) {
     delete ((*yyvaluep).key_value_);
   }
 }
-#line 2065 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2085 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 149: /* key_string_value  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 150: /* key_string_value  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_string_value_) != nullptr) {
     delete ((*yyvaluep).key_string_value_);
   }
 }
-#line 2075 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2095 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 150: /* key_string_list  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 151: /* key_string_list  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_string_list_) != nullptr) {
     delete ((*yyvaluep).key_string_list_);
   }
 }
-#line 2085 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2105 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 151: /* key_integer_value  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 152: /* key_integer_value  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_integer_value_) != nullptr) {
     delete ((*yyvaluep).key_integer_value_);
   }
 }
-#line 2095 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2115 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 152: /* index_type  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 153: /* index_type  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 2105 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2125 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 153: /* opt_index_properties  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 154: /* opt_index_properties  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_value_list_) != nullptr) {
     delete ((*yyvaluep).key_value_list_);
   }
 }
-#line 2115 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2135 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 154: /* insert_statement  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 155: /* insert_statement  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).insert_statement_) != nullptr) {
     delete ((*yyvaluep).insert_statement_);
   }
 }
-#line 2125 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2145 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 155: /* copy_from_statement  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 156: /* copy_from_statement  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).copy_from_statement_) != nullptr) {
     delete ((*yyvaluep).copy_from_statement_);
   }
 }
-#line 2135 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2155 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 156: /* opt_copy_from_params  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 157: /* opt_copy_from_params  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).copy_from_params_) != nullptr) {
     delete ((*yyvaluep).copy_from_params_);
   }
 }
-#line 2145 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2165 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 157: /* copy_from_params  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 158: /* copy_from_params  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).copy_from_params_) != nullptr) {
     delete ((*yyvaluep).copy_from_params_);
   }
 }
-#line 2155 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2175 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 158: /* update_statement  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 159: /* update_statement  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).update_statement_) != nullptr) {
     delete ((*yyvaluep).update_statement_);
   }
 }
-#line 2165 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2185 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 159: /* delete_statement  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 160: /* delete_statement  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).delete_statement_) != nullptr) {
     delete ((*yyvaluep).delete_statement_);
   }
 }
-#line 2175 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2195 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 160: /* assignment_list  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 161: /* assignment_list  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).assignment_list_) != nullptr) {
     delete ((*yyvaluep).assignment_list_);
   }
 }
-#line 2185 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2205 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 161: /* assignment_item  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 162: /* assignment_item  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).assignment_) != nullptr) {
     delete ((*yyvaluep).assignment_);
   }
 }
-#line 2195 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2215 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 162: /* select_statement  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 163: /* select_statement  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).select_statement_) != nullptr) {
     delete ((*yyvaluep).select_statement_);
   }
 }
-#line 2205 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2225 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 163: /* with_clause  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 164: /* with_clause  */
+#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).with_list_) != nullptr) {
     delete ((*yyvaluep).with_list_);
   }
 }
-#line 2215 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2235 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 164: /* with_list  */
-#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 165: /* with_list 

<TRUNCATED>


[19/24] incubator-quickstep git commit: Added JOIN ... ON ... operator and tests. (#171)

Posted by zu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/parser/preprocessed/SqlParser_gen.hpp
----------------------------------------------------------------------
diff --git a/parser/preprocessed/SqlParser_gen.hpp b/parser/preprocessed/SqlParser_gen.hpp
index e35664f..b884861 100644
--- a/parser/preprocessed/SqlParser_gen.hpp
+++ b/parser/preprocessed/SqlParser_gen.hpp
@@ -1,8 +1,8 @@
-/* A Bison parser, made by GNU Bison 3.0.2.  */
+/* A Bison parser, made by GNU Bison 3.0.4.  */
 
 /* Bison interface for Yacc-like parsers in C
 
-   Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
+   Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -164,10 +164,10 @@ extern int quickstep_yydebug;
 
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-typedef union YYSTYPE YYSTYPE;
+
 union YYSTYPE
 {
-#line 117 "../SqlParser.ypp" /* yacc.c:1909  */
+#line 118 "../SqlParser.ypp" /* yacc.c:1915  */
 
   quickstep::ParseString *string_value_;
 
@@ -203,6 +203,8 @@ union YYSTYPE
   quickstep::PtrList<quickstep::ParseTableReference> *table_reference_list_;
   quickstep::ParseTableReferenceSignature *table_reference_signature_;
 
+  quickstep::ParseJoinedTableReference::JoinType join_type_;
+
   quickstep::ParseDataType *data_type_;
   quickstep::ParseAttributeDefinition *attribute_definition_;
   quickstep::ParseColumnConstraint *column_constraint_;
@@ -257,8 +259,10 @@ union YYSTYPE
   quickstep::PtrVector<quickstep::ParseSubqueryTableReference> *with_list_;
   quickstep::ParseSubqueryTableReference *with_list_element_;
 
-#line 261 "SqlParser_gen.hpp" /* yacc.c:1909  */
+#line 263 "SqlParser_gen.hpp" /* yacc.c:1915  */
 };
+
+typedef union YYSTYPE YYSTYPE;
 # define YYSTYPE_IS_TRIVIAL 1
 # define YYSTYPE_IS_DECLARED 1
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/parser/tests/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/parser/tests/CMakeLists.txt b/parser/tests/CMakeLists.txt
index e9229e0..cea0f45 100644
--- a/parser/tests/CMakeLists.txt
+++ b/parser/tests/CMakeLists.txt
@@ -58,6 +58,10 @@ add_test(quickstep_parser_tests_ParserTest_insert
          quickstep_parser_tests_ParserTest
          "${CMAKE_CURRENT_SOURCE_DIR}/Insert.test"
          "${CMAKE_CURRENT_BINARY_DIR}/Insert.test")
+add_test(quickstep_parser_tests_ParserTest_join
+         quickstep_parser_tests_ParserTest
+         "${CMAKE_CURRENT_SOURCE_DIR}/Join.test"
+         "${CMAKE_CURRENT_BINARY_DIR}/Join.test")
 add_test(quickstep_parser_tests_ParserTest_select
          quickstep_parser_tests_ParserTest
          "${CMAKE_CURRENT_SOURCE_DIR}/Select.test"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/parser/tests/Join.test
----------------------------------------------------------------------
diff --git a/parser/tests/Join.test b/parser/tests/Join.test
new file mode 100644
index 0000000..8a252a4
--- /dev/null
+++ b/parser/tests/Join.test
@@ -0,0 +1,160 @@
+#   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.
+
+SELECT *
+FROM a JOIN b ON a.w = b.w
+       JOIN c ON a.x = c.x
+       JOIN d ON a.y = d.y;
+--
+SelectStatement
++-select_query=Select
+  +-select_clause=SelectStar
+  +-from_clause=
+    +-JoinedTable[join_type=InnerJoin]
+      +-left_table=JoinedTable[join_type=InnerJoin]
+      | +-left_table=JoinedTable[join_type=InnerJoin]
+      | | +-left_table=TableReference[table=a]
+      | | +-right_table=TableReference[table=b]
+      | | +-join_predicate=Equal
+      | |   +-left_operand=AttributeReference[attribute_name=w,relation_name=a]
+      | |   +-right_operand=AttributeReference[attribute_name=w,relation_name=b]
+      | +-right_table=TableReference[table=c]
+      | +-join_predicate=Equal
+      |   +-left_operand=AttributeReference[attribute_name=x,relation_name=a]
+      |   +-right_operand=AttributeReference[attribute_name=x,relation_name=c]
+      +-right_table=TableReference[table=d]
+      +-join_predicate=Equal
+        +-left_operand=AttributeReference[attribute_name=y,relation_name=a]
+        +-right_operand=AttributeReference[attribute_name=y,relation_name=d]
+==
+
+SELECT *
+FROM a AS a1 JOIN b AS b1 ON a1.w = b1.w
+             JOIN c AS c1 ON a1.x = c1.x
+             JOIN d AS d1 ON a1.y = d1.y;
+WHERE a1.x > b1.x
+  AND a1.y > c1.y
+  AND a1.z > d1.z;
+--
+SelectStatement
++-select_query=Select
+  +-select_clause=SelectStar
+  +-from_clause=
+    +-JoinedTable[join_type=InnerJoin]
+      +-left_table=JoinedTable[join_type=InnerJoin]
+      | +-left_table=JoinedTable[join_type=InnerJoin]
+      | | +-left_table=TableReference[table=a]
+      | | | +-table_signature=TableSignature[table_alias=a1]
+      | | +-right_table=TableReference[table=b]
+      | | | +-table_signature=TableSignature[table_alias=b1]
+      | | +-join_predicate=Equal
+      | |   +-left_operand=AttributeReference[attribute_name=w,relation_name=a1]
+      | |   +-right_operand=AttributeReference[attribute_name=w,relation_name=b1]
+      | +-right_table=TableReference[table=c]
+      | | +-table_signature=TableSignature[table_alias=c1]
+      | +-join_predicate=Equal
+      |   +-left_operand=AttributeReference[attribute_name=x,relation_name=a1]
+      |   +-right_operand=AttributeReference[attribute_name=x,relation_name=c1]
+      +-right_table=TableReference[table=d]
+      | +-table_signature=TableSignature[table_alias=d1]
+      +-join_predicate=Equal
+        +-left_operand=AttributeReference[attribute_name=y,relation_name=a1]
+        +-right_operand=AttributeReference[attribute_name=y,relation_name=d1]
+==
+
+SELECT *
+FROM a LEFT OUTER JOIN b ON a.w = b.w
+       RIGHT OUTER JOIN c ON a.x = c.x
+       FULL OUTER JOIN d ON a.y = d.y;
+--
+SelectStatement
++-select_query=Select
+  +-select_clause=SelectStar
+  +-from_clause=
+    +-JoinedTable[join_type=FullOuterJoin]
+      +-left_table=JoinedTable[join_type=RightOuterJoin]
+      | +-left_table=JoinedTable[join_type=LeftOuterJoin]
+      | | +-left_table=TableReference[table=a]
+      | | +-right_table=TableReference[table=b]
+      | | +-join_predicate=Equal
+      | |   +-left_operand=AttributeReference[attribute_name=w,relation_name=a]
+      | |   +-right_operand=AttributeReference[attribute_name=w,relation_name=b]
+      | +-right_table=TableReference[table=c]
+      | +-join_predicate=Equal
+      |   +-left_operand=AttributeReference[attribute_name=x,relation_name=a]
+      |   +-right_operand=AttributeReference[attribute_name=x,relation_name=c]
+      +-right_table=TableReference[table=d]
+      +-join_predicate=Equal
+        +-left_operand=AttributeReference[attribute_name=y,relation_name=a]
+        +-right_operand=AttributeReference[attribute_name=y,relation_name=d]
+==
+
+SELECT *
+FROM a INNER JOIN b ON (a.w = b.w OR a.x > b.y);
+--
+SelectStatement
++-select_query=Select
+  +-select_clause=SelectStar
+  +-from_clause=
+    +-JoinedTable[join_type=InnerJoin]
+      +-left_table=TableReference[table=a]
+      +-right_table=TableReference[table=b]
+      +-join_predicate=Or
+        +-Equal
+        | +-left_operand=AttributeReference[attribute_name=w,relation_name=a]
+        | +-right_operand=AttributeReference[attribute_name=w,relation_name=b]
+        +-Greater
+          +-left_operand=AttributeReference[attribute_name=x,relation_name=a]
+          +-right_operand=AttributeReference[attribute_name=y,relation_name=b]
+==
+
+SELECT *
+FROM b LEFT JOIN c ON b.x = c.x JOIN d ON c.y = d.y;
+--
+SelectStatement
++-select_query=Select
+  +-select_clause=SelectStar
+  +-from_clause=
+    +-JoinedTable[join_type=InnerJoin]
+      +-left_table=JoinedTable[join_type=LeftOuterJoin]
+      | +-left_table=TableReference[table=b]
+      | +-right_table=TableReference[table=c]
+      | +-join_predicate=Equal
+      |   +-left_operand=AttributeReference[attribute_name=x,relation_name=b]
+      |   +-right_operand=AttributeReference[attribute_name=x,relation_name=c]
+      +-right_table=TableReference[table=d]
+      +-join_predicate=Equal
+        +-left_operand=AttributeReference[attribute_name=y,relation_name=c]
+        +-right_operand=AttributeReference[attribute_name=y,relation_name=d]
+==
+
+SELECT *
+FROM b LEFT JOIN (c JOIN d ON c.y = d.y) ON b.x = c.x;
+--
+SelectStatement
++-select_query=Select
+  +-select_clause=SelectStar
+  +-from_clause=
+    +-JoinedTable[join_type=LeftOuterJoin]
+      +-left_table=TableReference[table=b]
+      +-right_table=JoinedTable[join_type=InnerJoin]
+      | +-left_table=TableReference[table=c]
+      | +-right_table=TableReference[table=d]
+      | +-join_predicate=Equal
+      |   +-left_operand=AttributeReference[attribute_name=y,relation_name=c]
+      |   +-right_operand=AttributeReference[attribute_name=y,relation_name=d]
+      +-join_predicate=Equal
+        +-left_operand=AttributeReference[attribute_name=x,relation_name=b]
+        +-right_operand=AttributeReference[attribute_name=x,relation_name=c]

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/parser/tests/TPCH.test
----------------------------------------------------------------------
diff --git a/parser/tests/TPCH.test b/parser/tests/TPCH.test
index dfcd6aa..2d12df5 100644
--- a/parser/tests/TPCH.test
+++ b/parser/tests/TPCH.test
@@ -1089,9 +1089,46 @@ ORDER BY
   custdist desc,
   c_count DESC
 --
-ERROR: OUTER JOIN is not supported yet (10 : 16)
-      customer LEFT OUTER JOIN orders ON
-               ^
+SelectStatement
++-select_query=Select
+  +-select_clause=SelectList
+  | +-SelectListItem
+  | | +-AttributeReference[attribute_name=c_count]
+  | +-SelectListItem[alias=custdist]
+  |   +-FunctionCall[name=COUNT,is_star=true]
+  +-group_by=GroupBy
+  | +-AttributeReference[attribute_name=c_count]
+  +-order_by=OrderBy
+  | +-OrderByItem[is_asc=false,nulls_first=true]
+  | | +-AttributeReference[attribute_name=custdist]
+  | +-OrderByItem[is_asc=false,nulls_first=true]
+  |   +-AttributeReference[attribute_name=c_count]
+  +-from_clause=
+    +-SubqueryTable
+      +-table_signature=TableSignature[table_alias=c_orders,
+      | columns=(c_custkey, c_count)]
+      +-SubqueryExpression
+        +-Select
+          +-select_clause=SelectList
+          | +-SelectListItem
+          | | +-AttributeReference[attribute_name=c_custkey]
+          | +-SelectListItem
+          |   +-FunctionCall[name=COUNT]
+          |     +-AttributeReference[attribute_name=o_orderkey]
+          +-group_by=GroupBy
+          | +-AttributeReference[attribute_name=c_custkey]
+          +-from_clause=
+            +-JoinedTable[join_type=LeftOuterJoin]
+              +-left_table=TableReference[table=customer]
+              +-right_table=TableReference[table=orders]
+              +-join_predicate=And
+                +-Equal
+                | +-left_operand=AttributeReference[attribute_name=c_custkey]
+                | +-right_operand=AttributeReference[attribute_name=o_custkey]
+                +-NotLike
+                  +-left_operand=AttributeReference[attribute_name=o_comment]
+                  +-right_operand=Literal
+                    +-StringLiteral[value=%special%requests%]
 ==
 
 # Query 14

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/query_optimizer/resolver/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/query_optimizer/resolver/CMakeLists.txt b/query_optimizer/resolver/CMakeLists.txt
index f8ffa72..854ace1 100644
--- a/query_optimizer/resolver/CMakeLists.txt
+++ b/query_optimizer/resolver/CMakeLists.txt
@@ -46,6 +46,7 @@ target_link_libraries(quickstep_queryoptimizer_resolver_Resolver
                       quickstep_parser_ParseGeneratorTableReference
                       quickstep_parser_ParseGroupBy
                       quickstep_parser_ParseHaving
+                      quickstep_parser_ParseJoinedTableReference
                       quickstep_parser_ParseLimit
                       quickstep_parser_ParseLiteralValue
                       quickstep_parser_ParseOrderBy

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/query_optimizer/resolver/NameResolver.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/resolver/NameResolver.cpp b/query_optimizer/resolver/NameResolver.cpp
index 35745f3..9833f56 100644
--- a/query_optimizer/resolver/NameResolver.cpp
+++ b/query_optimizer/resolver/NameResolver.cpp
@@ -121,6 +121,23 @@ E::AttributeReferencePtr NameResolver::lookup(
   return attribute;
 }
 
+void NameResolver::merge(NameResolver *other) {
+  // Check whether there is any conflict name with the input name resolver.
+  for (const auto &scoped_rel_info : other->rel_name_to_rel_info_map_) {
+    const std::string &rel_name = scoped_rel_info.first;
+    if (rel_name_to_rel_info_map_.find(rel_name) != rel_name_to_rel_info_map_.end()) {
+      THROW_SQL_ERROR_AT(&scoped_rel_info.second->parse_relation_name)
+          << "Relation alias " << rel_name << " appears more than once";
+    }
+  }
+
+  for (std::unique_ptr<RelationInfo> &scoped_relation : other->relations_) {
+    relations_.emplace_back(scoped_relation.release());
+  }
+  rel_name_to_rel_info_map_.insert(other->rel_name_to_rel_info_map_.begin(),
+                                   other->rel_name_to_rel_info_map_.end());
+}
+
 std::vector<E::AttributeReferencePtr> NameResolver::getVisibleAttributeReferences() const {
   std::vector<E::AttributeReferencePtr> referenced_attributes;
   for (const std::unique_ptr<RelationInfo> &rel : relations_) {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/query_optimizer/resolver/NameResolver.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/resolver/NameResolver.hpp b/query_optimizer/resolver/NameResolver.hpp
index 6aed904..ea3f1e4 100644
--- a/query_optimizer/resolver/NameResolver.hpp
+++ b/query_optimizer/resolver/NameResolver.hpp
@@ -86,6 +86,15 @@ class NameResolver {
       const ParseString *parse_rel_node) const;
 
   /**
+   * @brief Combines the name scopes in the current name resolver and in \p other.
+   *        The ownership of <relations_> in \p other will be transferred to the
+   *        current name resolver.
+   *
+   * @param other The name resolver to be merged into this resolver.
+   */
+  void merge(NameResolver *other);
+
+  /**
    * @return All AttributeReferences in the current name scope.
    */
   std::vector<expressions::AttributeReferencePtr> getVisibleAttributeReferences() const;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/query_optimizer/resolver/Resolver.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/resolver/Resolver.cpp b/query_optimizer/resolver/Resolver.cpp
index 8323c33..242a1f0 100644
--- a/query_optimizer/resolver/Resolver.cpp
+++ b/query_optimizer/resolver/Resolver.cpp
@@ -42,6 +42,7 @@
 #include "parser/ParseGeneratorTableReference.hpp"
 #include "parser/ParseGroupBy.hpp"
 #include "parser/ParseHaving.hpp"
+#include "parser/ParseJoinedTableReference.hpp"
 #include "parser/ParseLimit.hpp"
 #include "parser/ParseLiteralValue.hpp"
 #include "parser/ParseOrderBy.hpp"
@@ -1467,6 +1468,16 @@ L::LogicalPtr Resolver::resolveTableReference(const ParseTableReference &table_r
       name_resolver->addRelation(reference_alias, logical_plan);
       break;
     }
+    case ParseTableReference::kJoinedTableReference: {
+      NameResolver joined_table_name_resolver;
+
+      logical_plan = resolveJoinedTableReference(
+          static_cast<const ParseJoinedTableReference&>(table_reference),
+          &joined_table_name_resolver);
+
+      name_resolver->merge(&joined_table_name_resolver);
+      break;
+    }
     default:
       LOG(FATAL) << "Unhandeled table reference " << table_reference.toString();
   }
@@ -1592,6 +1603,29 @@ L::LogicalPtr Resolver::resolveGeneratorTableReference(
 }
 
 
+L::LogicalPtr Resolver::resolveJoinedTableReference(
+    const ParseJoinedTableReference &joined_table_reference,
+    NameResolver *name_resolver) {
+  const L::LogicalPtr left_table =
+      resolveTableReference(*joined_table_reference.left_table(), name_resolver);
+  const L::LogicalPtr right_table =
+      resolveTableReference(*joined_table_reference.right_table(), name_resolver);
+
+  ExpressionResolutionInfo resolution_info(*name_resolver,
+                                           "join clause" /* clause_name */,
+                                           nullptr /* select_list_info */);
+  const E::PredicatePtr on_predicate =
+      resolvePredicate(*joined_table_reference.join_predicate(), &resolution_info);
+
+  if (joined_table_reference.join_type() == ParseJoinedTableReference::JoinType::kInnerJoin) {
+    return L::Filter::Create(
+        L::MultiwayCartesianJoin::Create({ left_table, right_table }),
+        on_predicate);
+  }
+
+  THROW_SQL_ERROR_AT(&joined_table_reference) << "Outer joins are not supported yet";
+}
+
 void Resolver::resolveSelectClause(
     const ParseSelectionClause &parse_selection,
     const std::string &select_name,

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/query_optimizer/resolver/Resolver.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/resolver/Resolver.hpp b/query_optimizer/resolver/Resolver.hpp
index 31afe18..a84c61c 100644
--- a/query_optimizer/resolver/Resolver.hpp
+++ b/query_optimizer/resolver/Resolver.hpp
@@ -41,6 +41,7 @@ class Comparison;
 class ParseExpression;
 class ParseFunctionCall;
 class ParseGeneratorTableReference;
+class ParseJoinedTableReference;
 class ParseOrderBy;
 class ParsePredicate;
 class ParseSearchedCaseExpression;
@@ -333,6 +334,19 @@ class Resolver {
       const ParseString *reference_alias);
 
   /**
+   * @brief Resolves a joined table resulting from a join between two table
+   *        references.
+   *
+   * @param joined_table_reference The parse joined table reference to be resolved.
+   * @param name_resolver The name resolver to be updated with the left and the
+   *        right tables.
+   * @return A logical plan for the joined table reference.
+   */
+  logical::LogicalPtr resolveJoinedTableReference(
+      const ParseJoinedTableReference &joined_table_reference,
+      NameResolver *name_resolver);
+
+  /**
    * @brief Renames the output columns from \p logical_plan based on the table signature
    *        by wrapping it with a Project.
    *

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/query_optimizer/tests/OptimizerTextTestRunner.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/OptimizerTextTestRunner.hpp b/query_optimizer/tests/OptimizerTextTestRunner.hpp
index ee1967a..7904ac3 100644
--- a/query_optimizer/tests/OptimizerTextTestRunner.hpp
+++ b/query_optimizer/tests/OptimizerTextTestRunner.hpp
@@ -51,6 +51,7 @@ class OptimizerTextTestRunner : public TextBasedTestRunner {
    */
   OptimizerTextTestRunner() {
     test_database_loader_.createTestRelation(true /* allow_vchar */);
+    test_database_loader_.createJoinRelations();
   }
 
   void runTestCase(const std::string &input,

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/query_optimizer/tests/TestDatabaseLoader.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/TestDatabaseLoader.cpp b/query_optimizer/tests/TestDatabaseLoader.cpp
index 05907b3..2de69b6 100644
--- a/query_optimizer/tests/TestDatabaseLoader.cpp
+++ b/query_optimizer/tests/TestDatabaseLoader.cpp
@@ -18,6 +18,7 @@
 #include "query_optimizer/tests/TestDatabaseLoader.hpp"
 
 #include <cmath>
+#include <cstddef>
 #include <cstdint>
 #include <memory>
 #include <string>
@@ -84,6 +85,35 @@ CatalogRelation *TestDatabaseLoader::createTestRelation(bool allow_vchar) {
   return test_relation_;
 }
 
+void TestDatabaseLoader::createJoinRelations() {
+  std::vector<std::string> rel_names = { "a", "b", "c", "d" };
+  std::vector<std::vector<std::pair<std::string, TypeID>>> rel_columns = {
+      { { "w", kInt }, { "x", kInt }, { "y", kInt }, { "z", kInt } },
+      { { "w", kInt }, { "x", kInt } },
+      { { "x", kInt }, { "y", kInt } },
+      { { "y", kInt }, { "z", kInt } }
+  };
+
+  for (std::size_t rel_idx = 0; rel_idx < rel_names.size(); ++rel_idx) {
+    std::unique_ptr<CatalogRelation> relation(
+        new CatalogRelation(&catalog_database_,
+                            rel_names[rel_idx],
+                            -1 /* id */,
+                            true /* temporary */));
+
+    const std::vector<std::pair<std::string, TypeID>> &columns = rel_columns[rel_idx];
+    int attr_id = -1;
+    for (std::size_t col_idx = 0; col_idx < columns.size(); ++col_idx) {
+      relation->addAttribute(new CatalogAttribute(
+          relation.get(),
+          columns[col_idx].first,
+          TypeFactory::GetType(columns[col_idx].second),
+          ++attr_id));
+    }
+    catalog_database_.addRelation(relation.release());
+  }
+}
+
 void TestDatabaseLoader::loadTestRelation() {
   CHECK(test_relation_ != nullptr);
   CHECK(!test_relation_->hasAttributeWithName("vchar_col"));

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/query_optimizer/tests/TestDatabaseLoader.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/TestDatabaseLoader.hpp b/query_optimizer/tests/TestDatabaseLoader.hpp
index 27ef650..80dbfd2 100644
--- a/query_optimizer/tests/TestDatabaseLoader.hpp
+++ b/query_optimizer/tests/TestDatabaseLoader.hpp
@@ -111,6 +111,14 @@ class TestDatabaseLoader {
   CatalogRelation* createTestRelation(bool allow_vchar);
 
   /**
+   * @brief Creates four relations a(w INT, x INT, y INT, z INT), b(w INT, x INT),
+   *        c(x INT, y INT) and d(y INT, z INT) for testing JOINs. The created
+   *        relations are stored inside \p catalog_database_.
+   * @warning This can only be called once.
+   */
+  void createJoinRelations();
+
+  /**
    * @brief Loads data into the test relation. The test relation has 25 tuples.
    *        Each tuple is
    *           ((-1)^x*x, x^2, sqrt(x), (-1)^x*x*sqrt(x),

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/query_optimizer/tests/execution_generator/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/execution_generator/CMakeLists.txt b/query_optimizer/tests/execution_generator/CMakeLists.txt
index d70ea4c..149721c 100644
--- a/query_optimizer/tests/execution_generator/CMakeLists.txt
+++ b/query_optimizer/tests/execution_generator/CMakeLists.txt
@@ -43,6 +43,11 @@ add_test(quickstep_queryoptimizer_tests_executiongenerator_insert
          "${CMAKE_CURRENT_SOURCE_DIR}/Insert.test"
          "${CMAKE_CURRENT_BINARY_DIR}/Insert.test"
          "${CMAKE_CURRENT_BINARY_DIR}/Insert/")
+add_test(quickstep_queryoptimizer_tests_executiongenerator_join
+         "../quickstep_queryoptimizer_tests_ExecutionGeneratorTest"
+         "${CMAKE_CURRENT_SOURCE_DIR}/Join.test"
+         "${CMAKE_CURRENT_BINARY_DIR}/Join.test"
+         "${CMAKE_CURRENT_BINARY_DIR}/Join/")
 add_test(quickstep_queryoptimizer_tests_executiongenerator_select
          "../quickstep_queryoptimizer_tests_ExecutionGeneratorTest"
          "${CMAKE_CURRENT_SOURCE_DIR}/Select.test"
@@ -72,6 +77,7 @@ file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Distinct)
 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Drop)
 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Index)
 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Insert)
+file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Join)
 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/Select)
 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/StringPatternMatching)
 file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/TableGenerator)

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/query_optimizer/tests/execution_generator/Join.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/execution_generator/Join.test b/query_optimizer/tests/execution_generator/Join.test
new file mode 100644
index 0000000..6d6d2e1
--- /dev/null
+++ b/query_optimizer/tests/execution_generator/Join.test
@@ -0,0 +1,132 @@
+#   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.
+
+# Prepare testing relations
+CREATE TABLE a(w INT, x LONG, y DOUBLE, z VARCHAR(16));
+CREATE TABLE b(w INT, x LONG);
+CREATE TABLE c(x LONG, y DOUBLE);
+CREATE TABLE d(y DOUBLE, z VARCHAR(16));
+
+INSERT INTO a VALUES(0, 0, 0, 'C0');
+INSERT INTO a VALUES(1, 10, 100, 'C1');
+INSERT INTO a VALUES(2, 20, 200, 'C2');
+INSERT INTO a VALUES(3, 30, 300, 'C3');
+INSERT INTO a VALUES(4, 40, 400, 'C4');
+INSERT INTO a VALUES(5, 50, 500, 'C5');
+INSERT INTO a VALUES(6, 60, 600, 'C6');
+INSERT INTO a VALUES(7, 70, 700, 'C7');
+INSERT INTO a VALUES(8, 80, 800, 'C8');
+INSERT INTO a VALUES(9, 90, 900, 'C9');
+INSERT INTO a VALUES(10, 100, 1000, 'C10');
+INSERT INTO a VALUES(11, 110, 1100, 'C11');
+INSERT INTO a VALUES(12, 120, 1200, 'C12');
+INSERT INTO a VALUES(13, 130, 1300, 'C13');
+INSERT INTO a VALUES(14, 140, 1400, 'C14');
+INSERT INTO a VALUES(15, 150, 1500, 'C15');
+INSERT INTO a VALUES(16, 160, 1600, 'C16');
+INSERT INTO a VALUES(17, 170, 1700, 'C17');
+INSERT INTO a VALUES(18, 180, 1800, 'C18');
+INSERT INTO a VALUES(19, 190, 1900, 'C19');
+
+INSERT INTO b
+SELECT w, x + (w/2)%2
+FROM a
+WHERE w % 2 = 0;
+
+INSERT INTO c
+SELECT x, y + (x/3)%3-1
+FROM a
+WHERE x % 3 = 0;
+
+INSERT INTO d
+SELECT y, z
+FROM a;
+--
+==
+
+
+# Join queries
+SELECT a.w, b.x, c.y, d.z
+FROM a JOIN b ON a.w = b.w
+       JOIN c ON a.x = c.x
+       JOIN d ON a.y = d.y;
+--
++-----------+--------------------+------------------------+----------------+
+|w          |x                   |y                       |z               |
++-----------+--------------------+------------------------+----------------+
+|          0|                   0|                      -1|              C0|
+|          6|                  61|                     601|              C6|
+|         12|                 120|                    1200|             C12|
+|         18|                 181|                    1799|             C18|
++-----------+--------------------+------------------------+----------------+
+==
+
+SELECT a.w, b.x, c.y
+FROM a JOIN b ON (a.w = b.w OR a.x > b.x)
+       JOIN c ON (a.x = c.x AND a.y > c.y)
+       JOIN d ON (a.y = d.y OR a.z > d.z)
+GROUP BY a.w, b.x, c.y
+ORDER BY a.w, b.x, c.y;
+--
++-----------+--------------------+------------------------+
+|w          |x                   |y                       |
++-----------+--------------------+------------------------+
+|          0|                   0|                      -1|
+|          9|                   0|                     899|
+|          9|                  21|                     899|
+|          9|                  40|                     899|
+|          9|                  61|                     899|
+|          9|                  80|                     899|
+|         18|                   0|                    1799|
+|         18|                  21|                    1799|
+|         18|                  40|                    1799|
+|         18|                  61|                    1799|
+|         18|                  80|                    1799|
+|         18|                 101|                    1799|
+|         18|                 120|                    1799|
+|         18|                 141|                    1799|
+|         18|                 160|                    1799|
+|         18|                 181|                    1799|
++-----------+--------------------+------------------------+
+==
+
+SELECT a1.w, b1.x, c1.y, d1.z
+FROM a AS a1 JOIN b AS b1 ON a1.w = b1.w
+             JOIN c AS c1 ON a1.x = c1.x
+             JOIN d AS d1 ON a1.y = d1.y
+WHERE a1.x = b1.x
+  AND a1.y = c1.y
+  AND a1.z = d1.z;
+--
++-----------+--------------------+------------------------+----------------+
+|w          |x                   |y                       |z               |
++-----------+--------------------+------------------------+----------------+
+|         12|                 120|                    1200|             C12|
++-----------+--------------------+------------------------+----------------+
+==
+
+SELECT a1.w, b1.x, c1.y, d1.z
+FROM a AS a1 JOIN b AS b1 ON a1.x <> b1.x
+             JOIN c AS c1 ON a1.y <> c1.y
+             JOIN d AS d1 ON a1.z = d1.z
+WHERE a1.w = b1.w
+  AND a1.x = c1.x;
+--
++-----------+--------------------+------------------------+----------------+
+|w          |x                   |y                       |z               |
++-----------+--------------------+------------------------+----------------+
+|          6|                  61|                     601|              C6|
+|         18|                 181|                    1799|             C18|
++-----------+--------------------+------------------------+----------------+

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/query_optimizer/tests/logical_generator/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/logical_generator/CMakeLists.txt b/query_optimizer/tests/logical_generator/CMakeLists.txt
index 08aba11..4edddfa 100644
--- a/query_optimizer/tests/logical_generator/CMakeLists.txt
+++ b/query_optimizer/tests/logical_generator/CMakeLists.txt
@@ -17,12 +17,14 @@ add_test(quickstep_queryoptimizer_tests_logicalgenerator_create
          "../quickstep_queryoptimizer_tests_OptimizerTextTest"
          "${CMAKE_CURRENT_SOURCE_DIR}/Create.test"
          "${CMAKE_CURRENT_BINARY_DIR}/Create.test")
-
- add_test(quickstep_queryoptimizer_tests_logicalgenerator_index
-          "../quickstep_queryoptimizer_tests_OptimizerTextTest"
-          "${CMAKE_CURRENT_SOURCE_DIR}/Index.test"
-          "${CMAKE_CURRENT_BINARY_DIR}/Index.test")
-
+add_test(quickstep_queryoptimizer_tests_logicalgenerator_index
+         "../quickstep_queryoptimizer_tests_OptimizerTextTest"
+         "${CMAKE_CURRENT_SOURCE_DIR}/Index.test"
+         "${CMAKE_CURRENT_BINARY_DIR}/Index.test")
+add_test(quickstep_queryoptimizer_tests_logicalgenerator_join
+         "../quickstep_queryoptimizer_tests_OptimizerTextTest"
+         "${CMAKE_CURRENT_SOURCE_DIR}/Join.test"
+         "${CMAKE_CURRENT_BINARY_DIR}/Join.test")
 add_test(quickstep_queryoptimizer_tests_logicalgenerator_select
         "../quickstep_queryoptimizer_tests_OptimizerTextTest"
         "${CMAKE_CURRENT_SOURCE_DIR}/Select.test"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/query_optimizer/tests/logical_generator/Join.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/logical_generator/Join.test b/query_optimizer/tests/logical_generator/Join.test
new file mode 100644
index 0000000..d48df4c
--- /dev/null
+++ b/query_optimizer/tests/logical_generator/Join.test
@@ -0,0 +1,217 @@
+#   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.
+
+[default optimized_logical_plan]
+
+SELECT a.z
+FROM a JOIN b ON a.w = b.w
+       JOIN c ON a.x = c.x
+       JOIN d ON a.y = d.y;
+--
+TopLevelPlan
++-plan=Project
+| +-input=HashJoin
+| | +-left=HashJoin
+| | | +-left=HashJoin
+| | | | +-left=TableReference[relation_name=a]
+| | | | | +-AttributeReference[id=0,name=w,relation=a,type=Int]
+| | | | | +-AttributeReference[id=1,name=x,relation=a,type=Int]
+| | | | | +-AttributeReference[id=2,name=y,relation=a,type=Int]
+| | | | | +-AttributeReference[id=3,name=z,relation=a,type=Int]
+| | | | +-right=TableReference[relation_name=b]
+| | | | | +-AttributeReference[id=4,name=w,relation=b,type=Int]
+| | | | | +-AttributeReference[id=5,name=x,relation=b,type=Int]
+| | | | +-left_join_attributes=
+| | | | | +-AttributeReference[id=0,name=w,relation=a,type=Int]
+| | | | +-right_join_attributes=
+| | | |   +-AttributeReference[id=4,name=w,relation=b,type=Int]
+| | | +-right=TableReference[relation_name=c]
+| | | | +-AttributeReference[id=6,name=x,relation=c,type=Int]
+| | | | +-AttributeReference[id=7,name=y,relation=c,type=Int]
+| | | +-left_join_attributes=
+| | | | +-AttributeReference[id=1,name=x,relation=a,type=Int]
+| | | +-right_join_attributes=
+| | |   +-AttributeReference[id=6,name=x,relation=c,type=Int]
+| | +-right=TableReference[relation_name=d]
+| | | +-AttributeReference[id=8,name=y,relation=d,type=Int]
+| | | +-AttributeReference[id=9,name=z,relation=d,type=Int]
+| | +-left_join_attributes=
+| | | +-AttributeReference[id=2,name=y,relation=a,type=Int]
+| | +-right_join_attributes=
+| |   +-AttributeReference[id=8,name=y,relation=d,type=Int]
+| +-project_list=
+|   +-AttributeReference[id=3,name=z,relation=a,type=Int]
++-output_attributes=
+  +-AttributeReference[id=3,name=z,relation=a,type=Int]
+==
+
+SELECT a.z
+FROM a JOIN b ON (a.w = b.w OR a.x > b.x)
+       JOIN c ON (a.x = c.x AND a.y > c.y)
+       JOIN d ON (a.y = d.y OR a.z > d.z);
+--
+TopLevelPlan
++-plan=Project
+| +-input=NestedLoopsJoin
+| | +-left=Filter
+| | | +-input=HashJoin
+| | | | +-left=NestedLoopsJoin
+| | | | | +-left=TableReference[relation_name=a]
+| | | | | | +-AttributeReference[id=0,name=w,relation=a,type=Int]
+| | | | | | +-AttributeReference[id=1,name=x,relation=a,type=Int]
+| | | | | | +-AttributeReference[id=2,name=y,relation=a,type=Int]
+| | | | | | +-AttributeReference[id=3,name=z,relation=a,type=Int]
+| | | | | +-right=TableReference[relation_name=b]
+| | | | | | +-AttributeReference[id=4,name=w,relation=b,type=Int]
+| | | | | | +-AttributeReference[id=5,name=x,relation=b,type=Int]
+| | | | | +-join_predicate=Or
+| | | | |   +-Equal
+| | | | |   | +-AttributeReference[id=0,name=w,relation=a,type=Int]
+| | | | |   | +-AttributeReference[id=4,name=w,relation=b,type=Int]
+| | | | |   +-Greater
+| | | | |     +-AttributeReference[id=1,name=x,relation=a,type=Int]
+| | | | |     +-AttributeReference[id=5,name=x,relation=b,type=Int]
+| | | | +-right=TableReference[relation_name=c]
+| | | | | +-AttributeReference[id=6,name=x,relation=c,type=Int]
+| | | | | +-AttributeReference[id=7,name=y,relation=c,type=Int]
+| | | | +-left_join_attributes=
+| | | | | +-AttributeReference[id=1,name=x,relation=a,type=Int]
+| | | | +-right_join_attributes=
+| | | |   +-AttributeReference[id=6,name=x,relation=c,type=Int]
+| | | +-filter_predicate=Greater
+| | |   +-AttributeReference[id=2,name=y,relation=a,type=Int]
+| | |   +-AttributeReference[id=7,name=y,relation=c,type=Int]
+| | +-right=TableReference[relation_name=d]
+| | | +-AttributeReference[id=8,name=y,relation=d,type=Int]
+| | | +-AttributeReference[id=9,name=z,relation=d,type=Int]
+| | +-join_predicate=Or
+| |   +-Equal
+| |   | +-AttributeReference[id=2,name=y,relation=a,type=Int]
+| |   | +-AttributeReference[id=8,name=y,relation=d,type=Int]
+| |   +-Greater
+| |     +-AttributeReference[id=3,name=z,relation=a,type=Int]
+| |     +-AttributeReference[id=9,name=z,relation=d,type=Int]
+| +-project_list=
+|   +-AttributeReference[id=3,name=z,relation=a,type=Int]
++-output_attributes=
+  +-AttributeReference[id=3,name=z,relation=a,type=Int]
+==
+
+SELECT a1.z
+FROM a AS a1 JOIN b AS b1 ON a1.w = b1.w
+             JOIN c AS c1 ON a1.x = c1.x
+             JOIN d AS d1 ON a1.y = d1.y
+WHERE a1.x = b1.x
+  AND a1.y = c1.y
+  AND a1.z = d1.z;
+--
+TopLevelPlan
++-plan=Project
+| +-input=HashJoin
+| | +-left=HashJoin
+| | | +-left=HashJoin
+| | | | +-left=TableReference[relation_name=a,relation_alias=a1]
+| | | | | +-AttributeReference[id=0,name=w,relation=a1,type=Int]
+| | | | | +-AttributeReference[id=1,name=x,relation=a1,type=Int]
+| | | | | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
+| | | | | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
+| | | | +-right=TableReference[relation_name=b,relation_alias=b1]
+| | | | | +-AttributeReference[id=4,name=w,relation=b1,type=Int]
+| | | | | +-AttributeReference[id=5,name=x,relation=b1,type=Int]
+| | | | +-left_join_attributes=
+| | | | | +-AttributeReference[id=1,name=x,relation=a1,type=Int]
+| | | | | +-AttributeReference[id=0,name=w,relation=a1,type=Int]
+| | | | +-right_join_attributes=
+| | | |   +-AttributeReference[id=5,name=x,relation=b1,type=Int]
+| | | |   +-AttributeReference[id=4,name=w,relation=b1,type=Int]
+| | | +-right=TableReference[relation_name=c,relation_alias=c1]
+| | | | +-AttributeReference[id=6,name=x,relation=c1,type=Int]
+| | | | +-AttributeReference[id=7,name=y,relation=c1,type=Int]
+| | | +-left_join_attributes=
+| | | | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
+| | | | +-AttributeReference[id=1,name=x,relation=a1,type=Int]
+| | | +-right_join_attributes=
+| | |   +-AttributeReference[id=7,name=y,relation=c1,type=Int]
+| | |   +-AttributeReference[id=6,name=x,relation=c1,type=Int]
+| | +-right=TableReference[relation_name=d,relation_alias=d1]
+| | | +-AttributeReference[id=8,name=y,relation=d1,type=Int]
+| | | +-AttributeReference[id=9,name=z,relation=d1,type=Int]
+| | +-left_join_attributes=
+| | | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
+| | | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
+| | +-right_join_attributes=
+| |   +-AttributeReference[id=9,name=z,relation=d1,type=Int]
+| |   +-AttributeReference[id=8,name=y,relation=d1,type=Int]
+| +-project_list=
+|   +-AttributeReference[id=3,name=z,relation=a1,type=Int]
++-output_attributes=
+  +-AttributeReference[id=3,name=z,relation=a1,type=Int]
+==
+
+SELECT a1.z
+FROM a AS a1 JOIN b AS b1 ON a1.w <> b1.w
+             JOIN c AS c1 ON a1.x <> c1.x
+             JOIN d AS d1 ON a1.y <> d1.y
+WHERE a1.x = b1.x
+  AND a1.y = c1.y
+  AND a1.z = d1.z;
+--
+TopLevelPlan
++-plan=Project
+| +-input=Filter
+| | +-input=HashJoin
+| | | +-left=Filter
+| | | | +-input=HashJoin
+| | | | | +-left=Filter
+| | | | | | +-input=HashJoin
+| | | | | | | +-left=TableReference[relation_name=a,relation_alias=a1]
+| | | | | | | | +-AttributeReference[id=0,name=w,relation=a1,type=Int]
+| | | | | | | | +-AttributeReference[id=1,name=x,relation=a1,type=Int]
+| | | | | | | | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
+| | | | | | | | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
+| | | | | | | +-right=TableReference[relation_name=b,relation_alias=b1]
+| | | | | | | | +-AttributeReference[id=4,name=w,relation=b1,type=Int]
+| | | | | | | | +-AttributeReference[id=5,name=x,relation=b1,type=Int]
+| | | | | | | +-left_join_attributes=
+| | | | | | | | +-AttributeReference[id=1,name=x,relation=a1,type=Int]
+| | | | | | | +-right_join_attributes=
+| | | | | | |   +-AttributeReference[id=5,name=x,relation=b1,type=Int]
+| | | | | | +-filter_predicate=NotEqual
+| | | | | |   +-AttributeReference[id=0,name=w,relation=a1,type=Int]
+| | | | | |   +-AttributeReference[id=4,name=w,relation=b1,type=Int]
+| | | | | +-right=TableReference[relation_name=c,relation_alias=c1]
+| | | | | | +-AttributeReference[id=6,name=x,relation=c1,type=Int]
+| | | | | | +-AttributeReference[id=7,name=y,relation=c1,type=Int]
+| | | | | +-left_join_attributes=
+| | | | | | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
+| | | | | +-right_join_attributes=
+| | | | |   +-AttributeReference[id=7,name=y,relation=c1,type=Int]
+| | | | +-filter_predicate=NotEqual
+| | | |   +-AttributeReference[id=1,name=x,relation=a1,type=Int]
+| | | |   +-AttributeReference[id=6,name=x,relation=c1,type=Int]
+| | | +-right=TableReference[relation_name=d,relation_alias=d1]
+| | | | +-AttributeReference[id=8,name=y,relation=d1,type=Int]
+| | | | +-AttributeReference[id=9,name=z,relation=d1,type=Int]
+| | | +-left_join_attributes=
+| | | | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
+| | | +-right_join_attributes=
+| | |   +-AttributeReference[id=9,name=z,relation=d1,type=Int]
+| | +-filter_predicate=NotEqual
+| |   +-AttributeReference[id=2,name=y,relation=a1,type=Int]
+| |   +-AttributeReference[id=8,name=y,relation=d1,type=Int]
+| +-project_list=
+|   +-AttributeReference[id=3,name=z,relation=a1,type=Int]
++-output_attributes=
+  +-AttributeReference[id=3,name=z,relation=a1,type=Int]

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/query_optimizer/tests/physical_generator/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/physical_generator/CMakeLists.txt b/query_optimizer/tests/physical_generator/CMakeLists.txt
index c01b133..abc6d9b 100644
--- a/query_optimizer/tests/physical_generator/CMakeLists.txt
+++ b/query_optimizer/tests/physical_generator/CMakeLists.txt
@@ -37,6 +37,10 @@ add_test(quickstep_queryoptimizer_tests_physicalgenerator_insert
          "../quickstep_queryoptimizer_tests_OptimizerTextTest"
          "${CMAKE_CURRENT_SOURCE_DIR}/Insert.test"
          "${CMAKE_CURRENT_BINARY_DIR}/Insert.test")
+add_test(quickstep_queryoptimizer_tests_physicalgenerator_join
+         "../quickstep_queryoptimizer_tests_OptimizerTextTest"
+         "${CMAKE_CURRENT_SOURCE_DIR}/Join.test"
+         "${CMAKE_CURRENT_BINARY_DIR}/Join.test")
 add_test(quickstep_queryoptimizer_tests_physicalgenerator_select
          "../quickstep_queryoptimizer_tests_OptimizerTextTest"
          "${CMAKE_CURRENT_SOURCE_DIR}/Select.test"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/query_optimizer/tests/physical_generator/Join.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/physical_generator/Join.test b/query_optimizer/tests/physical_generator/Join.test
new file mode 100644
index 0000000..c1f49b0
--- /dev/null
+++ b/query_optimizer/tests/physical_generator/Join.test
@@ -0,0 +1,237 @@
+#   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.
+
+[default physical_plan]
+
+SELECT a.z
+FROM a JOIN b ON a.w = b.w
+       JOIN c ON a.x = c.x
+       JOIN d ON a.y = d.y;
+--
+TopLevelPlan
++-plan=HashJoin
+| +-left=HashJoin
+| | +-left=HashJoin
+| | | +-left=TableReference[relation=a]
+| | | | +-AttributeReference[id=0,name=w,relation=a,type=Int]
+| | | | +-AttributeReference[id=1,name=x,relation=a,type=Int]
+| | | | +-AttributeReference[id=2,name=y,relation=a,type=Int]
+| | | | +-AttributeReference[id=3,name=z,relation=a,type=Int]
+| | | +-right=TableReference[relation=b]
+| | | | +-AttributeReference[id=4,name=w,relation=b,type=Int]
+| | | | +-AttributeReference[id=5,name=x,relation=b,type=Int]
+| | | +-project_expressions=
+| | | | +-AttributeReference[id=1,name=x,relation=a,type=Int]
+| | | | +-AttributeReference[id=2,name=y,relation=a,type=Int]
+| | | | +-AttributeReference[id=3,name=z,relation=a,type=Int]
+| | | +-left_join_attributes=
+| | | | +-AttributeReference[id=0,name=w,relation=a,type=Int]
+| | | +-right_join_attributes=
+| | |   +-AttributeReference[id=4,name=w,relation=b,type=Int]
+| | +-right=TableReference[relation=c]
+| | | +-AttributeReference[id=6,name=x,relation=c,type=Int]
+| | | +-AttributeReference[id=7,name=y,relation=c,type=Int]
+| | +-project_expressions=
+| | | +-AttributeReference[id=2,name=y,relation=a,type=Int]
+| | | +-AttributeReference[id=3,name=z,relation=a,type=Int]
+| | +-left_join_attributes=
+| | | +-AttributeReference[id=1,name=x,relation=a,type=Int]
+| | +-right_join_attributes=
+| |   +-AttributeReference[id=6,name=x,relation=c,type=Int]
+| +-right=TableReference[relation=d]
+| | +-AttributeReference[id=8,name=y,relation=d,type=Int]
+| | +-AttributeReference[id=9,name=z,relation=d,type=Int]
+| +-project_expressions=
+| | +-AttributeReference[id=3,name=z,relation=a,type=Int]
+| +-left_join_attributes=
+| | +-AttributeReference[id=2,name=y,relation=a,type=Int]
+| +-right_join_attributes=
+|   +-AttributeReference[id=8,name=y,relation=d,type=Int]
++-output_attributes=
+  +-AttributeReference[id=3,name=z,relation=a,type=Int]
+==
+
+SELECT a.z
+FROM a JOIN b ON (a.w = b.w OR a.x > b.x)
+       JOIN c ON (a.x = c.x AND a.y > c.y)
+       JOIN d ON (a.y = d.y OR a.z > d.z);
+--
+TopLevelPlan
++-plan=NestedLoopsJoin
+| +-left=HashJoin
+| | +-left=NestedLoopsJoin
+| | | +-left=TableReference[relation=a]
+| | | | +-AttributeReference[id=0,name=w,relation=a,type=Int]
+| | | | +-AttributeReference[id=1,name=x,relation=a,type=Int]
+| | | | +-AttributeReference[id=2,name=y,relation=a,type=Int]
+| | | | +-AttributeReference[id=3,name=z,relation=a,type=Int]
+| | | +-right=TableReference[relation=b]
+| | | | +-AttributeReference[id=4,name=w,relation=b,type=Int]
+| | | | +-AttributeReference[id=5,name=x,relation=b,type=Int]
+| | | +-join_predicate=Or
+| | | | +-Equal
+| | | | | +-AttributeReference[id=0,name=w,relation=a,type=Int]
+| | | | | +-AttributeReference[id=4,name=w,relation=b,type=Int]
+| | | | +-Greater
+| | | |   +-AttributeReference[id=1,name=x,relation=a,type=Int]
+| | | |   +-AttributeReference[id=5,name=x,relation=b,type=Int]
+| | | +-project_expressions=
+| | |   +-AttributeReference[id=1,name=x,relation=a,type=Int]
+| | |   +-AttributeReference[id=2,name=y,relation=a,type=Int]
+| | |   +-AttributeReference[id=3,name=z,relation=a,type=Int]
+| | +-right=TableReference[relation=c]
+| | | +-AttributeReference[id=6,name=x,relation=c,type=Int]
+| | | +-AttributeReference[id=7,name=y,relation=c,type=Int]
+| | +-residual_predicate=Greater
+| | | +-AttributeReference[id=2,name=y,relation=a,type=Int]
+| | | +-AttributeReference[id=7,name=y,relation=c,type=Int]
+| | +-project_expressions=
+| | | +-AttributeReference[id=2,name=y,relation=a,type=Int]
+| | | +-AttributeReference[id=3,name=z,relation=a,type=Int]
+| | +-left_join_attributes=
+| | | +-AttributeReference[id=1,name=x,relation=a,type=Int]
+| | +-right_join_attributes=
+| |   +-AttributeReference[id=6,name=x,relation=c,type=Int]
+| +-right=TableReference[relation=d]
+| | +-AttributeReference[id=8,name=y,relation=d,type=Int]
+| | +-AttributeReference[id=9,name=z,relation=d,type=Int]
+| +-join_predicate=Or
+| | +-Equal
+| | | +-AttributeReference[id=2,name=y,relation=a,type=Int]
+| | | +-AttributeReference[id=8,name=y,relation=d,type=Int]
+| | +-Greater
+| |   +-AttributeReference[id=3,name=z,relation=a,type=Int]
+| |   +-AttributeReference[id=9,name=z,relation=d,type=Int]
+| +-project_expressions=
+|   +-AttributeReference[id=3,name=z,relation=a,type=Int]
++-output_attributes=
+  +-AttributeReference[id=3,name=z,relation=a,type=Int]
+==
+
+SELECT a1.z
+FROM a AS a1 JOIN b AS b1 ON a1.w = b1.w
+             JOIN c AS c1 ON a1.x = c1.x
+             JOIN d AS d1 ON a1.y = d1.y
+WHERE a1.x = b1.x
+  AND a1.y = c1.y
+  AND a1.z = d1.z;
+--
+TopLevelPlan
++-plan=HashJoin
+| +-left=HashJoin
+| | +-left=HashJoin
+| | | +-left=TableReference[relation=a,alias=a1]
+| | | | +-AttributeReference[id=0,name=w,relation=a1,type=Int]
+| | | | +-AttributeReference[id=1,name=x,relation=a1,type=Int]
+| | | | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
+| | | | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
+| | | +-right=TableReference[relation=b,alias=b1]
+| | | | +-AttributeReference[id=4,name=w,relation=b1,type=Int]
+| | | | +-AttributeReference[id=5,name=x,relation=b1,type=Int]
+| | | +-project_expressions=
+| | | | +-AttributeReference[id=1,name=x,relation=a1,type=Int]
+| | | | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
+| | | | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
+| | | +-left_join_attributes=
+| | | | +-AttributeReference[id=1,name=x,relation=a1,type=Int]
+| | | | +-AttributeReference[id=0,name=w,relation=a1,type=Int]
+| | | +-right_join_attributes=
+| | |   +-AttributeReference[id=5,name=x,relation=b1,type=Int]
+| | |   +-AttributeReference[id=4,name=w,relation=b1,type=Int]
+| | +-right=TableReference[relation=c,alias=c1]
+| | | +-AttributeReference[id=6,name=x,relation=c1,type=Int]
+| | | +-AttributeReference[id=7,name=y,relation=c1,type=Int]
+| | +-project_expressions=
+| | | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
+| | | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
+| | +-left_join_attributes=
+| | | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
+| | | +-AttributeReference[id=1,name=x,relation=a1,type=Int]
+| | +-right_join_attributes=
+| |   +-AttributeReference[id=7,name=y,relation=c1,type=Int]
+| |   +-AttributeReference[id=6,name=x,relation=c1,type=Int]
+| +-right=TableReference[relation=d,alias=d1]
+| | +-AttributeReference[id=8,name=y,relation=d1,type=Int]
+| | +-AttributeReference[id=9,name=z,relation=d1,type=Int]
+| +-project_expressions=
+| | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
+| +-left_join_attributes=
+| | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
+| | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
+| +-right_join_attributes=
+|   +-AttributeReference[id=9,name=z,relation=d1,type=Int]
+|   +-AttributeReference[id=8,name=y,relation=d1,type=Int]
++-output_attributes=
+  +-AttributeReference[id=3,name=z,relation=a1,type=Int]
+==
+
+SELECT a1.z
+FROM a AS a1 JOIN b AS b1 ON a1.w <> b1.w
+             JOIN c AS c1 ON a1.x <> c1.x
+             JOIN d AS d1 ON a1.y <> d1.y
+WHERE a1.x = b1.x
+  AND a1.y = c1.y
+  AND a1.z = d1.z;
+--
+TopLevelPlan
++-plan=HashJoin
+| +-left=HashJoin
+| | +-left=HashJoin
+| | | +-left=TableReference[relation=a,alias=a1]
+| | | | +-AttributeReference[id=0,name=w,relation=a1,type=Int]
+| | | | +-AttributeReference[id=1,name=x,relation=a1,type=Int]
+| | | | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
+| | | | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
+| | | +-right=TableReference[relation=b,alias=b1]
+| | | | +-AttributeReference[id=4,name=w,relation=b1,type=Int]
+| | | | +-AttributeReference[id=5,name=x,relation=b1,type=Int]
+| | | +-residual_predicate=NotEqual
+| | | | +-AttributeReference[id=0,name=w,relation=a1,type=Int]
+| | | | +-AttributeReference[id=4,name=w,relation=b1,type=Int]
+| | | +-project_expressions=
+| | | | +-AttributeReference[id=1,name=x,relation=a1,type=Int]
+| | | | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
+| | | | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
+| | | +-left_join_attributes=
+| | | | +-AttributeReference[id=1,name=x,relation=a1,type=Int]
+| | | +-right_join_attributes=
+| | |   +-AttributeReference[id=5,name=x,relation=b1,type=Int]
+| | +-right=TableReference[relation=c,alias=c1]
+| | | +-AttributeReference[id=6,name=x,relation=c1,type=Int]
+| | | +-AttributeReference[id=7,name=y,relation=c1,type=Int]
+| | +-residual_predicate=NotEqual
+| | | +-AttributeReference[id=1,name=x,relation=a1,type=Int]
+| | | +-AttributeReference[id=6,name=x,relation=c1,type=Int]
+| | +-project_expressions=
+| | | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
+| | | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
+| | +-left_join_attributes=
+| | | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
+| | +-right_join_attributes=
+| |   +-AttributeReference[id=7,name=y,relation=c1,type=Int]
+| +-right=TableReference[relation=d,alias=d1]
+| | +-AttributeReference[id=8,name=y,relation=d1,type=Int]
+| | +-AttributeReference[id=9,name=z,relation=d1,type=Int]
+| +-residual_predicate=NotEqual
+| | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
+| | +-AttributeReference[id=8,name=y,relation=d1,type=Int]
+| +-project_expressions=
+| | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
+| +-left_join_attributes=
+| | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
+| +-right_join_attributes=
+|   +-AttributeReference[id=9,name=z,relation=d1,type=Int]
++-output_attributes=
+  +-AttributeReference[id=3,name=z,relation=a1,type=Int]

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/query_optimizer/tests/resolver/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/resolver/CMakeLists.txt b/query_optimizer/tests/resolver/CMakeLists.txt
index bc9725c..4d5a504 100644
--- a/query_optimizer/tests/resolver/CMakeLists.txt
+++ b/query_optimizer/tests/resolver/CMakeLists.txt
@@ -41,6 +41,10 @@ add_test(quickstep_queryoptimizer_tests_resolver_insert
          "../quickstep_queryoptimizer_tests_OptimizerTextTest"
          "${CMAKE_CURRENT_SOURCE_DIR}/Insert.test"
          "${CMAKE_CURRENT_BINARY_DIR}/Insert.test")
+add_test(quickstep_queryoptimizer_tests_resolver_join
+         "../quickstep_queryoptimizer_tests_OptimizerTextTest"
+         "${CMAKE_CURRENT_SOURCE_DIR}/Join.test"
+         "${CMAKE_CURRENT_BINARY_DIR}/Join.test")
 add_test(quickstep_queryoptimizer_tests_resolver_select
          "../quickstep_queryoptimizer_tests_OptimizerTextTest"
          "${CMAKE_CURRENT_SOURCE_DIR}/Select.test"

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/e87cabf4/query_optimizer/tests/resolver/Join.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/resolver/Join.test b/query_optimizer/tests/resolver/Join.test
new file mode 100644
index 0000000..f501f97
--- /dev/null
+++ b/query_optimizer/tests/resolver/Join.test
@@ -0,0 +1,172 @@
+#   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.
+
+[default initial_logical_plan]
+
+SELECT a.z
+FROM a JOIN b ON a.w = b.w
+       JOIN c ON a.x = c.x
+       JOIN d ON a.y = d.y;
+--
+TopLevelPlan
++-plan=Project
+| +-input=Filter
+| | +-input=MultiwayCartesianJoin
+| | | +-Filter
+| | | | +-input=MultiwayCartesianJoin
+| | | | | +-Filter
+| | | | | | +-input=MultiwayCartesianJoin
+| | | | | | | +-TableReference[relation_name=a]
+| | | | | | | | +-AttributeReference[id=0,name=w,relation=a,type=Int]
+| | | | | | | | +-AttributeReference[id=1,name=x,relation=a,type=Int]
+| | | | | | | | +-AttributeReference[id=2,name=y,relation=a,type=Int]
+| | | | | | | | +-AttributeReference[id=3,name=z,relation=a,type=Int]
+| | | | | | | +-TableReference[relation_name=b]
+| | | | | | |   +-AttributeReference[id=4,name=w,relation=b,type=Int]
+| | | | | | |   +-AttributeReference[id=5,name=x,relation=b,type=Int]
+| | | | | | +-filter_predicate=Equal
+| | | | | |   +-AttributeReference[id=0,name=w,relation=a,type=Int]
+| | | | | |   +-AttributeReference[id=4,name=w,relation=b,type=Int]
+| | | | | +-TableReference[relation_name=c]
+| | | | |   +-AttributeReference[id=6,name=x,relation=c,type=Int]
+| | | | |   +-AttributeReference[id=7,name=y,relation=c,type=Int]
+| | | | +-filter_predicate=Equal
+| | | |   +-AttributeReference[id=1,name=x,relation=a,type=Int]
+| | | |   +-AttributeReference[id=6,name=x,relation=c,type=Int]
+| | | +-TableReference[relation_name=d]
+| | |   +-AttributeReference[id=8,name=y,relation=d,type=Int]
+| | |   +-AttributeReference[id=9,name=z,relation=d,type=Int]
+| | +-filter_predicate=Equal
+| |   +-AttributeReference[id=2,name=y,relation=a,type=Int]
+| |   +-AttributeReference[id=8,name=y,relation=d,type=Int]
+| +-project_list=
+|   +-AttributeReference[id=3,name=z,relation=a,type=Int]
++-output_attributes=
+  +-AttributeReference[id=3,name=z,relation=a,type=Int]
+==
+
+SELECT a.z
+FROM a JOIN b ON (a.w = b.w OR a.x > b.x)
+       JOIN c ON (a.x = c.x OR a.y > c.y)
+       JOIN d ON (a.y = d.y OR a.z > d.z);
+--
+TopLevelPlan
++-plan=Project
+| +-input=Filter
+| | +-input=MultiwayCartesianJoin
+| | | +-Filter
+| | | | +-input=MultiwayCartesianJoin
+| | | | | +-Filter
+| | | | | | +-input=MultiwayCartesianJoin
+| | | | | | | +-TableReference[relation_name=a]
+| | | | | | | | +-AttributeReference[id=0,name=w,relation=a,type=Int]
+| | | | | | | | +-AttributeReference[id=1,name=x,relation=a,type=Int]
+| | | | | | | | +-AttributeReference[id=2,name=y,relation=a,type=Int]
+| | | | | | | | +-AttributeReference[id=3,name=z,relation=a,type=Int]
+| | | | | | | +-TableReference[relation_name=b]
+| | | | | | |   +-AttributeReference[id=4,name=w,relation=b,type=Int]
+| | | | | | |   +-AttributeReference[id=5,name=x,relation=b,type=Int]
+| | | | | | +-filter_predicate=Or
+| | | | | |   +-Equal
+| | | | | |   | +-AttributeReference[id=0,name=w,relation=a,type=Int]
+| | | | | |   | +-AttributeReference[id=4,name=w,relation=b,type=Int]
+| | | | | |   +-Greater
+| | | | | |     +-AttributeReference[id=1,name=x,relation=a,type=Int]
+| | | | | |     +-AttributeReference[id=5,name=x,relation=b,type=Int]
+| | | | | +-TableReference[relation_name=c]
+| | | | |   +-AttributeReference[id=6,name=x,relation=c,type=Int]
+| | | | |   +-AttributeReference[id=7,name=y,relation=c,type=Int]
+| | | | +-filter_predicate=Or
+| | | |   +-Equal
+| | | |   | +-AttributeReference[id=1,name=x,relation=a,type=Int]
+| | | |   | +-AttributeReference[id=6,name=x,relation=c,type=Int]
+| | | |   +-Greater
+| | | |     +-AttributeReference[id=2,name=y,relation=a,type=Int]
+| | | |     +-AttributeReference[id=7,name=y,relation=c,type=Int]
+| | | +-TableReference[relation_name=d]
+| | |   +-AttributeReference[id=8,name=y,relation=d,type=Int]
+| | |   +-AttributeReference[id=9,name=z,relation=d,type=Int]
+| | +-filter_predicate=Or
+| |   +-Equal
+| |   | +-AttributeReference[id=2,name=y,relation=a,type=Int]
+| |   | +-AttributeReference[id=8,name=y,relation=d,type=Int]
+| |   +-Greater
+| |     +-AttributeReference[id=3,name=z,relation=a,type=Int]
+| |     +-AttributeReference[id=9,name=z,relation=d,type=Int]
+| +-project_list=
+|   +-AttributeReference[id=3,name=z,relation=a,type=Int]
++-output_attributes=
+  +-AttributeReference[id=3,name=z,relation=a,type=Int]
+==
+
+SELECT a1.z
+FROM a AS a1 JOIN b AS b1 ON a1.w = b1.w
+             JOIN c AS c1 ON a1.x = c1.x
+             JOIN d AS d1 ON a1.y = d1.y;
+WHERE a1.x = b1.x
+  AND a1.y = c1.y
+  AND a1.z = d1.z;
+--
+TopLevelPlan
++-plan=Project
+| +-input=Filter
+| | +-input=MultiwayCartesianJoin
+| | | +-Filter
+| | | | +-input=MultiwayCartesianJoin
+| | | | | +-Filter
+| | | | | | +-input=MultiwayCartesianJoin
+| | | | | | | +-TableReference[relation_name=a,relation_alias=a1]
+| | | | | | | | +-AttributeReference[id=0,name=w,relation=a1,type=Int]
+| | | | | | | | +-AttributeReference[id=1,name=x,relation=a1,type=Int]
+| | | | | | | | +-AttributeReference[id=2,name=y,relation=a1,type=Int]
+| | | | | | | | +-AttributeReference[id=3,name=z,relation=a1,type=Int]
+| | | | | | | +-TableReference[relation_name=b,relation_alias=b1]
+| | | | | | |   +-AttributeReference[id=4,name=w,relation=b1,type=Int]
+| | | | | | |   +-AttributeReference[id=5,name=x,relation=b1,type=Int]
+| | | | | | +-filter_predicate=Equal
+| | | | | |   +-AttributeReference[id=0,name=w,relation=a1,type=Int]
+| | | | | |   +-AttributeReference[id=4,name=w,relation=b1,type=Int]
+| | | | | +-TableReference[relation_name=c,relation_alias=c1]
+| | | | |   +-AttributeReference[id=6,name=x,relation=c1,type=Int]
+| | | | |   +-AttributeReference[id=7,name=y,relation=c1,type=Int]
+| | | | +-filter_predicate=Equal
+| | | |   +-AttributeReference[id=1,name=x,relation=a1,type=Int]
+| | | |   +-AttributeReference[id=6,name=x,relation=c1,type=Int]
+| | | +-TableReference[relation_name=d,relation_alias=d1]
+| | |   +-AttributeReference[id=8,name=y,relation=d1,type=Int]
+| | |   +-AttributeReference[id=9,name=z,relation=d1,type=Int]
+| | +-filter_predicate=Equal
+| |   +-AttributeReference[id=2,name=y,relation=a1,type=Int]
+| |   +-AttributeReference[id=8,name=y,relation=d1,type=Int]
+| +-project_list=
+|   +-AttributeReference[id=3,name=z,relation=a1,type=Int]
++-output_attributes=
+  +-AttributeReference[id=3,name=z,relation=a1,type=Int]
+==
+
+SELECT *
+FROM b LEFT JOIN c ON b.x = c.x JOIN d ON c.y = d.y;
+--
+ERROR: Outer joins are not supported yet (2 : 13)
+FROM b LEFT JOIN c ON b.x = c.x JOIN d ON ...
+            ^
+==
+
+SELECT *
+FROM b LEFT JOIN (c JOIN d ON c.y = d.y) ON b.x = c.x;
+--
+ERROR: Outer joins are not supported yet (2 : 13)
+FROM b LEFT JOIN (c JOIN d ON c.y = d.y) O...
+            ^


[17/24] incubator-quickstep git commit: Added hook (not actual code) to BitWeaving. (#169)

Posted by zu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/cbd169e5/parser/preprocessed/SqlParser_gen.cpp
----------------------------------------------------------------------
diff --git a/parser/preprocessed/SqlParser_gen.cpp b/parser/preprocessed/SqlParser_gen.cpp
index 0937d33..7ebb01f 100644
--- a/parser/preprocessed/SqlParser_gen.cpp
+++ b/parser/preprocessed/SqlParser_gen.cpp
@@ -1,8 +1,8 @@
-/* A Bison parser, made by GNU Bison 3.0.4.  */
+/* A Bison parser, made by GNU Bison 3.0.2.  */
 
 /* Bison implementation for Yacc-like parsers in C
 
-   Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
+   Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -44,7 +44,7 @@
 #define YYBISON 1
 
 /* Bison version.  */
-#define YYBISON_VERSION "3.0.4"
+#define YYBISON_VERSION "3.0.2"
 
 /* Skeleton name.  */
 #define YYSKELETON_NAME "yacc.c"
@@ -211,98 +211,99 @@ extern int quickstep_yydebug;
     TOKEN_ASC = 282,
     TOKEN_BIGINT = 283,
     TOKEN_BIT = 284,
-    TOKEN_BLOCKPROPERTIES = 285,
-    TOKEN_BLOCKSAMPLE = 286,
-    TOKEN_BLOOM_FILTER = 287,
-    TOKEN_CSB_TREE = 288,
-    TOKEN_BY = 289,
-    TOKEN_CASE = 290,
-    TOKEN_CHARACTER = 291,
-    TOKEN_CHECK = 292,
-    TOKEN_COLUMN = 293,
-    TOKEN_CONSTRAINT = 294,
-    TOKEN_COPY = 295,
-    TOKEN_CREATE = 296,
-    TOKEN_DATE = 297,
-    TOKEN_DATETIME = 298,
-    TOKEN_DECIMAL = 299,
-    TOKEN_DEFAULT = 300,
-    TOKEN_DELETE = 301,
-    TOKEN_DELIMITER = 302,
-    TOKEN_DESC = 303,
-    TOKEN_DISTINCT = 304,
-    TOKEN_DOUBLE = 305,
-    TOKEN_DROP = 306,
-    TOKEN_ELSE = 307,
-    TOKEN_END = 308,
-    TOKEN_ESCAPE_STRINGS = 309,
-    TOKEN_EXISTS = 310,
-    TOKEN_EXTRACT = 311,
-    TOKEN_FALSE = 312,
-    TOKEN_FIRST = 313,
-    TOKEN_FLOAT = 314,
-    TOKEN_FOREIGN = 315,
-    TOKEN_FROM = 316,
-    TOKEN_FULL = 317,
-    TOKEN_GROUP = 318,
-    TOKEN_HASH = 319,
-    TOKEN_HAVING = 320,
-    TOKEN_IN = 321,
-    TOKEN_INDEX = 322,
-    TOKEN_INNER = 323,
-    TOKEN_INSERT = 324,
-    TOKEN_INTEGER = 325,
-    TOKEN_INTERVAL = 326,
-    TOKEN_INTO = 327,
-    TOKEN_JOIN = 328,
-    TOKEN_KEY = 329,
-    TOKEN_LAST = 330,
-    TOKEN_LEFT = 331,
-    TOKEN_LIMIT = 332,
-    TOKEN_LONG = 333,
-    TOKEN_NULL = 334,
-    TOKEN_NULLS = 335,
-    TOKEN_OFF = 336,
-    TOKEN_ON = 337,
-    TOKEN_ORDER = 338,
-    TOKEN_OUTER = 339,
-    TOKEN_PARTITION = 340,
-    TOKEN_PARTITIONS = 341,
-    TOKEN_PERCENT = 342,
-    TOKEN_PRIMARY = 343,
-    TOKEN_QUIT = 344,
-    TOKEN_RANGE = 345,
-    TOKEN_REAL = 346,
-    TOKEN_REFERENCES = 347,
-    TOKEN_RIGHT = 348,
-    TOKEN_ROW_DELIMITER = 349,
-    TOKEN_SELECT = 350,
-    TOKEN_SET = 351,
-    TOKEN_SMA = 352,
-    TOKEN_SMALLINT = 353,
-    TOKEN_TABLE = 354,
-    TOKEN_THEN = 355,
-    TOKEN_TIME = 356,
-    TOKEN_TIMESTAMP = 357,
-    TOKEN_TRUE = 358,
-    TOKEN_TUPLESAMPLE = 359,
-    TOKEN_UNIQUE = 360,
-    TOKEN_UPDATE = 361,
-    TOKEN_USING = 362,
-    TOKEN_VALUES = 363,
-    TOKEN_VARCHAR = 364,
-    TOKEN_WHEN = 365,
-    TOKEN_WHERE = 366,
-    TOKEN_WITH = 367,
-    TOKEN_YEARMONTH = 368,
-    TOKEN_EOF = 369,
-    TOKEN_LEX_ERROR = 370
+    TOKEN_BITWEAVING = 285,
+    TOKEN_BLOCKPROPERTIES = 286,
+    TOKEN_BLOCKSAMPLE = 287,
+    TOKEN_BLOOM_FILTER = 288,
+    TOKEN_CSB_TREE = 289,
+    TOKEN_BY = 290,
+    TOKEN_CASE = 291,
+    TOKEN_CHARACTER = 292,
+    TOKEN_CHECK = 293,
+    TOKEN_COLUMN = 294,
+    TOKEN_CONSTRAINT = 295,
+    TOKEN_COPY = 296,
+    TOKEN_CREATE = 297,
+    TOKEN_DATE = 298,
+    TOKEN_DATETIME = 299,
+    TOKEN_DECIMAL = 300,
+    TOKEN_DEFAULT = 301,
+    TOKEN_DELETE = 302,
+    TOKEN_DELIMITER = 303,
+    TOKEN_DESC = 304,
+    TOKEN_DISTINCT = 305,
+    TOKEN_DOUBLE = 306,
+    TOKEN_DROP = 307,
+    TOKEN_ELSE = 308,
+    TOKEN_END = 309,
+    TOKEN_ESCAPE_STRINGS = 310,
+    TOKEN_EXISTS = 311,
+    TOKEN_EXTRACT = 312,
+    TOKEN_FALSE = 313,
+    TOKEN_FIRST = 314,
+    TOKEN_FLOAT = 315,
+    TOKEN_FOREIGN = 316,
+    TOKEN_FROM = 317,
+    TOKEN_FULL = 318,
+    TOKEN_GROUP = 319,
+    TOKEN_HASH = 320,
+    TOKEN_HAVING = 321,
+    TOKEN_IN = 322,
+    TOKEN_INDEX = 323,
+    TOKEN_INNER = 324,
+    TOKEN_INSERT = 325,
+    TOKEN_INTEGER = 326,
+    TOKEN_INTERVAL = 327,
+    TOKEN_INTO = 328,
+    TOKEN_JOIN = 329,
+    TOKEN_KEY = 330,
+    TOKEN_LAST = 331,
+    TOKEN_LEFT = 332,
+    TOKEN_LIMIT = 333,
+    TOKEN_LONG = 334,
+    TOKEN_NULL = 335,
+    TOKEN_NULLS = 336,
+    TOKEN_OFF = 337,
+    TOKEN_ON = 338,
+    TOKEN_ORDER = 339,
+    TOKEN_OUTER = 340,
+    TOKEN_PARTITION = 341,
+    TOKEN_PARTITIONS = 342,
+    TOKEN_PERCENT = 343,
+    TOKEN_PRIMARY = 344,
+    TOKEN_QUIT = 345,
+    TOKEN_RANGE = 346,
+    TOKEN_REAL = 347,
+    TOKEN_REFERENCES = 348,
+    TOKEN_RIGHT = 349,
+    TOKEN_ROW_DELIMITER = 350,
+    TOKEN_SELECT = 351,
+    TOKEN_SET = 352,
+    TOKEN_SMA = 353,
+    TOKEN_SMALLINT = 354,
+    TOKEN_TABLE = 355,
+    TOKEN_THEN = 356,
+    TOKEN_TIME = 357,
+    TOKEN_TIMESTAMP = 358,
+    TOKEN_TRUE = 359,
+    TOKEN_TUPLESAMPLE = 360,
+    TOKEN_UNIQUE = 361,
+    TOKEN_UPDATE = 362,
+    TOKEN_USING = 363,
+    TOKEN_VALUES = 364,
+    TOKEN_VARCHAR = 365,
+    TOKEN_WHEN = 366,
+    TOKEN_WHERE = 367,
+    TOKEN_WITH = 368,
+    TOKEN_YEARMONTH = 369,
+    TOKEN_EOF = 370,
+    TOKEN_LEX_ERROR = 371
   };
 #endif
 
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-
+typedef union YYSTYPE YYSTYPE;
 union YYSTYPE
 {
 #line 117 "../SqlParser.ypp" /* yacc.c:355  */
@@ -395,10 +396,8 @@ union YYSTYPE
   quickstep::PtrVector<quickstep::ParseSubqueryTableReference> *with_list_;
   quickstep::ParseSubqueryTableReference *with_list_element_;
 
-#line 399 "SqlParser_gen.cpp" /* yacc.c:355  */
+#line 400 "SqlParser_gen.cpp" /* yacc.c:355  */
 };
-
-typedef union YYSTYPE YYSTYPE;
 # define YYSTYPE_IS_TRIVIAL 1
 # define YYSTYPE_IS_DECLARED 1
 #endif
@@ -430,7 +429,7 @@ int quickstep_yyparse (yyscan_t yyscanner, quickstep::ParseStatement **parsedSta
 #include "SqlLexer_gen.hpp"
 void NotSupported(const YYLTYPE *location, yyscan_t yyscanner, const std::string &feature);
 
-#line 434 "SqlParser_gen.cpp" /* yacc.c:358  */
+#line 433 "SqlParser_gen.cpp" /* yacc.c:358  */
 
 #ifdef short
 # undef short
@@ -674,21 +673,21 @@ union yyalloc
 /* YYFINAL -- State number of the termination state.  */
 #define YYFINAL  47
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   1093
+#define YYLAST   1147
 
 /* YYNTOKENS -- Number of terminals.  */
-#define YYNTOKENS  127
+#define YYNTOKENS  128
 /* YYNNTS -- Number of nonterminals.  */
 #define YYNNTS  95
 /* YYNRULES -- Number of rules.  */
-#define YYNRULES  254
+#define YYNRULES  255
 /* YYNSTATES -- Number of states.  */
-#define YYNSTATES  496
+#define YYNSTATES  497
 
 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
    by yylex, with out-of-bounds checking.  */
 #define YYUNDEFTOK  2
-#define YYMAXUTOK   370
+#define YYMAXUTOK   371
 
 #define YYTRANSLATE(YYX)                                                \
   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -698,11 +697,11 @@ union yyalloc
 static const yytype_uint8 yytranslate[] =
 {
        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     122,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+     123,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,   126,     2,     2,
-     123,   124,    23,    21,   125,    22,    27,    24,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,   121,
+       2,     2,     2,     2,     2,     2,     2,   127,     2,     2,
+     124,   125,    23,    21,   126,    22,    27,    24,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,   122,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
@@ -734,39 +733,39 @@ static const yytype_uint8 yytranslate[] =
       90,    91,    92,    93,    94,    95,    96,    97,    98,    99,
      100,   101,   102,   103,   104,   105,   106,   107,   108,   109,
      110,   111,   112,   113,   114,   115,   116,   117,   118,   119,
-     120
+     120,   121
 };
 
 #if YYDEBUG
   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
 static const yytype_uint16 yyrline[] =
 {
-       0,   569,   569,   573,   577,   581,   585,   588,   595,   598,
-     601,   604,   607,   610,   613,   616,   619,   622,   628,   634,
-     641,   647,   654,   663,   668,   677,   682,   687,   691,   697,
-     702,   705,   708,   713,   716,   719,   722,   725,   728,   731,
-     734,   737,   740,   752,   755,   758,   776,   796,   799,   802,
-     807,   812,   818,   824,   833,   837,   843,   846,   851,   856,
-     861,   868,   875,   879,   885,   888,   893,   896,   901,   904,
-     909,   912,   931,   935,   941,   945,   951,   954,   957,   962,
-     965,   972,   977,   988,   992,   996,  1002,  1005,  1011,  1019,
-    1022,  1025,  1031,  1036,  1039,  1044,  1048,  1052,  1056,  1062,
-    1067,  1072,  1076,  1082,  1088,  1091,  1096,  1101,  1105,  1111,
-    1117,  1123,  1126,  1130,  1136,  1139,  1144,  1148,  1154,  1157,
-    1160,  1165,  1170,  1173,  1179,  1183,  1189,  1195,  1201,  1207,
-    1213,  1219,  1225,  1231,  1239,  1244,  1247,  1250,  1255,  1259,
-    1263,  1266,  1270,  1275,  1278,  1283,  1286,  1291,  1295,  1301,
-    1304,  1309,  1312,  1317,  1320,  1325,  1328,  1347,  1351,  1357,
-    1364,  1367,  1370,  1375,  1378,  1381,  1387,  1390,  1395,  1400,
-    1409,  1414,  1423,  1428,  1431,  1436,  1439,  1444,  1450,  1456,
-    1459,  1462,  1465,  1468,  1471,  1477,  1486,  1489,  1494,  1497,
-    1502,  1505,  1510,  1513,  1516,  1519,  1522,  1525,  1530,  1534,
-    1538,  1541,  1546,  1551,  1554,  1559,  1563,  1569,  1574,  1578,
-    1584,  1589,  1592,  1597,  1601,  1607,  1610,  1613,  1616,  1628,
-    1632,  1651,  1666,  1670,  1676,  1679,  1684,  1688,  1695,  1698,
-    1701,  1704,  1707,  1710,  1713,  1716,  1719,  1722,  1727,  1738,
-    1741,  1746,  1749,  1752,  1758,  1762,  1768,  1771,  1779,  1782,
-    1785,  1788,  1794,  1799,  1804
+       0,   570,   570,   574,   578,   582,   586,   589,   596,   599,
+     602,   605,   608,   611,   614,   617,   620,   623,   629,   635,
+     642,   648,   655,   664,   669,   678,   683,   688,   692,   698,
+     703,   706,   709,   714,   717,   720,   723,   726,   729,   732,
+     735,   738,   741,   753,   756,   759,   777,   797,   800,   803,
+     808,   813,   819,   825,   834,   838,   844,   847,   852,   857,
+     862,   869,   876,   880,   886,   889,   894,   897,   902,   905,
+     910,   913,   932,   936,   942,   946,   952,   955,   958,   963,
+     966,   973,   978,   989,   994,   998,  1002,  1008,  1011,  1017,
+    1025,  1028,  1031,  1037,  1042,  1045,  1050,  1054,  1058,  1062,
+    1068,  1073,  1078,  1082,  1088,  1094,  1097,  1102,  1107,  1111,
+    1117,  1123,  1129,  1132,  1136,  1142,  1145,  1150,  1154,  1160,
+    1163,  1166,  1171,  1176,  1179,  1185,  1189,  1195,  1201,  1207,
+    1213,  1219,  1225,  1231,  1237,  1245,  1250,  1253,  1256,  1261,
+    1265,  1269,  1272,  1276,  1281,  1284,  1289,  1292,  1297,  1301,
+    1307,  1310,  1315,  1318,  1323,  1326,  1331,  1334,  1353,  1357,
+    1363,  1370,  1373,  1376,  1381,  1384,  1387,  1393,  1396,  1401,
+    1406,  1415,  1420,  1429,  1434,  1437,  1442,  1445,  1450,  1456,
+    1462,  1465,  1468,  1471,  1474,  1477,  1483,  1492,  1495,  1500,
+    1503,  1508,  1511,  1516,  1519,  1522,  1525,  1528,  1531,  1536,
+    1540,  1544,  1547,  1552,  1557,  1560,  1565,  1569,  1575,  1580,
+    1584,  1590,  1595,  1598,  1603,  1607,  1613,  1616,  1619,  1622,
+    1634,  1638,  1657,  1672,  1676,  1682,  1685,  1690,  1694,  1701,
+    1704,  1707,  1710,  1713,  1716,  1719,  1722,  1725,  1728,  1733,
+    1744,  1747,  1752,  1755,  1758,  1764,  1768,  1774,  1777,  1785,
+    1788,  1791,  1794,  1800,  1805,  1810
 };
 #endif
 
@@ -782,7 +781,7 @@ static const char *const yytname[] =
   "TOKEN_NEQ", "TOKEN_LIKE", "TOKEN_REGEXP", "TOKEN_BETWEEN", "TOKEN_IS",
   "'+'", "'-'", "'*'", "'/'", "UNARY_PLUS", "UNARY_MINUS", "'.'",
   "TOKEN_ADD", "TOKEN_ALL", "TOKEN_ALTER", "TOKEN_AS", "TOKEN_ASC",
-  "TOKEN_BIGINT", "TOKEN_BIT", "TOKEN_BLOCKPROPERTIES",
+  "TOKEN_BIGINT", "TOKEN_BIT", "TOKEN_BITWEAVING", "TOKEN_BLOCKPROPERTIES",
   "TOKEN_BLOCKSAMPLE", "TOKEN_BLOOM_FILTER", "TOKEN_CSB_TREE", "TOKEN_BY",
   "TOKEN_CASE", "TOKEN_CHARACTER", "TOKEN_CHECK", "TOKEN_COLUMN",
   "TOKEN_CONSTRAINT", "TOKEN_COPY", "TOKEN_CREATE", "TOKEN_DATE",
@@ -855,14 +854,14 @@ static const yytype_uint16 yytoknum[] =
      340,   341,   342,   343,   344,   345,   346,   347,   348,   349,
      350,   351,   352,   353,   354,   355,   356,   357,   358,   359,
      360,   361,   362,   363,   364,   365,   366,   367,   368,   369,
-     370,    59,    10,    40,    41,    44,    37
+     370,   371,    59,    10,    40,    41,    44,    37
 };
 # endif
 
-#define YYPACT_NINF -222
+#define YYPACT_NINF -209
 
 #define yypact_value_is_default(Yystate) \
-  (!!((Yystate) == (-222)))
+  (!!((Yystate) == (-209)))
 
 #define YYTABLE_NINF -1
 
@@ -873,56 +872,56 @@ static const yytype_uint16 yytoknum[] =
      STATE-NUM.  */
 static const yytype_int16 yypact[] =
 {
-     139,  -222,  -222,   -64,   168,    17,    40,   -27,     6,  -222,
-      25,   168,   168,  -222,   176,   116,  -222,  -222,  -222,  -222,
-    -222,  -222,  -222,  -222,  -222,  -222,    -6,  -222,   154,   179,
-     168,  -222,  -222,   122,   168,   168,   168,   168,   168,  -222,
-    -222,   576,    95,   118,  -222,   210,    88,  -222,  -222,  -222,
-     190,  -222,  -222,  -222,  -222,   145,   252,   184,   142,   162,
-    -222,    97,  -222,  -222,   276,   278,  -222,  -222,  -222,   640,
-     164,  -222,   222,  -222,  -222,   177,  -222,  -222,   291,  -222,
-    -222,  -222,  -222,  -222,  -222,   193,   235,   832,   335,   290,
-     236,  -222,   268,    37,  -222,  -222,  -222,  -222,  -222,  -222,
-    -222,   896,   -12,   168,   168,   242,   168,   168,   249,   251,
-     250,   168,   168,   512,  -222,  -222,   246,   168,  -222,  -222,
-    -222,   512,     3,   -20,  -222,   364,  -222,   168,  -222,   366,
-    -222,    36,  -222,    12,   162,   832,  -222,  -222,   168,   832,
-    -222,  -222,  -222,  -222,   832,   278,  -222,   168,   425,   111,
-    -222,   369,  -222,   275,  -222,   178,  -222,   275,   168,   105,
-     168,   168,   263,  -222,   265,  -222,   180,   975,   704,   242,
-     512,   374,   381,  -222,  -222,   405,   371,   942,   182,    14,
-     832,   -18,  -222,   832,  -222,   334,   269,   328,   272,  -222,
-     188,  -222,   136,   188,   -19,   329,  -222,  -222,    37,  -222,
-    -222,   277,   832,  -222,   288,   189,   168,  -222,   832,   280,
-    -222,   168,  -222,  -222,   279,   320,   326,   283,  -222,  -222,
-    -222,   170,   168,   295,   105,   168,  -222,    31,  -222,  -222,
-       2,    34,   512,   512,   133,  -222,  -222,  -222,  -222,  -222,
-    -222,  -222,  -222,   832,   285,   832,    33,  -222,   194,   296,
-     832,    50,  -222,   353,   288,  -222,  -222,   832,  -222,   168,
-    -222,  -222,    86,   336,   168,   173,   186,    12,  -222,   171,
-    -222,  -222,   406,   421,   188,   394,   365,  -222,   196,  -222,
-     832,  -222,   288,  -222,  -222,   512,   311,   315,   168,   434,
-      23,   198,  -222,   201,   413,   -10,  -222,   316,   325,  -222,
-     359,   321,   942,  -222,   370,   168,  -222,  -222,    31,  -222,
-    -222,   381,  -222,  -222,  -222,   832,   322,   203,   768,  -222,
-     288,   367,  -222,  -222,   942,   327,   288,   832,  -222,    41,
-    -222,   168,   375,   168,   -45,   168,   376,   168,   378,  -222,
-    -222,   360,   372,  -222,   832,   512,   373,  -222,   288,    13,
-     168,   168,   212,  -222,  -222,  -222,  -222,  -222,  -222,  -222,
-     207,  -222,   168,  -222,  -222,  -222,   339,   105,   428,   377,
-    -222,   512,  -222,  -222,   345,  -222,   259,   768,  -222,   832,
-     214,  -222,  -222,   942,   288,  -222,   -13,   168,    -5,   512,
-       0,   168,    11,   168,  -222,  -222,   344,   374,   431,   393,
-    -222,   218,   220,  -222,   472,    23,  -222,   168,  -222,  -222,
-     358,   444,  -222,    15,   168,   832,   224,   288,  -222,   226,
-     512,    46,   512,   374,   512,    66,   512,    75,   832,   477,
-    -222,   388,  -222,  -222,  -222,   228,  -222,  -222,  -222,  -222,
-       7,   168,    92,  -222,   363,   288,  -222,  -222,   374,   512,
-     374,   374,   512,   374,   512,   368,  -222,    43,  -222,   168,
-    -222,   168,  -222,  -222,   168,  -222,   230,  -222,  -222,   379,
-    -222,   374,   374,   374,   832,  -222,  -222,   403,   380,  -222,
-     239,  -222,   168,  -222,   143,  -222,   168,  -222,   254,  -222,
-    -222,   260,   399,  -222,   484,  -222
+     394,  -209,  -209,   -35,   190,    72,   133,   120,    53,  -209,
+      69,   190,   190,  -209,    94,   127,  -209,  -209,  -209,  -209,
+    -209,  -209,  -209,  -209,  -209,  -209,    91,  -209,   -34,   207,
+     190,  -209,  -209,   166,   190,   190,   190,   190,   190,  -209,
+    -209,   602,   134,   113,  -209,   235,   144,  -209,  -209,  -209,
+     197,  -209,  -209,  -209,  -209,    62,   289,   208,   176,   192,
+    -209,   137,  -209,  -209,   308,   321,  -209,  -209,  -209,   635,
+     206,  -209,   255,  -209,  -209,   210,  -209,  -209,   331,  -209,
+    -209,  -209,  -209,  -209,  -209,   214,   272,   844,   346,   285,
+     227,  -209,   236,    -2,  -209,  -209,  -209,  -209,  -209,  -209,
+    -209,   877,    41,   190,   190,   230,   190,   190,   123,   220,
+     237,   190,   190,   514,  -209,  -209,   233,   190,  -209,  -209,
+    -209,   514,    23,   -33,  -209,   349,  -209,   190,  -209,   352,
+    -209,     7,  -209,     9,   192,   844,  -209,  -209,   190,   844,
+    -209,  -209,  -209,  -209,   844,   321,  -209,   190,   426,   126,
+    -209,   350,  -209,   261,  -209,   146,  -209,   261,   190,     3,
+     190,   190,   239,  -209,   241,  -209,   148,   960,   723,   230,
+     514,   358,   359,  -209,  -209,  1075,   354,   965,   152,    15,
+     844,   -20,  -209,   844,  -209,   311,   247,   309,   254,  -209,
+      81,  -209,   105,    81,   -32,   312,  -209,  -209,    -2,  -209,
+    -209,   260,   844,  -209,   258,   156,   190,  -209,   844,   262,
+    -209,   190,  -209,  -209,   256,   303,   313,   265,  -209,  -209,
+    -209,   184,   190,   278,     3,   190,  -209,   118,  -209,  -209,
+       1,    37,   514,   514,    98,  -209,  -209,  -209,  -209,  -209,
+    -209,  -209,  -209,   844,   268,   844,    26,  -209,   165,   280,
+     844,    52,  -209,   337,   258,  -209,  -209,   844,  -209,   190,
+    -209,  -209,   116,   319,   190,   129,   132,     9,  -209,   106,
+    -209,  -209,   395,   399,    81,   361,   336,  -209,   167,  -209,
+     844,  -209,   258,  -209,  -209,   514,   284,   286,   190,   404,
+      88,   173,  -209,   177,   385,    27,  -209,   287,   296,  -209,
+     330,   292,   965,  -209,   338,   190,  -209,  -209,   118,  -209,
+    -209,   359,  -209,  -209,  -209,   844,   293,    55,   756,  -209,
+     258,   334,  -209,  -209,   965,   297,   258,   844,  -209,    39,
+    -209,   190,   341,   190,   -47,   190,   343,   190,   344,  -209,
+    -209,   332,   333,  -209,   844,   514,   339,  -209,   258,    10,
+     190,   190,   180,  -209,  -209,  -209,  -209,  -209,  -209,  -209,
+     209,  -209,   190,  -209,  -209,  -209,  -209,   305,     3,   391,
+     345,  -209,   514,  -209,  -209,   310,  -209,   232,   756,  -209,
+     844,   182,  -209,  -209,   965,   258,  -209,   -45,   190,   -25,
+     514,   -16,   190,    18,   190,  -209,  -209,   316,   358,   403,
+     356,  -209,   185,   187,  -209,   430,    88,  -209,   190,  -209,
+    -209,   320,   410,  -209,    16,   190,   844,   191,   258,  -209,
+     193,   514,    64,   514,   358,   514,    67,   514,    75,   844,
+     445,  -209,   355,  -209,  -209,  -209,   195,  -209,  -209,  -209,
+    -209,    13,   190,   121,  -209,   329,   258,  -209,  -209,   358,
+     514,   358,   358,   514,   358,   514,   340,  -209,   202,  -209,
+     190,  -209,   190,  -209,  -209,   190,  -209,   198,  -209,  -209,
+     347,  -209,   358,   358,   358,   844,  -209,  -209,   369,   348,
+    -209,   200,  -209,   190,  -209,   117,  -209,   190,  -209,   217,
+    -209,  -209,   219,   365,  -209,   455,  -209
 };
 
   /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
@@ -930,83 +929,83 @@ static const yytype_int16 yypact[] =
      means the default is an error.  */
 static const yytype_uint8 yydefact[] =
 {
-       0,     6,   254,     0,     0,     0,     0,     0,     0,    18,
-     111,     0,     0,     7,     0,     0,    15,     8,    10,    11,
-      13,    14,     9,    17,    12,    16,     0,   104,     0,   252,
-       0,   246,   247,     0,     0,     0,     0,     0,     0,   112,
-     113,     0,     0,   106,   107,     0,   145,     1,     3,     2,
-       0,   105,     5,     4,   253,     0,     0,     0,     0,   166,
-      25,     0,   219,   216,     0,   238,   114,    40,    29,     0,
+       0,     6,   255,     0,     0,     0,     0,     0,     0,    18,
+     112,     0,     0,     7,     0,     0,    15,     8,    10,    11,
+      13,    14,     9,    17,    12,    16,     0,   105,     0,   253,
+       0,   247,   248,     0,     0,     0,     0,     0,     0,   113,
+     114,     0,     0,   107,   108,     0,   146,     1,     3,     2,
+       0,   106,     5,     4,   254,     0,     0,     0,     0,   167,
+      25,     0,   220,   217,     0,   239,   115,    40,    29,     0,
        0,    30,    31,    34,    36,     0,    37,    39,     0,    41,
-     215,    35,    38,    32,    33,     0,     0,     0,     0,     0,
-     115,   116,   120,   187,   189,   191,   194,   195,   196,   193,
-     192,     0,   224,     0,     0,     0,     0,     0,     0,     0,
-      93,     0,     0,     0,   100,   167,     0,     0,    90,   217,
-     218,     0,     0,   211,   208,     0,    43,     0,   220,     0,
-      44,     0,   221,     0,   166,     0,   239,   240,     0,     0,
-     119,   242,   243,   241,     0,     0,   190,     0,     0,   166,
-     102,     0,   108,     0,   109,     0,   244,     0,     0,     0,
-       0,     0,     0,    92,    66,    27,     0,     0,     0,     0,
-       0,   168,   170,   172,   174,     0,   192,     0,     0,     0,
-       0,   211,   205,     0,   209,     0,     0,     0,     0,   197,
-       0,   147,   122,   142,   135,   149,   117,   118,   186,   188,
-     225,     0,     0,   198,   213,     0,     0,    99,     0,     0,
-     146,     0,    91,    19,     0,     0,     0,     0,    20,    21,
-      22,     0,     0,     0,    64,     0,    42,    56,   173,   181,
-       0,     0,     0,     0,     0,   228,   230,   231,   232,   233,
-     229,   234,   236,     0,     0,     0,     0,   222,     0,     0,
-       0,     0,   206,     0,   212,   204,    45,     0,    46,     0,
-     138,   143,     0,     0,     0,     0,     0,     0,   121,   123,
-     125,   141,     0,     0,   140,     0,   151,   199,     0,   200,
-       0,   101,   103,   134,   245,     0,     0,     0,     0,     0,
-       0,     0,   226,     0,   224,     0,    63,    65,    68,    28,
+     216,    35,    38,    32,    33,     0,     0,     0,     0,     0,
+     116,   117,   121,   188,   190,   192,   195,   196,   197,   194,
+     193,     0,   225,     0,     0,     0,     0,     0,     0,     0,
+      94,     0,     0,     0,   101,   168,     0,     0,    91,   218,
+     219,     0,     0,   212,   209,     0,    43,     0,   221,     0,
+      44,     0,   222,     0,   167,     0,   240,   241,     0,     0,
+     120,   243,   244,   242,     0,     0,   191,     0,     0,   167,
+     103,     0,   109,     0,   110,     0,   245,     0,     0,     0,
+       0,     0,     0,    93,    66,    27,     0,     0,     0,     0,
+       0,   169,   171,   173,   175,     0,   193,     0,     0,     0,
+       0,   212,   206,     0,   210,     0,     0,     0,     0,   198,
+       0,   148,   123,   143,   136,   150,   118,   119,   187,   189,
+     226,     0,     0,   199,   214,     0,     0,   100,     0,     0,
+     147,     0,    92,    19,     0,     0,     0,     0,    20,    21,
+      22,     0,     0,     0,    64,     0,    42,    56,   174,   182,
+       0,     0,     0,     0,     0,   229,   231,   232,   233,   234,
+     230,   235,   237,     0,     0,     0,     0,   223,     0,     0,
+       0,     0,   207,     0,   213,   205,    45,     0,    46,     0,
+     139,   144,     0,     0,     0,     0,     0,     0,   122,   124,
+     126,   142,     0,     0,   141,     0,   152,   200,     0,   201,
+       0,   102,   104,   135,   246,     0,     0,     0,     0,     0,
+       0,     0,   227,     0,   225,     0,    63,    65,    68,    28,
        0,     0,     0,    47,     0,     0,    49,    55,    57,    26,
-     180,   169,   171,   235,   237,     0,     0,     0,     0,   182,
-     179,     0,   178,    89,     0,     0,   210,     0,   203,     0,
-     144,     0,     0,     0,     0,     0,     0,     0,     0,   148,
-     124,     0,     0,   139,     0,     0,   153,   201,   214,     0,
-       0,     0,     0,    95,   250,   251,   249,   248,    96,    94,
-       0,    67,     0,    83,    84,    85,    86,     0,     0,    70,
-      48,     0,    51,    50,     0,    54,     0,     0,   184,     0,
-       0,   177,   223,     0,   207,   202,     0,     0,     0,     0,
-       0,     0,     0,     0,   136,   137,   150,   152,     0,   155,
-      61,     0,     0,    58,     0,     0,   227,     0,    24,    62,
-       0,     0,    23,     0,     0,     0,     0,   175,   183,     0,
-       0,     0,     0,   127,     0,     0,     0,     0,     0,     0,
-     110,     0,    59,    97,    98,     0,    74,    76,    77,    78,
-       0,     0,     0,    52,     0,   176,   185,    88,   133,     0,
-     126,   129,     0,   131,     0,   154,   157,   160,   156,     0,
-      87,     0,    82,    80,     0,    79,     0,    72,    73,     0,
-      53,   132,   128,   130,     0,   161,   162,   163,     0,    75,
-       0,    69,     0,   158,     0,   159,     0,    81,     0,   164,
-     165,     0,     0,    60,     0,    71
+     181,   170,   172,   236,   238,     0,     0,     0,     0,   183,
+     180,     0,   179,    90,     0,     0,   211,     0,   204,     0,
+     145,     0,     0,     0,     0,     0,     0,     0,     0,   149,
+     125,     0,     0,   140,     0,     0,   154,   202,   215,     0,
+       0,     0,     0,    96,   251,   252,   250,   249,    97,    95,
+       0,    67,     0,    83,    84,    85,    86,    87,     0,     0,
+      70,    48,     0,    51,    50,     0,    54,     0,     0,   185,
+       0,     0,   178,   224,     0,   208,   203,     0,     0,     0,
+       0,     0,     0,     0,     0,   137,   138,   151,   153,     0,
+     156,    61,     0,     0,    58,     0,     0,   228,     0,    24,
+      62,     0,     0,    23,     0,     0,     0,     0,   176,   184,
+       0,     0,     0,     0,   128,     0,     0,     0,     0,     0,
+       0,   111,     0,    59,    98,    99,     0,    74,    76,    77,
+      78,     0,     0,     0,    52,     0,   177,   186,    89,   134,
+       0,   127,   130,     0,   132,     0,   155,   158,   161,   157,
+       0,    88,     0,    82,    80,     0,    79,     0,    72,    73,
+       0,    53,   133,   129,   131,     0,   162,   163,   164,     0,
+      75,     0,    69,     0,   159,     0,   160,     0,    81,     0,
+     165,   166,     0,     0,    60,     0,    71
 };
 
   /* YYPGOTO[NTERM-NUM].  */
 static const yytype_int16 yypgoto[] =
 {
-    -222,  -222,  -222,  -222,  -222,  -222,  -222,  -222,  -139,  -222,
-     330,   187,  -222,  -222,  -221,  -222,  -222,  -222,  -222,  -222,
-    -222,    51,    35,  -222,  -222,  -222,  -222,  -222,  -222,  -222,
-    -222,  -222,  -222,  -222,  -222,   292,  -222,  -222,  -222,   390,
-       9,  -222,  -222,  -222,   385,  -222,  -222,  -222,   237,  -100,
-    -222,   232,  -173,   -11,  -222,  -222,  -222,  -222,  -222,  -222,
-      30,  -222,  -222,   -58,  -222,   -92,   273,   274,   342,    -3,
-     384,   382,   410,  -129,  -222,  -222,  -222,   331,  -222,   391,
-     332,  -196,  -175,   132,   -54,  -222,  -222,  -222,  -222,  -222,
-    -105,    -4,   119,  -222,  -222
+    -209,  -209,  -209,  -209,  -209,  -209,  -209,  -209,  -121,  -209,
+     298,   155,  -209,  -209,  -208,  -209,  -209,  -209,  -209,  -209,
+    -209,    22,     8,  -209,  -209,  -209,  -209,  -209,  -209,  -209,
+    -209,  -209,  -209,  -209,  -209,   267,  -209,  -209,  -209,   373,
+      14,  -209,  -209,  -209,   351,  -209,  -209,  -209,   211,  -102,
+    -209,   218,  -183,   -11,  -209,  -209,  -209,  -209,  -209,  -209,
+      12,  -209,  -209,   -54,  -209,   -50,   246,   251,   322,   -30,
+     353,   357,   392,  -129,  -209,  -209,  -209,   315,  -209,   371,
+     317,  -196,  -175,   115,   -86,  -209,  -209,  -209,  -209,  -209,
+    -105,    -4,    99,  -209,  -209
 };
 
   /* YYDEFGOTO[NTERM-NUM].  */
 static const yytype_int16 yydefgoto[] =
 {
       -1,    14,    15,    16,    17,    18,    19,    20,   165,   166,
-      88,   307,   308,   309,   218,   297,   298,   223,   369,   412,
-     469,   435,   436,   437,   438,   439,   366,   408,    21,    22,
+      88,   307,   308,   309,   218,   297,   298,   223,   370,   413,
+     470,   436,   437,   438,   439,   440,   367,   409,    21,    22,
      163,   291,    23,    24,   149,   150,    25,    26,    43,    44,
      209,    41,    89,    90,    91,   134,   268,   269,   270,   190,
-     274,   191,   260,   261,   192,   276,   346,   399,   430,   455,
-     456,   477,   485,   114,   115,   171,   172,   173,   174,   175,
+     274,   191,   260,   261,   192,   276,   346,   400,   431,   456,
+     457,   478,   486,   114,   115,   171,   172,   173,   174,   175,
       93,    94,    95,    96,    97,    98,   181,   182,   123,   124,
      185,   205,    99,   248,   100,   293,   245,   101,   139,   144,
      155,   102,   358,    28,    29
@@ -1017,317 +1016,327 @@ static const yytype_int16 yydefgoto[] =
      number is the opposite.  If YYTABLE_NINF, syntax error.  */
 static const yytype_uint16 yytable[] =
 {
-      33,    45,   247,   296,   193,   154,   278,    42,    46,    27,
-     232,    31,   178,    32,   462,   147,    31,   272,    32,   213,
-     271,   232,   232,   232,   136,   137,    55,   363,   364,   179,
-      57,    58,    59,    60,    61,    51,   463,   183,    92,   183,
-      30,   300,   389,   321,   234,   235,   236,   237,   238,   239,
-     240,   241,   242,   243,    39,   136,   137,   136,   137,   176,
-     141,   142,   136,   137,   136,   137,   122,   176,    50,   229,
-     118,   136,   137,   301,   420,   475,   195,    37,   230,    40,
-     211,   302,   422,    38,   131,   354,   299,   424,   140,    34,
-     273,   207,   365,    45,    10,   121,   476,   180,   426,   151,
-      46,   343,   156,   157,   148,   244,    36,   164,   167,   355,
-     356,   148,   211,   156,   176,   303,   176,   322,   180,   250,
-     211,    35,   380,   187,   304,   211,   310,   372,   305,   194,
-     464,   357,    92,   449,   197,   153,   211,   400,   193,   443,
-       1,   306,     2,   200,   319,   204,   409,   214,   396,   382,
-     313,   314,   315,   452,   167,   327,   219,   220,   189,   334,
-     189,   467,   454,   143,   331,   385,   212,   231,   292,     3,
-     215,   211,    31,   108,    32,   332,    47,   251,   176,   176,
-     254,   416,    54,   352,     4,     5,    46,   468,    56,    46,
-       6,   211,    31,   349,    32,     7,   103,    10,   216,   204,
-     211,   109,   151,   262,   316,   282,   489,   284,   247,   263,
-     116,   106,   379,     8,   264,   217,   378,   265,   294,   259,
-     117,   167,   289,   490,   136,   137,   386,   113,   388,   290,
-     390,   176,   392,     9,   266,    48,   206,    49,   262,    10,
-     317,   105,   320,   104,   263,   401,   402,   326,   330,   264,
-      11,   335,   265,   397,   329,    46,    12,   110,    13,   404,
-     156,   267,   336,   194,   337,   112,   405,   107,   415,   266,
-      46,   111,    31,    52,    32,   338,    53,   348,   113,   413,
-     136,   137,   421,   119,   156,   120,   425,   125,   427,   136,
-     137,   176,   158,   159,   160,   161,   128,   423,   126,   138,
-     127,   374,   210,   211,   224,   225,   249,   211,   406,   136,
-     137,   130,   376,   279,   280,   204,   129,   176,   323,   324,
-     347,   280,   359,   360,   384,   361,   362,   156,   448,   156,
-     450,   156,   451,   156,   453,   176,   403,   211,   418,   280,
-     132,   204,   431,   211,   432,   211,   156,   156,   446,   280,
-     447,   324,   460,   461,   481,   461,   133,   471,   294,   480,
-     472,   135,   473,   487,   211,   153,   176,   162,   176,   177,
-     176,   186,   176,   188,   204,    10,   417,   488,   492,   211,
-     208,   491,   232,   156,   493,   211,   221,   156,   222,   156,
-     233,   246,   255,   256,   257,   176,   258,   275,   176,   286,
-     176,   277,   285,   440,   283,   287,   288,   295,   318,   325,
-     444,   328,   445,   341,   333,   234,   235,   236,   237,   238,
-     239,   240,   241,   242,   243,   457,   136,   137,   342,    31,
-      62,    32,    63,   344,   350,   345,   465,   440,   351,   353,
-     147,   367,   368,   370,   371,   377,    64,    65,   201,   373,
-     383,   381,   394,   387,   391,   478,   393,   440,    67,    68,
-     156,   398,   407,   410,   395,    69,    70,   411,   414,   280,
-     428,   457,    71,    72,    73,   429,   244,   433,   156,   202,
-      74,   441,   156,   442,   458,   459,    75,   470,   484,    76,
-     494,   495,   466,   474,   152,   375,   479,   227,   281,   339,
-      77,    78,   482,   486,   483,   311,   340,   312,    79,    80,
-     228,   146,   252,   253,   184,   419,    31,    62,    32,    63,
-     196,    81,   168,   198,   434,     0,   199,     0,    82,     0,
-       0,    83,    84,    64,    65,     0,     0,     0,     0,    85,
-       0,     0,     0,    86,     0,    67,    68,     0,    87,   203,
-       0,     0,    69,    70,     0,     0,     0,     0,     0,    71,
-      72,    73,     0,     0,     0,     0,     0,    74,     0,     0,
-       0,     0,   169,    75,     0,     0,    76,     0,     0,     0,
-      31,    62,    32,    63,     0,     0,     0,    77,    78,     0,
-       0,     0,     0,     0,     0,    79,    80,    64,    65,    66,
-       0,     0,     0,     0,     0,     0,     0,     0,    81,    67,
-      68,     0,     0,     0,     0,    82,    69,    70,    83,    84,
-       0,     0,     0,    71,    72,    73,    85,     0,     0,     0,
-      86,    74,     0,     0,     0,   170,     0,    75,     0,     0,
-      76,     0,     0,     0,    31,    62,    32,    63,     0,     0,
-       0,    77,    78,     0,     0,     0,     0,     0,     0,    79,
-      80,    64,    65,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,    81,    67,    68,     0,     0,     0,     0,    82,
-      69,    70,    83,    84,     0,     0,     0,    71,    72,    73,
-      85,     0,     0,     0,    86,    74,     0,     0,     0,    87,
-       0,    75,     0,     0,    76,     0,     0,     0,    31,    62,
-      32,    63,     0,     0,     0,    77,    78,     0,     0,     0,
-       0,     0,     0,    79,    80,    64,    65,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,    81,    67,    68,     0,
-       0,     0,     0,    82,    69,    70,    83,    84,     0,     0,
-       0,    71,    72,    73,    85,   121,     0,     0,    86,    74,
-       0,     0,     0,    87,   169,    75,     0,     0,    76,     0,
-       0,     0,    31,    62,    32,    63,     0,     0,     0,    77,
-      78,     0,     0,     0,     0,     0,     0,    79,    80,    64,
-      65,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-      81,    67,    68,     0,     0,     0,     0,    82,    69,    70,
-      83,    84,     0,     0,     0,    71,    72,    73,    85,     0,
-       0,     0,    86,    74,     0,     0,     0,   170,     0,    75,
-       0,     0,    76,     0,     0,     0,    31,    62,    32,    63,
-       0,     0,     0,    77,    78,     0,     0,     0,     0,     0,
-       0,    79,    80,    64,    65,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,    81,    67,    68,     0,    10,     0,
-       0,    82,    69,    70,    83,    84,     0,     0,     0,    71,
-      72,    73,    85,     0,     0,     0,    86,    74,     0,     0,
-       0,    87,     0,    75,     0,     0,    76,     0,     0,     0,
-      31,    62,    32,    63,     0,     0,     0,    77,    78,     0,
-       0,     0,     0,     0,     0,    79,    80,    64,   145,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,    81,    67,
-      68,     0,     0,     0,     0,    82,    69,    70,    83,    84,
-       0,     0,     0,    71,    72,    73,    85,    62,     0,    63,
-      86,    74,     0,     0,     0,    87,     0,    75,     0,     0,
-      76,     0,     0,    64,   145,     0,     0,     0,     0,     0,
-       0,    77,    78,     0,     0,    67,    68,     0,     0,    79,
-      80,     0,     0,    70,     0,     0,     0,     0,     0,    71,
-      72,    73,    81,     0,     0,     0,     0,    74,     0,    82,
-       0,     0,    83,    84,     0,     0,    76,     0,    67,    68,
-      85,     0,     0,     0,    86,     0,    70,    77,    78,    87,
-       0,     0,    71,    72,    73,    79,    80,     0,     0,     0,
-      74,     0,     0,     0,     0,     0,     0,     0,    81,    76,
-       0,     0,     0,     0,     0,    82,     0,     0,    83,    84,
-      77,   226,     0,     0,     0,     0,    85,     0,    79,     0,
-      86,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+      33,    45,   247,   154,   193,   272,   278,    42,    46,   232,
+     271,    92,   178,    31,    27,    32,   296,    31,   232,    32,
+     463,   141,   142,   232,   232,   183,    55,   176,   136,   137,
+      57,    58,    59,    60,    61,   176,   321,   213,   183,   122,
+      51,   390,   464,   421,   136,   137,   214,   234,   235,   236,
+     237,   238,   239,   240,   241,   242,   243,   131,   136,   137,
+     136,   137,   363,   423,   380,   364,   365,   229,   147,   215,
+      30,   179,   425,   136,   137,   118,   136,   137,   273,   211,
+     195,   211,   176,   121,   176,    31,    52,    32,   140,    53,
+     108,   343,   148,    45,    47,   207,   180,   216,    39,   151,
+      46,   211,   156,   157,   299,    92,   427,   164,   167,   244,
+     211,   322,   259,   156,   217,   313,   314,   315,   204,   109,
+     230,   250,   381,   187,    40,   143,   310,   373,   300,   194,
+     366,    38,   189,   153,   197,   401,   292,   465,   193,   180,
+     231,   444,   319,   200,   211,    34,   176,   176,   397,   383,
+     251,   354,   450,   254,   167,   453,   219,   220,   327,   334,
+     410,   301,   189,   455,   386,   148,    50,   158,   159,   302,
+     316,   212,   204,   262,   262,   355,   356,    35,   282,   263,
+     263,   490,   417,   352,   264,   264,    46,   265,   265,    46,
+     211,   468,    10,   211,    31,   331,    32,   357,   491,   176,
+      36,   211,   151,   303,   266,   266,   332,   284,   335,   247,
+      54,   337,   304,   317,   379,   320,   305,   469,   294,   336,
+     326,   167,   338,   136,   137,    37,   387,   329,   389,   306,
+     391,   267,   393,    56,   476,   349,   103,   289,    10,   104,
+      31,   416,    32,   113,   290,   402,   403,    48,   330,    49,
+     348,   116,   206,   136,   137,    46,   477,   136,   137,   176,
+     156,   117,   405,   194,   160,   161,   105,   138,   106,   406,
+      46,   210,   211,   224,   225,   107,   407,   249,   211,   136,
+     137,   279,   280,   422,   156,   377,   176,   426,   204,   428,
+     323,   324,   347,   280,   110,   398,   111,   385,   359,   360,
+     112,   375,   361,   362,   176,   404,   211,   419,   280,   113,
+     432,   211,   433,   211,   204,   119,   447,   280,   448,   324,
+     461,   462,   414,   482,   462,   488,   211,   156,   120,   156,
+     125,   156,   126,   156,   127,   176,   128,   176,   129,   176,
+     424,   176,   493,   211,   494,   211,   156,   156,   204,   130,
+     418,   132,   133,   135,   153,   162,   186,   177,   294,   188,
+     481,   208,    10,   221,   176,   222,   232,   176,   233,   176,
+     255,   449,   256,   451,   246,   452,   257,   454,   489,   258,
+     285,   275,   492,   286,   156,   277,   446,   283,   156,   288,
+     156,   295,   318,   287,   325,     1,   328,     2,   333,   458,
+     472,   344,   341,   473,   441,   474,   342,   345,   350,   353,
+     351,   445,   147,   368,   369,   371,   372,   378,   374,   382,
+     388,   384,   392,   394,     3,   395,   396,   411,   399,   408,
+      31,    62,    32,    63,   415,   434,   412,   466,   441,   430,
+       4,     5,   280,   429,   442,   458,     6,    64,    65,   201,
+     443,     7,   459,   460,   471,   485,   479,   495,   441,    67,
+      68,   156,   496,   376,   467,   227,   475,    69,    70,     8,
+     480,   483,   487,   281,    71,    72,    73,   152,   311,   156,
+     340,   202,    74,   156,   312,   339,   196,   484,    75,     9,
+     228,    76,   198,   146,   184,    10,   252,     0,   253,   420,
+       0,   199,    77,    78,     0,   435,    11,     0,     0,     0,
+      79,    80,    12,     0,    13,     0,     0,     0,    31,    62,
+      32,    63,     0,    81,   168,     0,     0,     0,     0,     0,
+      82,     0,     0,    83,    84,    64,    65,     0,     0,     0,
+       0,    85,     0,     0,     0,    86,     0,    67,    68,     0,
+      87,   203,     0,     0,     0,    69,    70,     0,     0,     0,
+       0,     0,    71,    72,    73,     0,     0,     0,     0,     0,
+      74,     0,     0,     0,     0,   169,    75,     0,     0,    76,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+      77,    78,     0,     0,     0,     0,     0,     0,    79,    80,
+       0,     0,     0,     0,     0,     0,    31,    62,    32,    63,
        0,    81,     0,     0,     0,     0,     0,     0,    82,     0,
-       0,    83,    84,     0,     0,     0,     0,     0,     0,    85,
-       0,     0,     0,    86
+       0,    83,    84,    64,    65,    66,     0,     0,     0,    85,
+       0,     0,     0,    86,     0,    67,    68,     0,   170,    31,
+      62,    32,    63,    69,    70,     0,     0,     0,     0,     0,
+      71,    72,    73,     0,     0,     0,    64,    65,    74,     0,
+       0,     0,     0,     0,    75,     0,     0,    76,    67,    68,
+       0,     0,     0,     0,     0,     0,    69,    70,    77,    78,
+       0,     0,     0,    71,    72,    73,    79,    80,     0,     0,
+       0,    74,     0,     0,     0,     0,     0,    75,     0,    81,
+      76,     0,     0,     0,     0,     0,    82,     0,     0,    83,
+      84,    77,    78,     0,     0,     0,     0,    85,     0,    79,
+      80,    86,     0,     0,     0,     0,    87,    31,    62,    32,
+      63,     0,    81,     0,     0,     0,     0,     0,     0,    82,
+       0,     0,    83,    84,    64,    65,     0,     0,     0,     0,
+      85,   121,     0,     0,    86,     0,    67,    68,     0,    87,
+      31,    62,    32,    63,    69,    70,     0,     0,     0,     0,
+       0,    71,    72,    73,     0,     0,     0,    64,    65,    74,
+       0,     0,     0,     0,   169,    75,     0,     0,    76,    67,
+      68,     0,     0,     0,     0,     0,     0,    69,    70,    77,
+      78,     0,     0,     0,    71,    72,    73,    79,    80,     0,
+       0,     0,    74,     0,     0,     0,     0,     0,    75,     0,
+      81,    76,     0,     0,     0,     0,     0,    82,     0,     0,
+      83,    84,    77,    78,     0,     0,     0,     0,    85,     0,
+      79,    80,    86,     0,     0,     0,     0,   170,    31,    62,
+      32,    63,     0,    81,     0,     0,     0,    10,     0,     0,
+      82,     0,     0,    83,    84,    64,    65,     0,     0,     0,
+       0,    85,     0,     0,     0,    86,     0,    67,    68,     0,
+      87,    31,    62,    32,    63,    69,    70,     0,     0,     0,
+       0,     0,    71,    72,    73,     0,     0,     0,    64,   145,
+      74,     0,     0,     0,     0,     0,    75,     0,     0,    76,
+      67,    68,     0,     0,     0,     0,     0,     0,    69,    70,
+      77,    78,     0,     0,     0,    71,    72,    73,    79,    80,
+       0,     0,     0,    74,     0,     0,     0,     0,     0,    75,
+       0,    81,    76,     0,     0,     0,     0,     0,    82,     0,
+       0,    83,    84,    77,    78,     0,     0,     0,     0,    85,
+       0,    79,    80,    86,     0,     0,     0,     0,    87,     0,
+      62,     0,    63,     0,    81,     0,     0,     0,     0,     0,
+       0,    82,     0,     0,    83,    84,    64,   145,     0,     0,
+       0,     0,    85,    67,    68,     0,    86,     0,    67,    68,
+       0,    87,    70,     0,     0,     0,     0,    70,    71,    72,
+      73,     0,     0,    71,    72,    73,    74,     0,     0,     0,
+       0,    74,     0,     0,     0,    76,     0,     0,     0,     0,
+      76,     0,     0,     0,     0,     0,    77,   226,     0,     0,
+       0,    77,    78,     0,    79,     0,     0,     0,     0,    79,
+      80,     0,     0,     0,     0,     0,     0,    81,     0,     0,
+       0,     0,    81,     0,    82,     0,     0,    83,    84,    82,
+       0,     0,    83,    84,     0,    85,     0,     0,     0,    86,
+      85,     0,     0,     0,    86,   234,   235,   236,   237,   238,
+     239,   240,   241,   242,   243,     0,   136,   137,     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,   244
 };
 
 static const yytype_int16 yycheck[] =
 {
-       4,    12,   177,   224,   133,   105,   202,    11,    12,     0,
-       8,     4,   117,     6,     7,    27,     4,    36,     6,   158,
-     193,     8,     8,     8,    21,    22,    30,    37,    38,   121,
-      34,    35,    36,    37,    38,    26,    29,    57,    41,    57,
-     104,    10,    87,    10,    10,    11,    12,    13,    14,    15,
-      16,    17,    18,    19,    29,    21,    22,    21,    22,   113,
-      23,    24,    21,    22,    21,    22,    69,   121,    74,   169,
-      61,    21,    22,    42,    87,    32,   134,   104,   170,    54,
-     125,    50,    87,    77,    87,    62,   225,    87,    92,    72,
-     109,   149,   102,   104,   100,   115,    53,   115,    87,   103,
-     104,   274,   106,   107,   123,    71,    66,   111,   112,    86,
-      87,   123,   125,   117,   168,    84,   170,    84,   115,   105,
-     125,   104,   318,   127,    93,   125,   124,   302,    97,   133,
-     123,   108,   135,    87,   138,   123,   125,   124,   267,   124,
-       1,   110,     3,   147,   244,   148,   367,    42,   344,   324,
-      17,    18,    19,    87,   158,   105,   160,   161,   124,   264,
-     124,    69,    87,   126,    78,   124,   157,   170,   222,    30,
-      65,   125,     4,    28,     6,    89,     0,   180,   232,   233,
-     183,   377,     3,   288,    45,    46,   190,    95,    66,   193,
-      51,   125,     4,   285,     6,    56,   101,   100,    93,   202,
-     125,    56,   206,    67,    71,   208,    63,   211,   383,    73,
-     113,   123,     9,    74,    78,   110,   316,    81,   222,    31,
-     123,   225,    52,    80,    21,    22,   331,   116,   333,    59,
-     335,   285,   337,    94,    98,   119,   125,   121,    67,   100,
-     243,    31,   245,   125,    73,   350,   351,   250,   259,    78,
-     111,    78,    81,   345,   257,   259,   117,     5,   119,    52,
-     264,   125,    89,   267,    78,   123,    59,    77,     9,    98,
-     274,    87,     4,   119,     6,    89,   122,   280,   116,   371,
-      21,    22,   387,     7,   288,     7,   391,   123,   393,    21,
-      22,   345,    43,    44,    43,    44,     5,   389,    76,    31,
-     123,   305,   124,   125,   124,   125,   124,   125,   362,    21,
-      22,    76,   315,   124,   125,   318,   123,   371,   124,   125,
-     124,   125,   124,   125,   327,   124,   125,   331,   420,   333,
-     422,   335,   424,   337,   426,   389,   124,   125,   124,   125,
-       5,   344,   124,   125,   124,   125,   350,   351,   124,   125,
-     124,   125,   124,   125,   124,   125,    66,   449,   362,   464,
-     452,   125,   454,   124,   125,   123,   420,   117,   422,   123,
-     424,     7,   426,     7,   377,   100,   379,   482,   124,   125,
-      11,   486,     8,   387,   124,   125,   123,   391,   123,   393,
-       9,    20,    58,   124,    66,   449,   124,    68,   452,    79,
-     454,   124,   123,   407,   124,    79,   123,   112,   123,   113,
-     414,    58,   415,     7,    78,    10,    11,    12,    13,    14,
-      15,    16,    17,    18,    19,   428,    21,    22,     7,     4,
-       5,     6,     7,    39,   123,    70,   440,   441,   123,     5,
-      27,   125,   117,    84,   123,   123,    21,    22,    23,    79,
-     123,    84,    92,    78,    78,   459,    78,   461,    33,    34,
-     464,    88,   123,    35,    92,    40,    41,    90,   123,   125,
-      39,   474,    47,    48,    49,    82,    71,     5,   482,    54,
-      55,   123,   486,    39,     7,    97,    61,   124,    85,    64,
-      91,     7,   441,   125,   104,   308,   461,   167,   206,   267,
-      75,    76,   123,   123,   474,   232,   269,   233,    83,    84,
-     168,   101,   181,   181,   123,   383,     4,     5,     6,     7,
-     135,    96,    10,   139,   405,    -1,   144,    -1,   103,    -1,
-      -1,   106,   107,    21,    22,    -1,    -1,    -1,    -1,   114,
-      -1,    -1,    -1,   118,    -1,    33,    34,    -1,   123,   124,
-      -1,    -1,    40,    41,    -1,    -1,    -1,    -1,    -1,    47,
-      48,    49,    -1,    -1,    -1,    -1,    -1,    55,    -1,    -1,
-      -1,    -1,    60,    61,    -1,    -1,    64,    -1,    -1,    -1,
-       4,     5,     6,     7,    -1,    -1,    -1,    75,    76,    -1,
-      -1,    -1,    -1,    -1,    -1,    83,    84,    21,    22,    23,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    96,    33,
-      34,    -1,    -1,    -1,    -1,   103,    40,    41,   106,   107,
-      -1,    -1,    -1,    47,    48,    49,   114,    -1,    -1,    -1,
-     118,    55,    -1,    -1,    -1,   123,    -1,    61,    -1,    -1,
-      64,    -1,    -1,    -1,     4,     5,     6,     7,    -1,    -1,
-      -1,    75,    76,    -1,    -1,    -1,    -1,    -1,    -1,    83,
-      84,    21,    22,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    96,    33,    34,    -1,    -1,    -1,    -1,   103,
-      40,    41,   106,   107,    -1,    -1,    -1,    47,    48,    49,
-     114,    -1,    -1,    -1,   118,    55,    -1,    -1,    -1,   123,
-      -1,    61,    -1,    -1,    64,    -1,    -1,    -1,     4,     5,
-       6,     7,    -1,    -1,    -1,    75,    76,    -1,    -1,    -1,
-      -1,    -1,    -1,    83,    84,    21,    22,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    96,    33,    34,    -1,
-      -1,    -1,    -1,   103,    40,    41,   106,   107,    -1,    -1,
-      -1,    47,    48,    49,   114,   115,    -1,    -1,   118,    55,
-      -1,    -1,    -1,   123,    60,    61,    -1,    -1,    64,    -1,
-      -1,    -1,     4,     5,     6,     7,    -1,    -1,    -1,    75,
-      76,    -1,    -1,    -1,    -1,    -1,    -1,    83,    84,    21,
-      22,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      96,    33,    34,    -1,    -1,    -1,    -1,   103,    40,    41,
-     106,   107,    -1,    -1,    -1,    47,    48,    49,   114,    -1,
-      -1,    -1,   118,    55,    -1,    -1,    -1,   123,    -1,    61,
-      -1,    -1,    64,    -1,    -1,    -1,     4,     5,     6,     7,
-      -1,    -1,    -1,    75,    76,    -1,    -1,    -1,    -1,    -1,
-      -1,    83,    84,    21,    22,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    96,    33,    34,    -1,   100,    -1,
-      -1,   103,    40,    41,   106,   107,    -1,    -1,    -1,    47,
-      48,    49,   114,    -1,    -1,    -1,   118,    55,    -1,    -1,
-      -1,   123,    -1,    61,    -1,    -1,    64,    -1,    -1,    -1,
-       4,     5,     6,     7,    -1,    -1,    -1,    75,    76,    -1,
-      -1,    -1,    -1,    -1,    -1,    83,    84,    21,    22,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    96,    33,
-      34,    -1,    -1,    -1,    -1,   103,    40,    41,   106,   107,
-      -1,    -1,    -1,    47,    48,    49,   114,     5,    -1,     7,
-     118,    55,    -1,    -1,    -1,   123,    -1,    61,    -1,    -1,
-      64,    -1,    -1,    21,    22,    -1,    -1,    -1,    -1,    -1,
-      -1,    75,    76,    -1,    -1,    33,    34,    -1,    -1,    83,
-      84,    -1,    -1,    41,    -1,    -1,    -1,    -1,    -1,    47,
-      48,    49,    96,    -1,    -1,    -1,    -1,    55,    -1,   103,
-      -1,    -1,   106,   107,    -1,    -1,    64,    -1,    33,    34,
-     114,    -1,    -1,    -1,   118,    -1,    41,    75,    76,   123,
-      -1,    -1,    47,    48,    49,    83,    84,    -1,    -1,    -1,
-      55,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    96,    64,
-      -1,    -1,    -1,    -1,    -1,   103,    -1,    -1,   106,   107,
-      75,    76,    -1,    -1,    -1,    -1,   114,    -1,    83,    -1,
-     118,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    96,    -1,    -1,    -1,    -1,    -1,    -1,   103,    -1,
-      -1,   106,   107,    -1,    -1,    -1,    -1,    -1,    -1,   114,
-      -1,    -1,    -1,   118
+       4,    12,   177,   105,   133,    37,   202,    11,    12,     8,
+     193,    41,   117,     4,     0,     6,   224,     4,     8,     6,
+       7,    23,    24,     8,     8,    58,    30,   113,    21,    22,
+      34,    35,    36,    37,    38,   121,    10,   158,    58,    69,
+      26,    88,    29,    88,    21,    22,    43,    10,    11,    12,
+      13,    14,    15,    16,    17,    18,    19,    87,    21,    22,
+      21,    22,    35,    88,     9,    38,    39,   169,    27,    66,
+     105,   121,    88,    21,    22,    61,    21,    22,   110,   126,
+     134,   126,   168,   116,   170,     4,   120,     6,    92,   123,
+      28,   274,   124,   104,     0,   149,   116,    94,    29,   103,
+     104,   126,   106,   107,   225,   135,    88,   111,   112,    72,
+     126,    85,    31,   117,   111,    17,    18,    19,   148,    57,
+     170,   106,   318,   127,    55,   127,   125,   302,    10,   133,
+     103,    78,   125,   124,   138,   125,   222,   124,   267,   116,
+     170,   125,   244,   147,   126,    73,   232,   233,   344,   324,
+     180,    63,    88,   183,   158,    88,   160,   161,   106,   264,
+     368,    43,   125,    88,   125,   124,    75,    44,    45,    51,
+      72,   157,   202,    68,    68,    87,    88,   105,   208,    74,
+      74,    64,   378,   288,    79,    79,   190,    82,    82,   193,
+     126,    70,   101,   126,     4,    79,     6,   109,    81,   285,
+      67,   126,   206,    85,    99,    99,    90,   211,    79,   384,
+       3,    79,    94,   243,   316,   245,    98,    96,   222,    90,
+     250,   225,    90,    21,    22,   105,   331,   257,   333,   111,
+     335,   126,   337,    67,    32,   285,   102,    53,   101,   126,
+       4,     9,     6,   117,    60,   350,   351,   120,   259,   122,
+     280,   114,   126,    21,    22,   259,    54,    21,    22,   345,
+     264,   124,    53,   267,    44,    45,    31,    31,   124,    60,
+     274,   125,   126,   125,   126,    78,   362,   125,   126,    21,
+      22,   125,   126,   388,   288,   315,   372,   392,   318,   394,
+     125,   126,   125,   126,     5,   345,    88,   327,   125,   126,
+     124,   305,   125,   126,   390,   125,   126,   125,   126,   117,
+     125,   126,   125,   126,   344,     7,   125,   126,   125,   126,
+     125,   126,   372,   125,   126,   125,   126,   331,     7,   333,
+     124,   335,    77,   337,   124,   421,     5,   423,   124,   425,
+     390,   427,   125,   126,   125,   126,   350,   351,   378,    77,
+     380,     5,    67,   126,   124,   118,     7,   124,   362,     7,
+     465,    11,   101,   124,   450,   124,     8,   453,     9,   455,
+      59,   421,   125,   423,    20,   425,    67,   427,   483,   125,
+     124,    69,   487,    80,   388,   125,   416,   125,   392,   124,
+     394,   113,   124,    80,   114,     1,    59,     3,    79,   429,
+     450,    40,     7,   453,   408,   455,     7,    71,   124,     5,
+     124,   415,    27,   126,   118,    85,   124,   124,    80,    85,
+      79,   124,    79,    79,    30,    93,    93,    36,    89,   124,
+       4,     5,     6,     7,   124,     5,    91,   441,   442,    83,
+      46,    47,   126,    40,   124,   475,    52,    21,    22,    23,
+      40,    57,     7,    98,   125,    86,   460,    92,   462,    33,
+      34,   465,     7,   308,   442,   167,   126,    41,    42,    75,
+     462,   124,   124,   206,    48,    49,    50,   104,   232,   483,
+     269,    55,    56,   487,   233,   267,   135,   475,    62,    95,
+     168,    65,   139,   101,   123,   101,   181,    -1,   181,   384,
+      -1,   144,    76,    77,    -1,   406,   112,    -1,    -1,    -1,
+      84,    85,   118,    -1,   120,    -1,    -1,    -1,     4,     5,
+       6,     7,    -1,    97,    10,    -1,    -1,    -1,    -1,    -1,
+     104,    -1,    -1,   107,   108,    21,    22,    -1,    -1,    -1,
+      -1,   115,    -1,    -1,    -1,   119,    -1,    33,    34,    -1,
+     124,   125,    -1,    -1,    -1,    41,    42,    -1,    -1,    -1,
+      -1,    -1,    48,    49,    50,    -1,    -1,    -1,    -1,    -1,
+      56,    -1,    -1,    -1,    -1,    61,    62,    -1,    -1,    65,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      76,    77,    -1,    -1,    -1,    -1,    -1,    -1,    84,    85,
+      -1,    -1,    -1,    -1,    -1,    -1,     4,     5,     6,     7,
+      -1,    97,    -1,    -1,    -1,    -1,    -1,    -1,   104,    -1,
+      -1,   107,   108,    21,    22,    23,    -1,    -1,    -1,   115,
+      -1,    -1,    -1,   119,    -1,    33,    34,    -1,   124,     4,
+       5,     6,     7,    41,    42,    -1,    -1,    -1,    -1,    -1,
+      48,    49,    50,    -1,    -1,    -1,    21,    22,    56,    -1,
+      -1,    -1,    -1,    -1,    62,    -1,    -1,    65,    33,    34,
+      -1,    -1,    -1,    -1,    -1,    -1,    41,    42,    76,    77,
+      -1,    -1,    -1,    48,    49,    50,    84,    85,    -1,    -1,
+      -1,    56,    -1,    -1,    -1,    -1,    -1,    62,    -1,    97,
+      65,    -1,    -1,    -1,    -1,    -1,   104,    -1,    -1,   107,
+     108,    76,    77,    -1,    -1,    -1,    -1,   115,    -1,    84,
+      85,   119,    -1,    -1,    -1,    -1,   124,     4,     5,     6,
+       7,    -1,    97,    -1,    -1,    -1,    -1,    -1,    -1,   104,
+      -1,    -1,   107,   108,    21,    22,    -1,    -1,    -1,    -1,
+     115,   116,    -1,    -1,   119,    -1,    33,    34,    -1,   124,
+       4,     5,     6,     7,    41,    42,    -1,    -1,    -1,    -1,
+      -1,    48,    49,    50,    -1,    -1,    -1,    21,    22,    56,
+      -1,    -1,    -1,    -1,    61,    62,    -1,    -1,    65,    33,
+      34,    -1,    -1,    -1,    -1,    -1,    -1,    41,    42,    76,
+      77,    -1,    -1,    -1,    48,    49,    50,    84,    85,    -1,
+      -1,    -1,    56,    -1,    -1,    -1,    -1,    -1,    62,    -1,
+      97,    65,    -1,    -1,    -1,    -1,    -1,   104,    -1,    -1,
+     107,   108,    76,    77,    -1,    -1,    -1,    -1,   115,    -1,
+      84,    85,   119,    -1,    -1,    -1,    -1,   124,     4,     5,
+       6,     7,    -1,    97,    -1,    -1,    -1,   101,    -1,    -1,
+     104,    -1,    -1,   107,   108,    21,    22,    -1,    -1,    -1,
+      -1,   115,    -1,    -1,    -1,   119,    -1,    33,    34,    -1,
+     124,     4,     5,     6,     7,    41,    42,    -1,    -1,    -1,
+      -1,    -1,    48,    49,    50,    -1,    -1,    -1,    21,    22,
+      56,    -1,    -1,    -1,    -1,    -1,    62,    -1,    -1,    65,
+      33,    34,    -1,    -1,    -1,    -1,    -1,    -1,    41,    42,
+      76,    77,    -1,    -1,    -1,    48,    49,    50,    84,    85,
+      -1,    -1,    -1,    56,    -1,    -1,    -1,    -1,    -1,    62,
+      -1,    97,    65,    -1,    -1,    -1,    -1,    -1,   104,    -1,
+      -1,   107,   108,    76,    77,    -1,    -1,    -1,    -1,   115,
+      -1,    84,    85,   119,    -1,    -1,    -1,    -1,   124,    -1,
+       5,    -1,     7,    -1,    97,    -1,    -1,    -1,    -1,    -1,
+      -1,   104,    -1,    -1,   107,   108,    21,    22,    -1,    -1,
+      -1,    -1,   115,    33,    34,    -1,   119,    -1,    33,    34,
+      -1,   124,    42,    -1,    -1,    -1,    -1,    42,    48,    49,
+      50,    -1,    -1,    48,    49,    50,    56,    -1,    -1,    -1,
+      -1,    56,    -1,    -1,    -1,    65,    -1,    -1,    -1,    -1,
+      65,    -1,    -1,    -1,    -1,    -1,    76,    77,    -1,    -1,
+      -1,    76,    77,    -1,    84,    -1,    -1,    -1,    -1,    84,
+      85,    -1,    -1,    -1,    -1,    -1,    -1,    97,    -1,    -1,
+      -1,    -1,    97,    -1,   104,    -1,    -1,   107,   108,   104,
+      -1,    -1,   107,   108,    -1,   115,    -1,    -1,    -1,   119,
+     115,    -1,    -1,    -1,   119,    10,    11,    12,    13,    14,
+      15,    16,    17,    18,    19,    -1,    21,    22,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    72
 };
 
   /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
      symbol of state STATE-NUM.  */
 static const yytype_uint8 yystos[] =
 {
-       0,     1,     3,    30,    45,    46,    51,    56,    74,    94,
-     100,   111,   117,   119,   128,   129,   130,   131,   132,   133,
-     134,   155,   156,   159,   160,   163,   164,   167,   220,   221,
-     104,     4,     6,   218,    72,   104,    66,   104,    77,    29,
-      54,   168,   218,   165,   166,   180,   218,     0,   119,   121,
-      74,   167,   119,   122,     3,   218,    66,   218,   218,   218,
-     218,   218,     5,     7,    21,    22,    23,    33,    34,    40,
-      41,    47,    48,    49,    55,    61,    64,    75,    76,    83,
-      84,    96,   103,   106,   107,   114,   118,   123,   137,   169,
-     170,   171,   196,   197,   198,   199,   200,   201,   202,   209,
-     211,   214,   218,   101,   125,    31,   123,    77,    28,    56,
-       5,    87,   123,   116,   190,   191,   113,   123,   167,     7,
-       7,   115,   196,   205,   206,   123,    76,   123,     5,   123,
-      76,   196,     5,    66,   172,   125,    21,    22,    31,   215,
-     218,    23,    24,   126,   216,    22,   199,    27,   123,   161,
-     162,   218,   166,   123,   176,   217,   218,   218,    43,    44,
-      43,    44,   117,   157,   218,   135,   136,   218,    10,    60,
-     123,   192,   193,   194,   195,   196,   211,   123,   217,   192,
-     115,   203,   204,    57,   206,   207,     7,   218,     7,   124,
-     176,   178,   181,   200,   218,   190,   171,   218,   197,   198,
-     218,    23,    54,   124,   196,   208,   125,   190,    11,   167,
-     124,   125,   167,   135,    42,    65,    93,   110,   141,   218,
-     218,   123,   123,   144,   124,   125,    76,   137,   195,   176,
-     192,   196,     8,     9,    10,    11,    12,    13,    14,    15,
-      16,    17,    18,    19,    71,   213,    20,   209,   210,   124,
-     105,   196,   204,   207,   196,    58,   124,    66,   124,    31,
-     179,   180,    67,    73,    78,    81,    98,   125,   173,   174,
-     175,   179,    36,   109,   177,    68,   182,   124,   208,   124,
-     125,   162,   196,   124,   218,   123,    79,    79,   123,    52,
-      59,   158,   211,   212,   218,   112,   141,   142,   143,   135,
-      10,    42,    50,    84,    93,    97,   110,   138,   139,   140,
-     124,   193,   194,    17,    18,    19,    71,   196,   123,   176,
-     196,    10,    84,   124,   125,   113,   196,   105,    58,   196,
-     180,    78,    89,    78,   217,    78,    89,    78,    89,   178,
-     175,     7,     7,   179,    39,    70,   183,   124,   196,   192,
-     123,   123,   217,     5,    62,    86,    87,   108,   219,   124,
-     125,   124,   125,    37,    38,   102,   153,   125,   117,   145,
-      84,   123,   209,    79,   218,   138,   196,   123,   176,     9,
-     208,    84,   209,   123,   196,   124,   217,    78,   217,    87,
-     217,    78,   217,    78,    92,    92,   208,   192,    88,   184,
-     124,   217,   217,   124,    52,    59,   211,   123,   154,   141,
-      35,    90,   146,   192,   123,     9,   208,   196,   124,   210,
-      87,   217,    87,   192,    87,   217,    87,   217,    39,    82,
-     185,   124,   124,     5,   219,   148,   149,   150,   151,   152,
-     218,   123,    39,   124,   218,   196,   124,   124,   192,    87,
-     192,   192,    87,   192,    87,   186,   187,   196,     7,    97,
-     124,   125,     7,    29,   123,   218,   148,    69,    95,   147,
-     124,   192,   192,   192,   125,    32,    53,   188,   218,   149,
-     217,   124,   123,   187,    85,   189,   123,   124,   217,    63,
-      80,   217,   124,   124,    91,     7
+       0,     1,     3,    30,    46,    47,    52,    57,    75,    95,
+     101,   112,   118,   120,   129,   130,   131,   132,   133,   134,
+     135,   156,   157,   160,   161,   164,   165,   168,   221,   222,
+     105,     4,     6,   219,    73,   105,    67,   105,    78,    29,
+      55,   169,   219,   166,   167,   181,   219,     0,   120,   122,
+      75,   168,   120,   123,     3,   219,    67,   219,   219,   219,
+     219,   219,     5,     7,    21,    22,    23,    33,    34,    41,
+      42,    48,    49,    50,    56,    62,    65,    76,    77,    84,
+      85,    97,   104,   107,   108,   115,   119,   124,   138,   170,
+     171,   172,   197,   198,   199,   200,   201,   202,   203,   210,
+     212,   215,   219,   102,   126,    31,   124,    78,    28,    57,
+       5,    88,   124,   117,   191,   192,   114,   124,   168,     7,
+       7,   116,   197,   206,   207,   124,    77,   124,     5,   124,
+      77,   197,     5,    67,   173,   126,    21,    22,    31,   216,
+     219,    23,    24,   127,   217,    22,   200,    27,   124,   162,
+     163,   219,   167,   124,   177,   218,   219,   219,    44,    45,
+      44,    45,   118,   158,   219,   136,   137,   219,    10,    61,
+     124,   193,   194,   195,   196,   197,   212,   124,   218,   193,
+     116,   204,   205,    58,   207,   208,     7,   219,     7,   125,
+     177,   179,   182,   201,   219,   191,   172,   219,   198,   199,
+     219,    23,    55,   125,   197,   209,   126,   191,    11,   168,
+     125,   126,   168,   136,    43,    66,    94,   111,   142,   219,
+     219,   124,   124,   145,   125,   126,    77,   138,   196,   177,
+     193,   197,     8,     9,    10,    11,    12,    13,    14,    15,
+      16,    17,    18,    19,    72,   214,    20,   210,   211,   125,
+     106,   197,   205,   208,   197,    59,   125,    67,   125,    31,
+     180,   181,    68,    74,    79,    82,    99,   126,   174,   175,
+     176,   180,    37,   110,   178,    69,   183,   125,   209,   125,
+     126,   163,   197,   125,   219,   124,    80,    80,   124,    53,
+      60,   159,   212,   213,   219,   113,   142,   143,   144,   136,
+      10,    43,    51,    85,    94,    98,   111,   139,   140,   141,
+     125,   194,   195,    17,    18,    19,    72,   197,   124,   177,
+     197,    10,    85,   125,   126,   114,   197,   106,    59,   197,
+     181,    79,    90,    79,   218,    79,    90,    79,    90,   179,
+     176,     7,     7,   180,    40,    71,   184,   125,   197,   193,
+     124,   124,   218,     5,    63,    87,    88,   109,   220,   125,
+     126,   125,   126,    35,    38,    39,   103,   154,   126,   118,
+     146,    85,   124,   210,    80,   219,   139,   197,   124,   177,
+       9,   209,    85,   210,   124,   197,   125,   218,    79,   218,
+      88,   218,    79,   218,    79,    93,    93,   209,   193,    89,
+     185,   125,   218,   218,   125,    53,    60,   212,   124,   155,
+     142,    36,    91,   147,   193,   124,     9,   209,   197,   125,
+     211,    88,   218,    88,   193,    88,   218,    88,   218,    40,
+      83,   186,   125,   125,     5,   220,   149,   150,   151,   152,
+     153,   219,   124,    40,   125,   219,   197,   125,   125,   193,
+      88,   193,   193,    88,   193,    88,   187,   188,   197,     7,
+      98,   125,   126,     7,    29,   124,   219,   149,    70,    96,
+     148,   125,   193,   193,   193,   126,    32,    54,   189,   219,
+     150,   218,   125,   124,   188,    86,   190,   124,   125,   218,
+      64,    81,   218,   125,   125,    92,     7
 };
 
   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
 static const yytype_uint8 yyr1[] =
 {
-       0,   127,   128,   128,   128,   128,   128,   128,   129,   129,
-     129,   129,   129,   129,   129,   129,   129,   129,   130,   131,
-     131,   131,   131,   132,   133,   134,   135,   136,   136,   137,
-     137,   137,   137,   137,   137,   137,   137,   137,   137,   137,
-     137,   137,   137,   137,   137,   137,   137,   138,   138,   138,
-     138,   138,   138,   138,   139,   139,   140,   140,   141,   141,
-     141,   141,   142,   142,   143,   143,   144,   144,   145,   145,
-     146,   146,   147,   147,   148,   148,   149,   149,   149,   150,
-     150,   151,   152,   153,   153,   153,   154,   154,   155,   155,
-     155,   155,   156,   157,   157,   158,   158,   158,   158,   159,
-     160,   161,   161,   162,   163,   163,   164,   165,   165,   166,
-     167,   168,   168,   168,   169,   169,   170,   170,   171,   171,
-     171,   172,   173,   173,   174,   174,   175,   175,   175,   175,
-     175,   175,   175,   175,   176,   177,   177,   177,   178,   178,
-     178,   178,   178,   179,   179,   180,   180,   181,   181,   182,
-     182,   183,   183,   184,   184,   185,   185,   186,   186,   187,
-     188,   188,   188,   189,   189,   189,   190,   190,   191,   192,
-     192,   193,   193,   194,   194,   195,   195,   195,   195,   195,
-     195,   195,   195,   195,   195,   195,   196,   196,   197,   197,
-     198,   198,   199,   199,   199,   199,   199,   199,   200,   200,
-     200,   200,   201,   202,   202,   203,   203,   204,   205,   205,
-     206,   207,   207,   208,   208,   209,   209,   209,   209,   209,
-     209,   209,   210,   210,   211,   211,   212,   212,   213,   213,
-     213,   213,   213,   213,   213,   213,   213,   213,   214,   215,
-     215,   216,   216,   216,   217,   217,   218,   218,   219,   219,
-     219,   219,   220,   221,   221
+       0,   128,   129,   129,   129,   129,   129,   129,   130,   130,
+     130,   130,   130,   130,   130,   130,   130,   130,   131,   132,
+     132,   132,   132,   133,   134,   135,   136,   137,   137,   138,
+     138,   138,   138,   138,   138,   138,   138,   138,   138,   138,
+     138,   138,   138,   138,   138,   138,   138,   139,   139,   139,
+     139,   139,   139,   139,   140,   140,   141,   141,   142,   142,
+     142,   142,   143,   143,   144,   144,   145,   145,   146,   146,
+     147,   147,   148,   148,   149,   149,   150,   150,   150,   151,
+     151,   152,   153,   154,   154,   154,   154,   155,   155,   156,
+     156,   156,   156,   157,   158,   158,   159,   159,   159,   159,
+     160,   161,   162,   162,   163,   164,   164,   165,   166,   166,
+     167,   168,   169,   169,   169,   170,   170,   171,   171,   172,
+     172,   172,   173,   174,   174,   175,   175,   176,   176,   176,
+     176,   176,   176,   176,   176,   177,   178,   178,   178,   179,
+     179,   179,   179,   179,   180,   180,   181,   181,   182,   182,
+     183,   183,   184,   184,   185,   185,   186,   186,   187,   187,
+     188,   189,   189,   189,   190,   190,   190,   191,   191,   192,
+     193,   193,   194,   194,   195,   195,   196,   196,   196,   196,
+     196,   196,   196,   196,   196,   196,   196,   197,   197,   198,
+     198,   199,   199,   200,   200,   200,   200,   200,   200,   201,
+     201,   201,   201,   202,   203,   203,   204,   204,   205,   206,
+     206,   207,   208,   208,   209,   209,   210,   210,   210,   210,
+     210,   210,   210,   211,   211,   212,   212,   213,   213,   214,
+     214,   214,   214,   214,   214,   214,   214,   214,   214,   215,
+     216,   216,   217,   217,   217,   218,   218,   219,   219,   220,
+     220,   220,   220,   221,   222,   222
 };
 
   /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
@@ -1341,24 +1350,24 @@ static const yytype_uint8 yyr2[] =
        2,     2,     4,     5,     2,     1,     0,     1,     4,     5,
       10,     4,     3,     1,     0,     1,     0,     3,     0,     5,
        0,     8,     1,     1,     1,     3,     1,     1,     1,     2,
-       2,     4,     2,     1,     1,     1,     0,     3,    10,     7,
-       4,     5,     5,     0,     4,     2,     2,     4,     4,     5,
-       4,     3,     1,     3,     1,     2,     2,     1,     3,     3,
-       9,     0,     1,     1,     1,     1,     1,     3,     3,     2,
-       1,     3,     0,     1,     2,     1,     5,     4,     6,     5,
-       6,     5,     6,     5,     3,     0,     3,     3,     2,     3,
-       2,     2,     1,     1,     2,     1,     4,     1,     3,     0,
-       3,     0,     2,     0,     3,     0,     2,     1,     3,     3,
-       0,     1,     1,     0,     2,     2,     0,     1,     2,     3,
-       1,     3,     1,     2,     1,     5,     6,     4,     3,     3,
-       3,     2,     3,     5,     4,     6,     3,     1,     3,     1,
-       2,     1,     1,     1,     1,     1,     1,     3,     3,     4,
-       4,     5,     6,     5,     4,     1,     2,     4,     1,     2,
-       4,     0,     2,     1,     3,     1,     1,     2,     2,     1,
-       2,     2,     1,     3,     1,     3,     1,     3,     1,     1,
-       1,     1,     1,     1,     1,     2,     1,     2,     1,     1,
-       1,     1,     1,     1,     1,     3,     1,     1,     1,     1,
-       1,     1,     2,     2,     0
+       2,     4,     2,     1,     1,     1,     1,     0,     3,    10,
+       7,     4,     5,     5,     0,     4,     2,     2,     4,     4,
+       5,     4,     3,     1,     3,     1,     2,     2,     1,     3,
+       3,     9,     0,     1,     1,     1,     1,     1,     3,     3,
+       2,     1,     3,     0,     1,     2,     1,     5,     4,     6,
+       5,     6,     5,     6,     5,     3,     0,     3,     3,     2,
+       3,     2,     2,     1,     1,     2,     1,     4,     1,     3,
+       0,     3,     0,     2,     0,     3,     0,     2,     1,     3,
+       3,     0,     1,     1,     0,     2,     2,     0,     1,     2,
+       3,     1,     3,     1,     2,     1,     5,     6,     4,     3,
+       3,     3,     2,     3,     5,     4,     6,     3,     1,     3,
+       1,     2,     1,     1,     1,     1,     1,     1,     3,     3,
+       4,     4,     5,     6,     5,     4,     1,     2,     4,     1,
+       2,     4,     0,     2,     1,     3,     1,     1,     2,     2,
+       1,     2,     2,     1,     3,     1,     3,     1,     3,     1,
+       1,     1,     1,     1,     1,     1,     2,     1,     2,     1,
+       1,     1,     1,     1,     1,     1,     3,     1,     1,     1,
+       1,     1,     1,     2,     2,     0
 };
 
 
@@ -1855,893 +1864,893 @@ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocatio
   switch (yytype)
     {
           case 3: /* TOKEN_COMMAND  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 1865 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1874 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 4: /* TOKEN_NAME  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 1875 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1884 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 5: /* TOKEN_STRING_SINGLE_QUOTED  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 1885 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1894 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 6: /* TOKEN_STRING_DOUBLE_QUOTED  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 1895 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1904 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 7: /* TOKEN_UNSIGNED_NUMVAL  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).numeric_literal_value_) != nullptr) {
     delete ((*yyvaluep).numeric_literal_value_);
   }
 }
-#line 1905 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1914 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 129: /* sql_statement  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 130: /* sql_statement  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).statement_) != nullptr) {
     delete ((*yyvaluep).statement_);
   }
 }
-#line 1915 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1924 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 130: /* quit_statement  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 131: /* quit_statement  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).quit_statement_) != nullptr) {
     delete ((*yyvaluep).quit_statement_);
   }
 }
-#line 1925 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1934 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 131: /* alter_table_statement  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 132: /* alter_table_statement  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).statement_) != nullptr) {
     delete ((*yyvaluep).statement_);
   }
 }
-#line 1935 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1944 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 132: /* create_table_statement  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 133: /* create_table_statement  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).create_table_statement_) != nullptr) {
     delete ((*yyvaluep).create_table_statement_);
   }
 }
-#line 1945 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1954 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 133: /* create_index_statement  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 134: /* create_index_statement  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).statement_) != nullptr) {
     delete ((*yyvaluep).statement_);
   }
 }
-#line 1955 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1964 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 134: /* drop_table_statement  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 135: /* drop_table_statement  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).drop_table_statement_) != nullptr) {
     delete ((*yyvaluep).drop_table_statement_);
   }
 }
-#line 1965 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1974 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 135: /* column_def  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 136: /* column_def  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).attribute_definition_) != nullptr) {
     delete ((*yyvaluep).attribute_definition_);
   }
 }
-#line 1975 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1984 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 136: /* column_def_commalist  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 137: /* column_def_commalist  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).attribute_definition_list_) != nullptr) {
     delete ((*yyvaluep).attribute_definition_list_);
   }
 }
-#line 1985 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1994 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 137: /* data_type  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 138: /* data_type  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).data_type_) != nullptr) {
     delete ((*yyvaluep).data_type_);
   }
 }
-#line 1995 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2004 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 138: /* column_constraint_def  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 139: /* column_constraint_def  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).column_constraint_) != nullptr) {
     delete ((*yyvaluep).column_constraint_);
   }
 }
-#line 2005 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2014 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 139: /* column_constraint_def_list  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 140: /* column_constraint_def_list  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).column_constraint_list_) != nullptr) {
     delete ((*yyvaluep).column_constraint_list_);
   }
 }
-#line 2015 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2024 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 140: /* opt_column_constraint_def_list  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 141: /* opt_column_constraint_def_list  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).column_constraint_list_) != nullptr) {
     delete ((*yyvaluep).column_constraint_list_);
   }
 }
-#line 2025 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2034 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 144: /* opt_column_list  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 145: /* opt_column_list  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).attribute_list_) != nullptr) {
     delete ((*yyvaluep).attribute_list_);
   }
 }
-#line 2035 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2044 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 145: /* opt_block_properties  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 146: /* opt_block_properties  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).block_properties_) != nullptr) {
     delete ((*yyvaluep).block_properties_);
   }
 }
-#line 2045 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2054 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 146: /* opt_partition_clause  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 147: /* opt_partition_clause  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).partition_clause_) != nullptr) {
     delete ((*yyvaluep).partition_clause_);
   }
 }
-#line 2055 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2064 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 147: /* partition_type  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 148: /* partition_type  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 2065 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2074 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 148: /* key_value_list  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 149: /* key_value_list  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_value_list_) != nullptr) {
     delete ((*yyvaluep).key_value_list_);
   }
 }
-#line 2075 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2084 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 149: /* key_value  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 150: /* key_value  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_value_) != nullptr) {
     delete ((*yyvaluep).key_value_);
   }
 }
-#line 2085 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2094 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 150: /* key_string_value  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 151: /* key_string_value  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_string_value_) != nullptr) {
     delete ((*yyvaluep).key_string_value_);
   }
 }
-#line 2095 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2104 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 151: /* key_string_list  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 152: /* key_string_list  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_string_list_) != nullptr) {
     delete ((*yyvaluep).key_string_list_);
   }
 }
-#line 2105 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2114 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 152: /* key_integer_value  */
-#line 560 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 153: /* key_integer_value  */
+#line 561 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_integer_value_) != nullptr) {
     delete ((*yyvaluep).key_integer_value_);
   }


<TRUNCATED>


[06/24] incubator-quickstep git commit: Adds backend support for hash semi/anti joins. (#164)

Posted by zu...@apache.org.
Adds backend support for hash semi/anti joins. (#164)

* Added implementations for HashSemiJoin and HashAntiJoin operators.

* Added component in ExecutionGenerator to convert semi/anti join nodes into relational operators.

* Add 'this' pointer in anonymous functionfor gcc build


Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/a39ad965
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/a39ad965
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/a39ad965

Branch: refs/heads/master
Commit: a39ad9654f10fbe67a90cb7b65dc30dc797f55b3
Parents: 914f2d8
Author: Jianqiao Zhu <ji...@cs.wisc.edu>
Authored: Thu Apr 14 16:28:24 2016 -0500
Committer: Jignesh Patel <pa...@users.noreply.github.com>
Committed: Thu Apr 14 16:28:24 2016 -0500

----------------------------------------------------------------------
 query_optimizer/ExecutionGenerator.cpp          |  42 +-
 .../tests/execution_generator/Select.test       |  43 +++
 relational_operators/CMakeLists.txt             |   2 +
 relational_operators/HashJoinOperator.cpp       | 360 +++++++++++++++--
 relational_operators/HashJoinOperator.hpp       | 350 ++++++++++++++---
 relational_operators/WorkOrder.proto            |  58 ++-
 relational_operators/WorkOrderFactory.cpp       | 211 ++++++++--
 storage/HashTable.hpp                           | 387 +++++++++++++++++++
 storage/LinearOpenAddressingHashTable.hpp       |  72 ++++
 storage/SeparateChainingHashTable.hpp           |  54 +++
 .../SimpleScalarSeparateChainingHashTable.hpp   |  37 ++
 storage/StorageBlock.hpp                        |  20 +
 12 files changed, 1506 insertions(+), 130 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a39ad965/query_optimizer/ExecutionGenerator.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp
index cf90be7..aa6b0dc 100644
--- a/query_optimizer/ExecutionGenerator.cpp
+++ b/query_optimizer/ExecutionGenerator.cpp
@@ -23,6 +23,7 @@
 #include <cstddef>
 #include <memory>
 #include <string>
+#include <type_traits>
 #include <unordered_map>
 #include <utility>
 #include <vector>
@@ -570,16 +571,19 @@ void ExecutionGenerator::convertHashJoin(const P::HashJoinPtr &physical_plan) {
     key_types.push_back(&left_attribute_type);
   }
 
-  // Choose the smaller table as the inner build table,
-  // and the other one as the outer probe table.
   std::size_t probe_cardinality = cost_model_->estimateCardinality(probe_physical);
   std::size_t build_cardinality = cost_model_->estimateCardinality(build_physical);
-  if (probe_cardinality < build_cardinality) {
-    // Switch the probe and build physical nodes.
-    std::swap(probe_physical, build_physical);
-    std::swap(probe_cardinality, build_cardinality);
-    std::swap(probe_attribute_ids, build_attribute_ids);
-    std::swap(any_probe_attributes_nullable, any_build_attributes_nullable);
+  // For inner join, we may swap the probe table and the build table.
+  if (physical_plan->join_type() == P::HashJoin::JoinType::kInnerJoin)  {
+    // Choose the smaller table as the inner build table,
+    // and the other one as the outer probe table.
+    if (probe_cardinality < build_cardinality) {
+      // Switch the probe and build physical nodes.
+      std::swap(probe_physical, build_physical);
+      std::swap(probe_cardinality, build_cardinality);
+      std::swap(probe_attribute_ids, build_attribute_ids);
+      std::swap(any_probe_attributes_nullable, any_build_attributes_nullable);
+    }
   }
 
   // Convert the residual predicate proto.
@@ -647,6 +651,25 @@ void ExecutionGenerator::convertHashJoin(const P::HashJoinPtr &physical_plan) {
                                  &output_relation,
                                  insert_destination_proto);
 
+  // Get JoinType
+  HashJoinOperator::JoinType join_type;
+  switch (physical_plan->join_type()) {
+    case P::HashJoin::JoinType::kInnerJoin:
+      join_type = HashJoinOperator::JoinType::kInnerJoin;
+      break;
+    case P::HashJoin::JoinType::kLeftSemiJoin:
+      join_type = HashJoinOperator::JoinType::kLeftSemiJoin;
+      break;
+    case P::HashJoin::JoinType::kLeftAntiJoin:
+      join_type = HashJoinOperator::JoinType::kLeftAntiJoin;
+      break;
+    default:
+      LOG(FATAL) << "Invalid physical::HashJoin::JoinType: "
+                 << static_cast<typename std::underlying_type<P::HashJoin::JoinType>::type>(
+                        physical_plan->join_type());
+  }
+
+  // Create hash join operator
   const QueryPlan::DAGNodeIndex join_operator_index =
       execution_plan_->addRelationalOperator(
           new HashJoinOperator(
@@ -659,7 +682,8 @@ void ExecutionGenerator::convertHashJoin(const P::HashJoinPtr &physical_plan) {
               insert_destination_index,
               join_hash_table_index,
               residual_predicate_index,
-              project_expressions_group_index));
+              project_expressions_group_index,
+              join_type));
   insert_destination_proto->set_relational_op_index(join_operator_index);
 
   const QueryPlan::DAGNodeIndex destroy_operator_index =

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a39ad965/query_optimizer/tests/execution_generator/Select.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/execution_generator/Select.test b/query_optimizer/tests/execution_generator/Select.test
index e1614cb..9bfa27c 100644
--- a/query_optimizer/tests/execution_generator/Select.test
+++ b/query_optimizer/tests/execution_generator/Select.test
@@ -721,6 +721,49 @@ WHERE CASE WHEN i < j THEN i
 +-----------+-----------+
 ==
 
+SELECT i AS odd
+FROM generate_series(0, 10, 1) AS gs1(i)
+WHERE
+  NOT EXISTS (
+    SELECT *
+    FROM generate_series(0, 10, 2) AS gs2(even)
+    WHERE i = even
+  );
+--
++-----------+
+|odd        |
++-----------+
+|          1|
+|          3|
+|          5|
+|          7|
+|          9|
++-----------+
+==
+
+SELECT i
+FROM generate_series(0, 100, 3) AS gs1(i)
+WHERE
+  EXISTS (
+    SELECT *
+    FROM generate_series(0, 100, 5) AS gs2(i)
+    WHERE gs1.i = gs2.i
+  )
+  AND NOT EXISTS (
+    SELECT *
+    FROM generate_series(0, 100, 10) AS gs3(i)
+    WHERE gs1.i = gs3.i
+  )
+  AND (i < 40 OR i > 60);
+--
++-----------+
+|i          |
++-----------+
+|         15|
+|         75|
++-----------+
+==
+
 # TODO(team): Support uncorrelated queries.
 # SELECT COUNT(*)
 # FROM test

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a39ad965/relational_operators/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/relational_operators/CMakeLists.txt b/relational_operators/CMakeLists.txt
index 17a9a6f..b02bc6b 100644
--- a/relational_operators/CMakeLists.txt
+++ b/relational_operators/CMakeLists.txt
@@ -176,11 +176,13 @@ target_link_libraries(quickstep_relationaloperators_HashJoinOperator
                       quickstep_storage_StorageBlock
                       quickstep_storage_StorageBlockInfo
                       quickstep_storage_StorageManager
+                      quickstep_storage_SubBlocksReference
                       quickstep_storage_TupleReference
                       quickstep_storage_TupleStorageSubBlock
                       quickstep_storage_ValueAccessor
                       quickstep_types_containers_ColumnVectorsValueAccessor
                       quickstep_utility_Macros
+                      quickstep_utility_PtrList
                       tmb)
 target_link_libraries(quickstep_relationaloperators_InsertOperator
                       glog

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a39ad965/relational_operators/HashJoinOperator.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/HashJoinOperator.cpp b/relational_operators/HashJoinOperator.cpp
index f7bbf38..e0076e3 100644
--- a/relational_operators/HashJoinOperator.cpp
+++ b/relational_operators/HashJoinOperator.cpp
@@ -35,6 +35,7 @@
 #include "storage/StorageBlock.hpp"
 #include "storage/StorageBlockInfo.hpp"
 #include "storage/StorageManager.hpp"
+#include "storage/SubBlocksReference.hpp"
 #include "storage/TupleReference.hpp"
 #include "storage/TupleStorageSubBlock.hpp"
 #include "storage/ValueAccessor.hpp"
@@ -85,7 +86,7 @@ class MapBasedJoinedTupleCollector {
   // Consolidation is a no-op for this version, but we provide this trivial
   // call so that MapBasedJoinedTupleCollector and
   // VectorBasedJoinedTupleCollector have the same interface and can both be
-  // used in the templated HashJoinWorkOrder::executeWithCollectorType() method.
+  // used in the templated HashInnerJoinWorkOrder::executeWithCollectorType() method.
   inline void consolidate() const {
   }
 
@@ -183,6 +184,25 @@ class VectorBasedJoinedTupleCollector {
       consolidated_joined_tuples_;
 };
 
+class SemiAntiJoinTupleCollector {
+ public:
+  explicit SemiAntiJoinTupleCollector(const TupleStorageSubBlock &tuple_store) {
+    filter_.reset(tuple_store.getExistenceMap());
+  }
+
+  template <typename ValueAccessorT>
+  inline void operator()(const ValueAccessorT &accessor) {
+    filter_->set(accessor.getCurrentPosition(), false);
+  }
+
+  const TupleIdSequence* filter() const {
+    return filter_.get();
+  }
+
+ private:
+  std::unique_ptr<TupleIdSequence> filter_;
+};
+
 }  // namespace
 
 bool HashJoinOperator::getAllWorkOrders(
@@ -191,31 +211,53 @@ bool HashJoinOperator::getAllWorkOrders(
     StorageManager *storage_manager,
     const tmb::client_id scheduler_client_id,
     tmb::MessageBus *bus) {
+  switch (join_type_) {
+    case JoinType::kInnerJoin:
+      return getAllNonOuterJoinWorkOrders<HashInnerJoinWorkOrder>(
+          container, query_context, storage_manager);
+    case JoinType::kLeftSemiJoin:
+      return getAllNonOuterJoinWorkOrders<HashSemiJoinWorkOrder>(
+          container, query_context, storage_manager);
+    case JoinType::kLeftAntiJoin:
+      return getAllNonOuterJoinWorkOrders<HashAntiJoinWorkOrder>(
+          container, query_context, storage_manager);
+    default:
+      LOG(FATAL) << "Unknown join type in HashJoinOperator::getAllWorkOrders()";
+  }
+}
+
+template <class JoinWorkOrderClass>
+bool HashJoinOperator::getAllNonOuterJoinWorkOrders(
+    WorkOrdersContainer *container,
+    QueryContext *query_context,
+    StorageManager *storage_manager) {
   // We wait until the building of global hash table is complete.
   if (blocking_dependencies_met_) {
     DCHECK(query_context != nullptr);
 
-    const Predicate *residual_predicate = query_context->getPredicate(residual_predicate_index_);
+    const Predicate *residual_predicate =
+        query_context->getPredicate(residual_predicate_index_);
     const vector<unique_ptr<const Scalar>> &selection =
         query_context->getScalarGroup(selection_index_);
     InsertDestination *output_destination =
         query_context->getInsertDestination(output_destination_index_);
-    JoinHashTable *hash_table = query_context->getJoinHashTable(hash_table_index_);
+    const JoinHashTable &hash_table =
+        *(query_context->getJoinHashTable(hash_table_index_));
 
     if (probe_relation_is_stored_) {
       if (!started_) {
         for (const block_id probe_block_id : probe_relation_block_ids_) {
           container->addNormalWorkOrder(
-              new HashJoinWorkOrder(build_relation_,
-                                    probe_relation_,
-                                    join_key_attributes_,
-                                    any_join_key_attributes_nullable_,
-                                    probe_block_id,
-                                    residual_predicate,
-                                    selection,
-                                    output_destination,
-                                    hash_table,
-                                    storage_manager),
+              new JoinWorkOrderClass(build_relation_,
+                                     probe_relation_,
+                                     join_key_attributes_,
+                                     any_join_key_attributes_nullable_,
+                                     probe_block_id,
+                                     residual_predicate,
+                                     selection,
+                                     hash_table,
+                                     output_destination,
+                                     storage_manager),
               op_index_);
         }
         started_ = true;
@@ -224,27 +266,26 @@ bool HashJoinOperator::getAllWorkOrders(
     } else {
       while (num_workorders_generated_ < probe_relation_block_ids_.size()) {
         container->addNormalWorkOrder(
-            new HashJoinWorkOrder(
-                build_relation_,
-                probe_relation_,
-                join_key_attributes_,
-                any_join_key_attributes_nullable_,
-                probe_relation_block_ids_[num_workorders_generated_],
-                residual_predicate,
-                selection,
-                output_destination,
-                hash_table,
-                storage_manager),
+            new JoinWorkOrderClass(build_relation_,
+                                   probe_relation_,
+                                   join_key_attributes_,
+                                   any_join_key_attributes_nullable_,
+                                   probe_relation_block_ids_[num_workorders_generated_],
+                                   residual_predicate,
+                                   selection,
+                                   hash_table,
+                                   output_destination,
+                                   storage_manager),
             op_index_);
         ++num_workorders_generated_;
       }  // end while
       return done_feeding_input_relation_;
-    }  // end else (input_relation_is_stored is false)
-  }  // end if (blocking_dependencies_met)
+    }  // end else (probe_relation_is_stored_)
+  }  // end if (blocking_dependencies_met_)
   return false;
 }
 
-void HashJoinWorkOrder::execute() {
+void HashInnerJoinWorkOrder::execute() {
   if (FLAGS_vector_based_joined_tuple_collector) {
     executeWithCollectorType<VectorBasedJoinedTupleCollector>();
   } else {
@@ -253,7 +294,7 @@ void HashJoinWorkOrder::execute() {
 }
 
 template <typename CollectorT>
-void HashJoinWorkOrder::executeWithCollectorType() {
+void HashInnerJoinWorkOrder::executeWithCollectorType() {
   BlockReference probe_block(
       storage_manager_->getBlock(block_id_, probe_relation_));
   const TupleStorageSubBlock &probe_store = probe_block->getTupleStorageSubBlock();
@@ -261,13 +302,13 @@ void HashJoinWorkOrder::executeWithCollectorType() {
   std::unique_ptr<ValueAccessor> probe_accessor(probe_store.createValueAccessor());
   CollectorT collector;
   if (join_key_attributes_.size() == 1) {
-    hash_table_->getAllFromValueAccessor(
+    hash_table_.getAllFromValueAccessor(
         probe_accessor.get(),
         join_key_attributes_.front(),
         any_join_key_attributes_nullable_,
         &collector);
   } else {
-    hash_table_->getAllFromValueAccessorCompositeKey(
+    hash_table_.getAllFromValueAccessorCompositeKey(
         probe_accessor.get(),
         join_key_attributes_,
         any_join_key_attributes_nullable_,
@@ -348,4 +389,263 @@ void HashJoinWorkOrder::executeWithCollectorType() {
   }
 }
 
+void HashSemiJoinWorkOrder::execute() {
+  if (residual_predicate_ == nullptr) {
+    executeWithoutResidualPredicate();
+  } else {
+    executeWithResidualPredicate();
+  }
+}
+
+void HashSemiJoinWorkOrder::executeWithResidualPredicate() {
+  const relation_id build_relation_id = build_relation_.getID();
+  const relation_id probe_relation_id = probe_relation_.getID();
+
+  BlockReference probe_block = storage_manager_->getBlock(block_id_,
+                                                          probe_relation_);
+  const TupleStorageSubBlock &probe_store = probe_block->getTupleStorageSubBlock();
+
+  std::unique_ptr<ValueAccessor> probe_accessor(probe_store.createValueAccessor());
+
+  // TODO(harshad) - Make this function work with both types of collectors.
+
+  // We collect all the matching probe relation tuples, as there's a residual
+  // preidcate that needs to be applied after collecting these matches.
+  MapBasedJoinedTupleCollector collector;
+  if (join_key_attributes_.size() == 1) {
+    hash_table_.getAllFromValueAccessor(
+        probe_accessor.get(),
+        join_key_attributes_.front(),
+        any_join_key_attributes_nullable_,
+        &collector);
+  } else {
+    hash_table_.getAllFromValueAccessorCompositeKey(
+        probe_accessor.get(),
+        join_key_attributes_,
+        any_join_key_attributes_nullable_,
+        &collector);
+  }
+
+  // Get a filter for tuples in the given probe block.
+  TupleIdSequence filter(probe_store.getMaxTupleID() + 1);
+  filter.setRange(0, filter.length(), false);
+  for (const std::pair<const block_id,
+                       std::vector<std::pair<tuple_id, tuple_id>>>
+           &build_block_entry : *collector.getJoinedTuples()) {
+    // First element of the pair build_block_entry is the build block ID
+    // 2nd element of the pair is a vector of pairs, in each of which -
+    // 1st element is a matching tuple ID from the inner (build) relation.
+    // 2nd element is a matching tuple ID from the outer (probe) relation.
+
+    // Get the block from the build relation for this pair of matched tuples.
+    BlockReference build_block =
+        storage_manager_->getBlock(build_block_entry.first, build_relation_);
+    const TupleStorageSubBlock &build_store =
+        build_block->getTupleStorageSubBlock();
+    std::unique_ptr<ValueAccessor> build_accessor(
+        build_store.createValueAccessor());
+    for (const std::pair<tuple_id, tuple_id> &hash_match
+         : build_block_entry.second) {
+      // For each pair, 1st element is a tuple ID from the build relation in the
+      // given build block, 2nd element is a tuple ID from the probe relation.
+      if (filter.get(hash_match.second)) {
+        // We have already found matches for this tuple that belongs to the
+        // probe side, skip it.
+        continue;
+      }
+      if (residual_predicate_->matchesForJoinedTuples(*build_accessor,
+                                                      build_relation_id,
+                                                      hash_match.first,
+                                                      *probe_accessor,
+                                                      probe_relation_id,
+                                                      hash_match.second)) {
+        filter.set(hash_match.second, true);
+      }
+    }
+  }
+
+  SubBlocksReference sub_blocks_ref(probe_store,
+                                    probe_block->getIndices(),
+                                    probe_block->getIndicesConsistent());
+
+  std::unique_ptr<ValueAccessor> probe_accessor_with_filter(
+      probe_store.createValueAccessor(&filter));
+  ColumnVectorsValueAccessor temp_result;
+  for (vector<unique_ptr<const Scalar>>::const_iterator selection_it = selection_.begin();
+       selection_it != selection_.end();
+       ++selection_it) {
+    temp_result.addColumn((*selection_it)->getAllValues(
+        probe_accessor_with_filter.get(), &sub_blocks_ref));
+  }
+
+  output_destination_->bulkInsertTuples(&temp_result);
+}
+
+void HashSemiJoinWorkOrder::executeWithoutResidualPredicate() {
+  DCHECK(residual_predicate_ == nullptr);
+
+  BlockReference probe_block = storage_manager_->getBlock(block_id_,
+                                                          probe_relation_);
+  const TupleStorageSubBlock &probe_store = probe_block->getTupleStorageSubBlock();
+
+  std::unique_ptr<ValueAccessor> probe_accessor(probe_store.createValueAccessor());
+  SemiAntiJoinTupleCollector collector(probe_store);
+  // We collect all the probe relation tuples which have at least one matching
+  // tuple in the build relation. As a performance optimization, the hash table
+  // just looks for the existence of the probing key in the hash table and sets
+  // the bit for the probing key in the collector. The optimization works
+  // because there is no residual predicate in this case, unlike
+  // executeWithResidualPredicate().
+  if (join_key_attributes_.size() == 1u) {
+    // Call the collector to set the bit to 0 for every key without a match.
+    hash_table_.runOverKeysFromValueAccessorIfMatchNotFound(
+        probe_accessor.get(),
+        join_key_attributes_.front(),
+        any_join_key_attributes_nullable_,
+        &collector);
+  } else {
+    // Call the collector to set the bit to 0 for every key without a match.
+    hash_table_.runOverKeysFromValueAccessorIfMatchNotFoundCompositeKey(
+        probe_accessor.get(),
+        join_key_attributes_,
+        any_join_key_attributes_nullable_,
+        &collector);
+  }
+
+  SubBlocksReference sub_blocks_ref(probe_store,
+                                    probe_block->getIndices(),
+                                    probe_block->getIndicesConsistent());
+
+  std::unique_ptr<ValueAccessor> probe_accessor_with_filter(
+      probe_store.createValueAccessor(collector.filter()));
+  ColumnVectorsValueAccessor temp_result;
+  for (vector<unique_ptr<const Scalar>>::const_iterator selection_it = selection_.begin();
+       selection_it != selection_.end(); ++selection_it) {
+    temp_result.addColumn((*selection_it)->getAllValues(
+        probe_accessor_with_filter.get(), &sub_blocks_ref));
+  }
+
+  output_destination_->bulkInsertTuples(&temp_result);
+}
+
+void HashAntiJoinWorkOrder::executeWithoutResidualPredicate() {
+  DCHECK(residual_predicate_ == nullptr);
+
+  BlockReference probe_block = storage_manager_->getBlock(block_id_,
+                                                          probe_relation_);
+  const TupleStorageSubBlock &probe_store = probe_block->getTupleStorageSubBlock();
+
+  std::unique_ptr<ValueAccessor> probe_accessor(probe_store.createValueAccessor());
+  SemiAntiJoinTupleCollector collector(probe_store);
+  // We probe the hash table to find the keys which have an entry in the
+  // hash table.
+  if (join_key_attributes_.size() == 1) {
+    // Call the collector to set the bit to 0 for every key with a match.
+    hash_table_.runOverKeysFromValueAccessorIfMatchFound(
+        probe_accessor.get(),
+        join_key_attributes_.front(),
+        any_join_key_attributes_nullable_,
+        &collector);
+  } else {
+    // Call the collector to set the bit to 0 for every key with a match.
+    hash_table_.runOverKeysFromValueAccessorIfMatchFoundCompositeKey(
+        probe_accessor.get(),
+        join_key_attributes_,
+        any_join_key_attributes_nullable_,
+        &collector);
+  }
+
+  SubBlocksReference sub_blocks_ref(probe_store,
+                                    probe_block->getIndices(),
+                                    probe_block->getIndicesConsistent());
+
+  std::unique_ptr<ValueAccessor> probe_accessor_with_filter(
+      probe_store.createValueAccessor(collector.filter()));
+  ColumnVectorsValueAccessor temp_result;
+  for (vector<unique_ptr<const Scalar>>::const_iterator selection_it = selection_.begin();
+       selection_it != selection_.end(); ++selection_it) {
+    temp_result.addColumn((*selection_it)->getAllValues(
+        probe_accessor_with_filter.get(), &sub_blocks_ref));
+  }
+
+  output_destination_->bulkInsertTuples(&temp_result);
+}
+
+void HashAntiJoinWorkOrder::executeWithResidualPredicate() {
+  const relation_id build_relation_id = build_relation_.getID();
+  const relation_id probe_relation_id = probe_relation_.getID();
+
+  BlockReference probe_block = storage_manager_->getBlock(block_id_,
+                                                          probe_relation_);
+  const TupleStorageSubBlock &probe_store = probe_block->getTupleStorageSubBlock();
+
+  std::unique_ptr<ValueAccessor> probe_accessor(probe_store.createValueAccessor());
+  // TODO(harshad) - Make the following code work with both types of collectors.
+  MapBasedJoinedTupleCollector collector;
+  // We probe the hash table and get all the matches. Unlike
+  // executeWithoutResidualPredicate(), we have to collect all the matching
+  // tuples, because after this step we still have to evalute the residual
+  // predicate.
+  if (join_key_attributes_.size() == 1) {
+    hash_table_.getAllFromValueAccessor(
+        probe_accessor.get(),
+        join_key_attributes_.front(),
+        any_join_key_attributes_nullable_,
+        &collector);
+  } else {
+    hash_table_.getAllFromValueAccessorCompositeKey(
+        probe_accessor.get(),
+        join_key_attributes_,
+        any_join_key_attributes_nullable_,
+        &collector);
+  }
+
+  // Create a filter for all the tuples from the given probe block.
+  std::unique_ptr<TupleIdSequence> filter(probe_store.getExistenceMap());
+  for (const std::pair<const block_id, std::vector<std::pair<tuple_id, tuple_id>>>
+           &build_block_entry : *collector.getJoinedTuples()) {
+    // First element of the pair build_block_entry is the build block ID
+    // 2nd element of the pair is a vector of pairs, in each of which -
+    // 1st element is a matching tuple ID from the inner (build) relation.
+    // 2nd element is a matching tuple ID from the outer (probe) relation.
+    BlockReference build_block = storage_manager_->getBlock(build_block_entry.first,
+                                                            build_relation_);
+    const TupleStorageSubBlock &build_store = build_block->getTupleStorageSubBlock();
+    std::unique_ptr<ValueAccessor> build_accessor(build_store.createValueAccessor());
+    for (const std::pair<tuple_id, tuple_id> &hash_match
+         : build_block_entry.second) {
+      if (!filter->get(hash_match.second)) {
+        // We have already seen this tuple, skip it.
+        continue;
+      }
+      if (residual_predicate_->matchesForJoinedTuples(*build_accessor,
+                                                      build_relation_id,
+                                                      hash_match.first,
+                                                      *probe_accessor,
+                                                      probe_relation_id,
+                                                      hash_match.second)) {
+        // Note that the filter marks a match as false, as needed by the anti
+        // join definition.
+        filter->set(hash_match.second, false);
+      }
+    }
+  }
+
+  SubBlocksReference sub_blocks_ref(probe_store,
+                                    probe_block->getIndices(),
+                                    probe_block->getIndicesConsistent());
+
+  std::unique_ptr<ValueAccessor> probe_accessor_with_filter(
+      probe_store.createValueAccessor(filter.get()));
+  ColumnVectorsValueAccessor temp_result;
+  for (vector<unique_ptr<const Scalar>>::const_iterator selection_it = selection_.begin();
+       selection_it != selection_.end();
+       ++selection_it) {
+    temp_result.addColumn((*selection_it)->getAllValues(probe_accessor_with_filter.get(),
+                                                     &sub_blocks_ref));
+  }
+
+  output_destination_->bulkInsertTuples(&temp_result);
+}
+
 }  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a39ad965/relational_operators/HashJoinOperator.hpp
----------------------------------------------------------------------
diff --git a/relational_operators/HashJoinOperator.hpp b/relational_operators/HashJoinOperator.hpp
index a00e590..c22f435 100644
--- a/relational_operators/HashJoinOperator.hpp
+++ b/relational_operators/HashJoinOperator.hpp
@@ -31,6 +31,7 @@
 #include "storage/HashTable.hpp"
 #include "storage/StorageBlockInfo.hpp"
 #include "utility/Macros.hpp"
+#include "utility/PtrList.hpp"
 
 #include "glog/logging.h"
 
@@ -52,11 +53,17 @@ class WorkOrdersContainer;
  */
 
 /**
- * @brief An operator which performs a hash-join on two
- *        relations.
+ * @brief An operator which performs a hash-join, including inner-join,
+ *        semi-join, anti-join and outer-join on two relations.
  **/
 class HashJoinOperator : public RelationalOperator {
  public:
+  enum class JoinType {
+    kInnerJoin = 0,
+    kLeftSemiJoin,
+    kLeftAntiJoin
+  };
+
   /**
    * @brief Constructor.
    *
@@ -98,6 +105,7 @@ class HashJoinOperator : public RelationalOperator {
    *        corresponding to the attributes of the relation referred by
    *        output_relation_id. Each Scalar is evaluated for the joined tuples,
    *        and the resulting value is inserted into the join result.
+   * @param join_type The type of join corresponding to this operator.
    **/
   HashJoinOperator(const CatalogRelation &build_relation,
                    const CatalogRelation &probe_relation,
@@ -108,21 +116,24 @@ class HashJoinOperator : public RelationalOperator {
                    const QueryContext::insert_destination_id output_destination_index,
                    const QueryContext::join_hash_table_id hash_table_index,
                    const QueryContext::predicate_id residual_predicate_index,
-                   const QueryContext::scalar_group_id selection_index)
-    : build_relation_(build_relation),
-      probe_relation_(probe_relation),
-      probe_relation_is_stored_(probe_relation_is_stored),
-      join_key_attributes_(join_key_attributes),
-      any_join_key_attributes_nullable_(any_join_key_attributes_nullable),
-      output_relation_(output_relation),
-      output_destination_index_(output_destination_index),
-      hash_table_index_(hash_table_index),
-      residual_predicate_index_(residual_predicate_index),
-      selection_index_(selection_index),
-      probe_relation_block_ids_(probe_relation_is_stored ? probe_relation.getBlocksSnapshot()
-                                                         : std::vector<block_id>()),
-      num_workorders_generated_(0),
-      started_(false) {}
+                   const QueryContext::scalar_group_id selection_index,
+                   const JoinType join_type = JoinType::kInnerJoin)
+      : build_relation_(build_relation),
+        probe_relation_(probe_relation),
+        probe_relation_is_stored_(probe_relation_is_stored),
+        join_key_attributes_(join_key_attributes),
+        any_join_key_attributes_nullable_(any_join_key_attributes_nullable),
+        output_relation_(output_relation),
+        output_destination_index_(output_destination_index),
+        hash_table_index_(hash_table_index),
+        residual_predicate_index_(residual_predicate_index),
+        selection_index_(selection_index),
+        join_type_(join_type),
+        probe_relation_block_ids_(probe_relation_is_stored
+                                      ? probe_relation.getBlocksSnapshot()
+                                      : std::vector<block_id>()),
+        num_workorders_generated_(0),
+        started_(false) {}
 
   ~HashJoinOperator() override {}
 
@@ -164,6 +175,11 @@ class HashJoinOperator : public RelationalOperator {
   }
 
  private:
+  template <class JoinWorkOrderClass>
+  bool getAllNonOuterJoinWorkOrders(WorkOrdersContainer *container,
+                                    QueryContext *query_context,
+                                    StorageManager *storage_manager);
+
   const CatalogRelation &build_relation_;
   const CatalogRelation &probe_relation_;
   const bool probe_relation_is_stored_;
@@ -174,6 +190,7 @@ class HashJoinOperator : public RelationalOperator {
   const QueryContext::join_hash_table_id hash_table_index_;
   const QueryContext::predicate_id residual_predicate_index_;
   const QueryContext::scalar_group_id selection_index_;
+  const JoinType join_type_;
 
   std::vector<block_id> probe_relation_block_ids_;
   std::size_t num_workorders_generated_;
@@ -184,9 +201,9 @@ class HashJoinOperator : public RelationalOperator {
 };
 
 /**
- * @brief A WorkOrder produced by HashJoinOperator.
+ * @brief An inner join WorkOrder produced by HashJoinOperator.
  **/
-class HashJoinWorkOrder : public WorkOrder {
+class HashInnerJoinWorkOrder : public WorkOrder {
  public:
   /**
    * @brief Constructor.
@@ -206,20 +223,20 @@ class HashJoinWorkOrder : public WorkOrder {
    * @param selection A list of Scalars corresponding to the relation attributes
    *        in \c output_destination. Each Scalar is evaluated for the joined
    *        tuples, and the resulting value is inserted into the join result.
-   * @param output_destination The InsertDestination to insert the join results.
    * @param hash_table The JoinHashTable to use.
+   * @param output_destination The InsertDestination to insert the join results.
    * @param storage_manager The StorageManager to use.
    **/
-  HashJoinWorkOrder(const CatalogRelationSchema &build_relation,
-                    const CatalogRelationSchema &probe_relation,
-                    const std::vector<attribute_id> &join_key_attributes,
-                    const bool any_join_key_attributes_nullable,
-                    const block_id lookup_block_id,
-                    const Predicate *residual_predicate,
-                    const std::vector<std::unique_ptr<const Scalar>> &selection,
-                    InsertDestination *output_destination,
-                    JoinHashTable *hash_table,
-                    StorageManager *storage_manager)
+  HashInnerJoinWorkOrder(const CatalogRelationSchema &build_relation,
+                         const CatalogRelationSchema &probe_relation,
+                         const std::vector<attribute_id> &join_key_attributes,
+                         const bool any_join_key_attributes_nullable,
+                         const block_id lookup_block_id,
+                         const Predicate *residual_predicate,
+                         const std::vector<std::unique_ptr<const Scalar>> &selection,
+                         const JoinHashTable &hash_table,
+                         InsertDestination *output_destination,
+                         StorageManager *storage_manager)
       : build_relation_(build_relation),
         probe_relation_(probe_relation),
         join_key_attributes_(join_key_attributes),
@@ -227,8 +244,8 @@ class HashJoinWorkOrder : public WorkOrder {
         block_id_(lookup_block_id),
         residual_predicate_(residual_predicate),
         selection_(selection),
+        hash_table_(hash_table),
         output_destination_(DCHECK_NOTNULL(output_destination)),
-        hash_table_(DCHECK_NOTNULL(hash_table)),
         storage_manager_(DCHECK_NOTNULL(storage_manager)) {}
 
   /**
@@ -249,20 +266,20 @@ class HashJoinWorkOrder : public WorkOrder {
    * @param selection A list of Scalars corresponding to the relation attributes
    *        in \c output_destination. Each Scalar is evaluated for the joined
    *        tuples, and the resulting value is inserted into the join result.
-   * @param output_destination The InsertDestination to insert the join results.
    * @param hash_table The JoinHashTable to use.
+   * @param output_destination The InsertDestination to insert the join results.
    * @param storage_manager The StorageManager to use.
    **/
-  HashJoinWorkOrder(const CatalogRelationSchema &build_relation,
-                    const CatalogRelationSchema &probe_relation,
-                    std::vector<attribute_id> &&join_key_attributes,
-                    const bool any_join_key_attributes_nullable,
-                    const block_id lookup_block_id,
-                    const Predicate *residual_predicate,
-                    const std::vector<std::unique_ptr<const Scalar>> &selection,
-                    InsertDestination *output_destination,
-                    JoinHashTable *hash_table,
-                    StorageManager *storage_manager)
+  HashInnerJoinWorkOrder(const CatalogRelationSchema &build_relation,
+                         const CatalogRelationSchema &probe_relation,
+                         std::vector<attribute_id> &&join_key_attributes,
+                         const bool any_join_key_attributes_nullable,
+                         const block_id lookup_block_id,
+                         const Predicate *residual_predicate,
+                         const std::vector<std::unique_ptr<const Scalar>> &selection,
+                         const JoinHashTable &hash_table,
+                         InsertDestination *output_destination,
+                         StorageManager *storage_manager)
       : build_relation_(build_relation),
         probe_relation_(probe_relation),
         join_key_attributes_(std::move(join_key_attributes)),
@@ -270,11 +287,11 @@ class HashJoinWorkOrder : public WorkOrder {
         block_id_(lookup_block_id),
         residual_predicate_(residual_predicate),
         selection_(selection),
+        hash_table_(hash_table),
         output_destination_(DCHECK_NOTNULL(output_destination)),
-        hash_table_(DCHECK_NOTNULL(hash_table)),
         storage_manager_(DCHECK_NOTNULL(storage_manager)) {}
 
-  ~HashJoinWorkOrder() override {}
+  ~HashInnerJoinWorkOrder() override {}
 
   /**
    * @exception TupleTooLargeForBlock A tuple produced by this join was too
@@ -290,18 +307,257 @@ class HashJoinWorkOrder : public WorkOrder {
   template <typename CollectorT>
   void executeWithCollectorType();
 
-  const CatalogRelationSchema &build_relation_, &probe_relation_;
+  const CatalogRelationSchema &build_relation_;
+  const CatalogRelationSchema &probe_relation_;
+  const std::vector<attribute_id> join_key_attributes_;
+  const bool any_join_key_attributes_nullable_;
+  const block_id block_id_;
+  const Predicate *residual_predicate_;
+  const std::vector<std::unique_ptr<const Scalar>> &selection_;
+  const JoinHashTable &hash_table_;
+
+  InsertDestination *output_destination_;
+  StorageManager *storage_manager_;
+
+  DISALLOW_COPY_AND_ASSIGN(HashInnerJoinWorkOrder);
+};
+
+/**
+ * @brief A left semi-join WorkOrder produced by the HashJoinOperator to execute
+ *        EXISTS() clause.
+ **/
+class HashSemiJoinWorkOrder : public WorkOrder {
+ public:
+  /**
+   * @brief Constructor.
+   *
+   * @param build_relation The relation that the hash table was originally built
+   *        on (i.e. the inner relation in the join).
+   * @param probe_relation The relation to probe the hash table with (i.e. the
+   *        outer relation in the join).
+   * @param join_key_attributes The IDs of equijoin attributes in \c
+   *        probe_relation.
+   * @param any_join_key_attributes_nullable If any attribute is nullable.
+   * @param lookup_block_id The block id of the probe_relation.
+   * @param residual_predicate If non-null, apply as an additional filter to
+   *        pairs of tuples that match the hash-join (i.e. key equality)
+   *        predicate. Effectively, this makes the join predicate the
+   *        conjunction of the key-equality predicate and residual_predicate.
+   * @param selection A list of Scalars corresponding to the relation attributes
+   *        in \c output_destination. Each Scalar is evaluated for the joined
+   *        tuples, and the resulting value is inserted into the join result.
+   * @param hash_table The JoinHashTable to use.
+   * @param output_destination The InsertDestination to insert the join results.
+   * @param storage_manager The StorageManager to use.
+   **/
+  HashSemiJoinWorkOrder(const CatalogRelationSchema &build_relation,
+                        const CatalogRelationSchema &probe_relation,
+                        const std::vector<attribute_id> &join_key_attributes,
+                        const bool any_join_key_attributes_nullable,
+                        const block_id lookup_block_id,
+                        const Predicate *residual_predicate,
+                        const std::vector<std::unique_ptr<const Scalar>> &selection,
+                        const JoinHashTable &hash_table,
+                        InsertDestination *output_destination,
+                        StorageManager *storage_manager)
+      : build_relation_(build_relation),
+        probe_relation_(probe_relation),
+        join_key_attributes_(join_key_attributes),
+        any_join_key_attributes_nullable_(any_join_key_attributes_nullable),
+        block_id_(lookup_block_id),
+        residual_predicate_(residual_predicate),
+        selection_(selection),
+        hash_table_(hash_table),
+        output_destination_(DCHECK_NOTNULL(output_destination)),
+        storage_manager_(DCHECK_NOTNULL(storage_manager)) {}
+
+  /**
+   * @brief Constructor for the distributed version.
+   *
+   * @param build_relation The relation that the hash table was originally built
+   *        on (i.e. the inner relation in the join).
+   * @param probe_relation The relation to probe the hash table with (i.e. the
+   *        outer relation in the join).
+   * @param join_key_attributes The IDs of equijoin attributes in \c
+   *        probe_relation.
+   * @param any_join_key_attributes_nullable If any attribute is nullable.
+   * @param lookup_block_id The block id of the probe_relation.
+   * @param residual_predicate If non-null, apply as an additional filter to
+   *        pairs of tuples that match the hash-join (i.e. key equality)
+   *        predicate. Effectively, this makes the join predicate the
+   *        conjunction of the key-equality predicate and residual_predicate.
+   * @param selection A list of Scalars corresponding to the relation attributes
+   *        in \c output_destination. Each Scalar is evaluated for the joined
+   *        tuples, and the resulting value is inserted into the join result.
+   * @param hash_table The JoinHashTable to use.
+   * @param output_destination The InsertDestination to insert the join results.
+   * @param storage_manager The StorageManager to use.
+   **/
+  HashSemiJoinWorkOrder(const CatalogRelationSchema &build_relation,
+                        const CatalogRelationSchema &probe_relation,
+                        std::vector<attribute_id> &&join_key_attributes,
+                        const bool any_join_key_attributes_nullable,
+                        const block_id lookup_block_id,
+                        const Predicate *residual_predicate,
+                        const std::vector<std::unique_ptr<const Scalar>> &selection,
+                        const JoinHashTable &hash_table,
+                        InsertDestination *output_destination,
+                        StorageManager *storage_manager)
+      : build_relation_(build_relation),
+        probe_relation_(probe_relation),
+        join_key_attributes_(std::move(join_key_attributes)),
+        any_join_key_attributes_nullable_(any_join_key_attributes_nullable),
+        block_id_(lookup_block_id),
+        residual_predicate_(residual_predicate),
+        selection_(selection),
+        hash_table_(hash_table),
+        output_destination_(DCHECK_NOTNULL(output_destination)),
+        storage_manager_(DCHECK_NOTNULL(storage_manager)) {}
+
+  ~HashSemiJoinWorkOrder() override {}
+
+  void execute() override;
+
+ private:
+  void executeWithoutResidualPredicate();
+
+  void executeWithResidualPredicate();
+
+  const CatalogRelationSchema &build_relation_;
+  const CatalogRelationSchema &probe_relation_;
+  const std::vector<attribute_id> join_key_attributes_;
+  const bool any_join_key_attributes_nullable_;
+  const block_id block_id_;
+  const Predicate *residual_predicate_;
+  const std::vector<std::unique_ptr<const Scalar>> &selection_;
+  const JoinHashTable &hash_table_;
+
+  InsertDestination *output_destination_;
+  StorageManager *storage_manager_;
+
+  DISALLOW_COPY_AND_ASSIGN(HashSemiJoinWorkOrder);
+};
+
+/**
+ * @brief A left anti-join WorkOrder produced by the HashJoinOperator to execute
+ *        NOT EXISTS() clause.
+ **/
+class HashAntiJoinWorkOrder : public WorkOrder {
+ public:
+  /**
+   * @brief Constructor.
+   *
+   * @param build_relation The relation that the hash table was originally built
+   *        on (i.e. the inner relation in the join).
+   * @param probe_relation The relation to probe the hash table with (i.e. the
+   *        outer relation in the join).
+   * @param join_key_attributes The IDs of equijoin attributes in \c
+   *        probe_relation.
+   * @param any_join_key_attributes_nullable If any attribute is nullable.
+   * @param lookup_block_id The block id of the probe_relation.
+   * @param residual_predicate If non-null, apply as an additional filter to
+   *        pairs of tuples that match the hash-join (i.e. key equality)
+   *        predicate. Effectively, this makes the join predicate the
+   *        conjunction of the key-equality predicate and residual_predicate.
+   * @param selection A list of Scalars corresponding to the relation attributes
+   *        in \c output_destination. Each Scalar is evaluated for the joined
+   *        tuples, and the resulting value is inserted into the join result.
+   * @param hash_table The JoinHashTable to use.
+   * @param output_destination The InsertDestination to insert the join results.
+   * @param storage_manager The StorageManager to use.
+   **/
+  HashAntiJoinWorkOrder(const CatalogRelationSchema &build_relation,
+                        const CatalogRelationSchema &probe_relation,
+                        const std::vector<attribute_id> &join_key_attributes,
+                        const bool any_join_key_attributes_nullable,
+                        const block_id lookup_block_id,
+                        const Predicate *residual_predicate,
+                        const std::vector<std::unique_ptr<const Scalar>> &selection,
+                        const JoinHashTable &hash_table,
+                        InsertDestination *output_destination,
+                        StorageManager *storage_manager)
+      : build_relation_(build_relation),
+        probe_relation_(probe_relation),
+        join_key_attributes_(join_key_attributes),
+        any_join_key_attributes_nullable_(any_join_key_attributes_nullable),
+        block_id_(lookup_block_id),
+        residual_predicate_(residual_predicate),
+        selection_(selection),
+        hash_table_(hash_table),
+        output_destination_(DCHECK_NOTNULL(output_destination)),
+        storage_manager_(DCHECK_NOTNULL(storage_manager)) {}
+
+  /**
+   * @brief Constructor for the distributed version.
+   *
+   * @param build_relation The relation that the hash table was originally built
+   *        on (i.e. the inner relation in the join).
+   * @param probe_relation The relation to probe the hash table with (i.e. the
+   *        outer relation in the join).
+   * @param join_key_attributes The IDs of equijoin attributes in \c
+   *        probe_relation.
+   * @param any_join_key_attributes_nullable If any attribute is nullable.
+   * @param lookup_block_id The block id of the probe_relation.
+   * @param residual_predicate If non-null, apply as an additional filter to
+   *        pairs of tuples that match the hash-join (i.e. key equality)
+   *        predicate. Effectively, this makes the join predicate the
+   *        conjunction of the key-equality predicate and residual_predicate.
+   * @param selection A list of Scalars corresponding to the relation attributes
+   *        in \c output_destination. Each Scalar is evaluated for the joined
+   *        tuples, and the resulting value is inserted into the join result.
+   * @param hash_table The JoinHashTable to use.
+   * @param output_destination The InsertDestination to insert the join results.
+   * @param storage_manager The StorageManager to use.
+   **/
+  HashAntiJoinWorkOrder(const CatalogRelationSchema &build_relation,
+                        const CatalogRelationSchema &probe_relation,
+                        std::vector<attribute_id> &&join_key_attributes,
+                        const bool any_join_key_attributes_nullable,
+                        const block_id lookup_block_id,
+                        const Predicate *residual_predicate,
+                        const std::vector<std::unique_ptr<const Scalar>> &selection,
+                        const JoinHashTable &hash_table,
+                        InsertDestination *output_destination,
+                        StorageManager *storage_manager)
+      : build_relation_(build_relation),
+        probe_relation_(probe_relation),
+        join_key_attributes_(join_key_attributes),
+        any_join_key_attributes_nullable_(any_join_key_attributes_nullable),
+        block_id_(lookup_block_id),
+        residual_predicate_(residual_predicate),
+        selection_(selection),
+        hash_table_(hash_table),
+        output_destination_(DCHECK_NOTNULL(output_destination)),
+        storage_manager_(DCHECK_NOTNULL(storage_manager)) {}
+
+  ~HashAntiJoinWorkOrder() override {}
+
+  void execute() override {
+    if (residual_predicate_ == nullptr) {
+      executeWithoutResidualPredicate();
+    } else {
+      executeWithResidualPredicate();
+    }
+  }
+
+ private:
+  void executeWithoutResidualPredicate();
+
+  void executeWithResidualPredicate();
+
+  const CatalogRelationSchema &build_relation_;
+  const CatalogRelationSchema &probe_relation_;
   const std::vector<attribute_id> join_key_attributes_;
   const bool any_join_key_attributes_nullable_;
   const block_id block_id_;
   const Predicate *residual_predicate_;
   const std::vector<std::unique_ptr<const Scalar>> &selection_;
+  const JoinHashTable &hash_table_;
 
   InsertDestination *output_destination_;
-  JoinHashTable *hash_table_;
   StorageManager *storage_manager_;
 
-  DISALLOW_COPY_AND_ASSIGN(HashJoinWorkOrder);
+  DISALLOW_COPY_AND_ASSIGN(HashAntiJoinWorkOrder);
 };
 
 /** @} */

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a39ad965/relational_operators/WorkOrder.proto
----------------------------------------------------------------------
diff --git a/relational_operators/WorkOrder.proto b/relational_operators/WorkOrder.proto
index e0ec19d..1a0bcd1 100644
--- a/relational_operators/WorkOrder.proto
+++ b/relational_operators/WorkOrder.proto
@@ -29,18 +29,20 @@ enum WorkOrderType {
   DESTROY_HASH = 6;
   DROP_TABLE = 7;
   FINALIZE_AGGREGATION = 8;
-  HASH_JOIN = 9;
-  INSERT = 10;
-  NESTED_LOOP_JOIN = 11;
-  SAMPLE = 12;
-  SAVE_BLOCKS = 13;
-  SELECT = 14;
-  SORT_MERGE_RUN = 15;
-  SORT_RUN_GENERATION = 16;
-  TABLE_GENERATOR = 17;
-  TEXT_SCAN = 18;
-  TEXT_SPLIT = 19;
-  UPDATE = 20;
+  HASH_INNER_JOIN = 9;
+  HASH_SEMI_JOIN = 10;
+  HASH_ANTI_JOIN = 11;
+  INSERT = 12;
+  NESTED_LOOP_JOIN = 13;
+  SAMPLE = 14;
+  SAVE_BLOCKS = 15;
+  SELECT = 16;
+  SORT_MERGE_RUN = 17;
+  SORT_RUN_GENERATION = 18;
+  TABLE_GENERATOR = 19;
+  TEXT_SCAN = 20;
+  TEXT_SPLIT = 21;
+  UPDATE = 22;
 }
 
 message WorkOrder {
@@ -104,7 +106,7 @@ message FinalizeAggregationWorkOrder {
   }
 }
 
-message HashJoinWorkOrder {
+message HashInnerJoinWorkOrder {
   extend WorkOrder {
     // All required.
     optional int32 build_relation_id = 160;
@@ -119,6 +121,36 @@ message HashJoinWorkOrder {
   }
 }
 
+message HashAntiJoinWorkOrder {
+  extend WorkOrder {
+    // All required.
+    optional int32 build_relation_id = 350;
+    optional int32 probe_relation_id = 351;
+    repeated int32 join_key_attributes = 352;
+    optional bool any_join_key_attributes_nullable = 353;
+    optional int32 insert_destination_index = 354;
+    optional uint32 join_hash_table_index = 355;
+    optional int32 residual_predicate_index = 356;
+    optional int32 selection_index = 357;
+    optional fixed64 block_id = 358;
+  }
+}
+
+message HashSemiJoinWorkOrder {
+  extend WorkOrder {
+    // All required.
+    optional int32 build_relation_id = 360;
+    optional int32 probe_relation_id = 361;
+    repeated int32 join_key_attributes = 362;
+    optional bool any_join_key_attributes_nullable = 363;
+    optional int32 insert_destination_index = 364;
+    optional uint32 join_hash_table_index = 365;
+    optional int32 residual_predicate_index = 366;
+    optional int32 selection_index = 367;
+    optional fixed64 block_id = 368;
+  }
+}
+
 message InsertWorkOrder {
   extend WorkOrder {
     // All required.

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a39ad965/relational_operators/WorkOrderFactory.cpp
----------------------------------------------------------------------
diff --git a/relational_operators/WorkOrderFactory.cpp b/relational_operators/WorkOrderFactory.cpp
index 4713681..92c1140 100644
--- a/relational_operators/WorkOrderFactory.cpp
+++ b/relational_operators/WorkOrderFactory.cpp
@@ -135,30 +135,88 @@ WorkOrder* WorkOrderFactory::ReconstructFromProto(const serialization::WorkOrder
           query_context->getInsertDestination(
               proto.GetExtension(serialization::FinalizeAggregationWorkOrder::insert_destination_index)));
     }
-    case serialization::HASH_JOIN: {
-      LOG(INFO) << "Creating HashJoinWorkOrder";
+    case serialization::HASH_INNER_JOIN: {
+      LOG(INFO) << "Creating HashInnerJoinWorkOrder";
       vector<attribute_id> join_key_attributes;
-      for (int i = 0; i < proto.ExtensionSize(serialization::HashJoinWorkOrder::join_key_attributes); ++i) {
+      const int join_key_attributes_size =
+          proto.ExtensionSize(serialization::HashAntiJoinWorkOrder::join_key_attributes);
+      for (int i = 0; i < join_key_attributes_size; ++i) {
         join_key_attributes.push_back(
-            proto.GetExtension(serialization::HashJoinWorkOrder::join_key_attributes, i));
+            proto.GetExtension(serialization::HashInnerJoinWorkOrder::join_key_attributes, i));
       }
 
-      return new HashJoinWorkOrder(
+      return new HashInnerJoinWorkOrder(
           catalog_database->getRelationSchemaById(
-              proto.GetExtension(serialization::HashJoinWorkOrder::build_relation_id)),
+              proto.GetExtension(serialization::HashInnerJoinWorkOrder::build_relation_id)),
           catalog_database->getRelationSchemaById(
-              proto.GetExtension(serialization::HashJoinWorkOrder::probe_relation_id)),
+              proto.GetExtension(serialization::HashInnerJoinWorkOrder::probe_relation_id)),
           move(join_key_attributes),
-          proto.GetExtension(serialization::HashJoinWorkOrder::any_join_key_attributes_nullable),
-          proto.GetExtension(serialization::HashJoinWorkOrder::block_id),
+          proto.GetExtension(serialization::HashInnerJoinWorkOrder::any_join_key_attributes_nullable),
+          proto.GetExtension(serialization::HashInnerJoinWorkOrder::block_id),
           query_context->getPredicate(
-              proto.GetExtension(serialization::HashJoinWorkOrder::residual_predicate_index)),
+              proto.GetExtension(serialization::HashInnerJoinWorkOrder::residual_predicate_index)),
           query_context->getScalarGroup(
-              proto.GetExtension(serialization::HashJoinWorkOrder::selection_index)),
+              proto.GetExtension(serialization::HashInnerJoinWorkOrder::selection_index)),
+          *query_context->getJoinHashTable(
+              proto.GetExtension(serialization::HashInnerJoinWorkOrder::join_hash_table_index)),
           query_context->getInsertDestination(
-              proto.GetExtension(serialization::HashJoinWorkOrder::insert_destination_index)),
-          query_context->getJoinHashTable(
-              proto.GetExtension(serialization::HashJoinWorkOrder::join_hash_table_index)),
+              proto.GetExtension(serialization::HashInnerJoinWorkOrder::insert_destination_index)),
+          storage_manager);
+    }
+    case serialization::HASH_SEMI_JOIN: {
+      LOG(INFO) << "Creating HashSemiJoinWorkOrder";
+      vector<attribute_id> join_key_attributes;
+      const int join_key_attributes_size =
+          proto.ExtensionSize(serialization::HashAntiJoinWorkOrder::join_key_attributes);
+      for (int i = 0; i < join_key_attributes_size; ++i) {
+        join_key_attributes.push_back(
+            proto.GetExtension(serialization::HashSemiJoinWorkOrder::join_key_attributes, i));
+      }
+
+      return new HashSemiJoinWorkOrder(
+          catalog_database->getRelationSchemaById(
+              proto.GetExtension(serialization::HashSemiJoinWorkOrder::build_relation_id)),
+          catalog_database->getRelationSchemaById(
+              proto.GetExtension(serialization::HashSemiJoinWorkOrder::probe_relation_id)),
+          move(join_key_attributes),
+          proto.GetExtension(serialization::HashSemiJoinWorkOrder::any_join_key_attributes_nullable),
+          proto.GetExtension(serialization::HashSemiJoinWorkOrder::block_id),
+          query_context->getPredicate(
+              proto.GetExtension(serialization::HashSemiJoinWorkOrder::residual_predicate_index)),
+          query_context->getScalarGroup(
+              proto.GetExtension(serialization::HashSemiJoinWorkOrder::selection_index)),
+          *query_context->getJoinHashTable(
+              proto.GetExtension(serialization::HashSemiJoinWorkOrder::join_hash_table_index)),
+          query_context->getInsertDestination(
+              proto.GetExtension(serialization::HashSemiJoinWorkOrder::insert_destination_index)),
+          storage_manager);
+    }
+    case serialization::HASH_ANTI_JOIN: {
+      LOG(INFO) << "Creating HashAntiJoinWorkOrder";
+      vector<attribute_id> join_key_attributes;
+      const int join_key_attributes_size =
+          proto.ExtensionSize(serialization::HashAntiJoinWorkOrder::join_key_attributes);
+      for (int i = 0; i < join_key_attributes_size; ++i) {
+        join_key_attributes.push_back(
+            proto.GetExtension(serialization::HashAntiJoinWorkOrder::join_key_attributes, i));
+      }
+
+      return new HashAntiJoinWorkOrder(
+          catalog_database->getRelationSchemaById(
+              proto.GetExtension(serialization::HashAntiJoinWorkOrder::build_relation_id)),
+          catalog_database->getRelationSchemaById(
+              proto.GetExtension(serialization::HashAntiJoinWorkOrder::probe_relation_id)),
+          move(join_key_attributes),
+          proto.GetExtension(serialization::HashAntiJoinWorkOrder::any_join_key_attributes_nullable),
+          proto.GetExtension(serialization::HashAntiJoinWorkOrder::block_id),
+          query_context->getPredicate(
+              proto.GetExtension(serialization::HashAntiJoinWorkOrder::residual_predicate_index)),
+          query_context->getScalarGroup(
+              proto.GetExtension(serialization::HashAntiJoinWorkOrder::selection_index)),
+          *query_context->getJoinHashTable(
+              proto.GetExtension(serialization::HashAntiJoinWorkOrder::join_hash_table_index)),
+          query_context->getInsertDestination(
+              proto.GetExtension(serialization::HashAntiJoinWorkOrder::insert_destination_index)),
           storage_manager);
     }
     case serialization::INSERT: {
@@ -394,46 +452,137 @@ bool WorkOrderFactory::ProtoIsValid(const serialization::WorkOrder &proto,
              query_context.isValidInsertDestinationId(
                  proto.GetExtension(serialization::FinalizeAggregationWorkOrder::insert_destination_index));
     }
-    case serialization::HASH_JOIN: {
-      if (!proto.HasExtension(serialization::HashJoinWorkOrder::build_relation_id) ||
-          !proto.HasExtension(serialization::HashJoinWorkOrder::probe_relation_id)) {
+    case serialization::HASH_INNER_JOIN: {
+      if (!proto.HasExtension(serialization::HashInnerJoinWorkOrder::build_relation_id) ||
+          !proto.HasExtension(serialization::HashInnerJoinWorkOrder::probe_relation_id)) {
+        return false;
+      }
+
+      const relation_id build_relation_id =
+          proto.GetExtension(serialization::HashInnerJoinWorkOrder::build_relation_id);
+      if (!catalog_database.hasRelationWithId(build_relation_id)) {
+        return false;
+      }
+
+      const relation_id probe_relation_id =
+          proto.GetExtension(serialization::HashInnerJoinWorkOrder::probe_relation_id);
+      if (!catalog_database.hasRelationWithId(probe_relation_id)) {
+        return false;
+      }
+
+      const CatalogRelationSchema &build_relation = catalog_database.getRelationSchemaById(build_relation_id);
+      const CatalogRelationSchema &probe_relation = catalog_database.getRelationSchemaById(probe_relation_id);
+      for (int i = 0; i < proto.ExtensionSize(serialization::HashInnerJoinWorkOrder::join_key_attributes); ++i) {
+        const attribute_id attr_id =
+            proto.GetExtension(serialization::HashInnerJoinWorkOrder::join_key_attributes, i);
+        if (!build_relation.hasAttributeWithId(attr_id) ||
+            !probe_relation.hasAttributeWithId(attr_id)) {
+          return false;
+        }
+      }
+
+      return proto.HasExtension(serialization::HashInnerJoinWorkOrder::any_join_key_attributes_nullable) &&
+             proto.HasExtension(serialization::HashInnerJoinWorkOrder::insert_destination_index) &&
+             query_context.isValidInsertDestinationId(
+                 proto.GetExtension(serialization::HashInnerJoinWorkOrder::insert_destination_index)) &&
+             proto.HasExtension(serialization::HashInnerJoinWorkOrder::join_hash_table_index) &&
+             query_context.isValidJoinHashTableId(
+                 proto.GetExtension(serialization::HashInnerJoinWorkOrder::join_hash_table_index)) &&
+             proto.HasExtension(serialization::HashInnerJoinWorkOrder::residual_predicate_index) &&
+             query_context.isValidPredicate(
+                 proto.GetExtension(serialization::HashInnerJoinWorkOrder::residual_predicate_index)) &&
+             proto.HasExtension(serialization::HashInnerJoinWorkOrder::selection_index) &&
+             query_context.isValidScalarGroupId(
+                 proto.GetExtension(serialization::HashInnerJoinWorkOrder::selection_index)) &&
+             proto.HasExtension(serialization::HashInnerJoinWorkOrder::block_id);
+    }
+    case serialization::HASH_SEMI_JOIN: {
+      if (!proto.HasExtension(serialization::HashSemiJoinWorkOrder::build_relation_id) ||
+          !proto.HasExtension(serialization::HashSemiJoinWorkOrder::probe_relation_id)) {
+        return false;
+      }
+
+      const relation_id build_relation_id =
+          proto.GetExtension(serialization::HashSemiJoinWorkOrder::build_relation_id);
+      if (!catalog_database.hasRelationWithId(build_relation_id)) {
+        return false;
+      }
+
+      const relation_id probe_relation_id =
+          proto.GetExtension(serialization::HashSemiJoinWorkOrder::probe_relation_id);
+      if (!catalog_database.hasRelationWithId(probe_relation_id)) {
+        return false;
+      }
+
+      const CatalogRelationSchema &build_relation = catalog_database.getRelationSchemaById(build_relation_id);
+      const CatalogRelationSchema &probe_relation = catalog_database.getRelationSchemaById(probe_relation_id);
+      for (int i = 0; i < proto.ExtensionSize(serialization::HashSemiJoinWorkOrder::join_key_attributes); ++i) {
+        const attribute_id attr_id =
+            proto.GetExtension(serialization::HashSemiJoinWorkOrder::join_key_attributes, i);
+        if (!build_relation.hasAttributeWithId(attr_id) ||
+            !probe_relation.hasAttributeWithId(attr_id)) {
+          return false;
+        }
+      }
+
+      return proto.HasExtension(serialization::HashSemiJoinWorkOrder::any_join_key_attributes_nullable) &&
+             proto.HasExtension(serialization::HashSemiJoinWorkOrder::insert_destination_index) &&
+             query_context.isValidInsertDestinationId(
+                 proto.GetExtension(serialization::HashSemiJoinWorkOrder::insert_destination_index)) &&
+             proto.HasExtension(serialization::HashSemiJoinWorkOrder::join_hash_table_index) &&
+             query_context.isValidJoinHashTableId(
+                 proto.GetExtension(serialization::HashSemiJoinWorkOrder::join_hash_table_index)) &&
+             proto.HasExtension(serialization::HashSemiJoinWorkOrder::residual_predicate_index) &&
+             query_context.isValidPredicate(
+                 proto.GetExtension(serialization::HashSemiJoinWorkOrder::residual_predicate_index)) &&
+             proto.HasExtension(serialization::HashSemiJoinWorkOrder::selection_index) &&
+             query_context.isValidScalarGroupId(
+                 proto.GetExtension(serialization::HashSemiJoinWorkOrder::selection_index)) &&
+             proto.HasExtension(serialization::HashSemiJoinWorkOrder::block_id);
+    }
+    case serialization::HASH_ANTI_JOIN: {
+      if (!proto.HasExtension(serialization::HashAntiJoinWorkOrder::build_relation_id) ||
+          !proto.HasExtension(serialization::HashAntiJoinWorkOrder::probe_relation_id)) {
         return false;
       }
 
-      const relation_id build_relation_id = proto.GetExtension(serialization::HashJoinWorkOrder::build_relation_id);
+      const relation_id build_relation_id =
+          proto.GetExtension(serialization::HashAntiJoinWorkOrder::build_relation_id);
       if (!catalog_database.hasRelationWithId(build_relation_id)) {
         return false;
       }
 
-      const relation_id probe_relation_id = proto.GetExtension(serialization::HashJoinWorkOrder::probe_relation_id);
+      const relation_id probe_relation_id =
+          proto.GetExtension(serialization::HashAntiJoinWorkOrder::probe_relation_id);
       if (!catalog_database.hasRelationWithId(probe_relation_id)) {
         return false;
       }
 
       const CatalogRelationSchema &build_relation = catalog_database.getRelationSchemaById(build_relation_id);
       const CatalogRelationSchema &probe_relation = catalog_database.getRelationSchemaById(probe_relation_id);
-      for (int i = 0; i < proto.ExtensionSize(serialization::HashJoinWorkOrder::join_key_attributes); ++i) {
-        const attribute_id attr_id = proto.GetExtension(serialization::HashJoinWorkOrder::join_key_attributes, i);
+      for (int i = 0; i < proto.ExtensionSize(serialization::HashAntiJoinWorkOrder::join_key_attributes); ++i) {
+        const attribute_id attr_id =
+            proto.GetExtension(serialization::HashAntiJoinWorkOrder::join_key_attributes, i);
         if (!build_relation.hasAttributeWithId(attr_id) ||
             !probe_relation.hasAttributeWithId(attr_id)) {
           return false;
         }
       }
 
-      return proto.HasExtension(serialization::HashJoinWorkOrder::any_join_key_attributes_nullable) &&
-             proto.HasExtension(serialization::HashJoinWorkOrder::insert_destination_index) &&
+      return proto.HasExtension(serialization::HashAntiJoinWorkOrder::any_join_key_attributes_nullable) &&
+             proto.HasExtension(serialization::HashAntiJoinWorkOrder::insert_destination_index) &&
              query_context.isValidInsertDestinationId(
-                 proto.GetExtension(serialization::HashJoinWorkOrder::insert_destination_index)) &&
-             proto.HasExtension(serialization::HashJoinWorkOrder::join_hash_table_index) &&
+                 proto.GetExtension(serialization::HashAntiJoinWorkOrder::insert_destination_index)) &&
+             proto.HasExtension(serialization::HashAntiJoinWorkOrder::join_hash_table_index) &&
              query_context.isValidJoinHashTableId(
-                 proto.GetExtension(serialization::HashJoinWorkOrder::join_hash_table_index)) &&
-             proto.HasExtension(serialization::HashJoinWorkOrder::residual_predicate_index) &&
+                 proto.GetExtension(serialization::HashAntiJoinWorkOrder::join_hash_table_index)) &&
+             proto.HasExtension(serialization::HashAntiJoinWorkOrder::residual_predicate_index) &&
              query_context.isValidPredicate(
-                 proto.GetExtension(serialization::HashJoinWorkOrder::residual_predicate_index)) &&
-             proto.HasExtension(serialization::HashJoinWorkOrder::selection_index) &&
+                 proto.GetExtension(serialization::HashAntiJoinWorkOrder::residual_predicate_index)) &&
+             proto.HasExtension(serialization::HashAntiJoinWorkOrder::selection_index) &&
              query_context.isValidScalarGroupId(
-                 proto.GetExtension(serialization::HashJoinWorkOrder::selection_index)) &&
-             proto.HasExtension(serialization::HashJoinWorkOrder::block_id);
+                 proto.GetExtension(serialization::HashAntiJoinWorkOrder::selection_index)) &&
+             proto.HasExtension(serialization::HashAntiJoinWorkOrder::block_id);
     }
     case serialization::INSERT: {
       return proto.HasExtension(serialization::InsertWorkOrder::insert_destination_index) &&

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a39ad965/storage/HashTable.hpp
----------------------------------------------------------------------
diff --git a/storage/HashTable.hpp b/storage/HashTable.hpp
index ab74e2c..ef79d11 100644
--- a/storage/HashTable.hpp
+++ b/storage/HashTable.hpp
@@ -707,6 +707,89 @@ class HashTable : public HashTableBase<resizable,
                                FunctorT *functor) const;
 
   /**
+   * @brief Lookup (multiple) keys from a ValueAccessor, apply a functor to
+   *        the matching values and additionally call a hasMatch() function of
+   *        the functor when the first match for a key is found.
+   * @warning This method assumes that no concurrent calls to put(),
+   *          putCompositeKey(), putValueAccessor(),
+   *          putValueAccessorCompositeKey(), upsert(), upsertCompositeKey(),
+   *          upsertValueAccessor(), or upsertValueAccessorCompositeKey() are
+   *          taking place (i.e. that this HashTable is immutable for the
+   *          duration of the call and as long as the returned pointer may be
+   *          dereferenced). Concurrent calls to getSingle(),
+   *          getSingleCompositeKey(), getAll(), getAllCompositeKey(),
+   *          getAllFromValueAccessor(), getAllFromValueAccessorCompositeKey(),
+   *          forEach(), and forEachCompositeKey() are safe.
+   * @note This version is for single scalar keys. See also
+   *       getAllFromValueAccessorCompositeKeyWithExtraWorkForFirstMatch().
+   *
+   * @param accessor A ValueAccessor which will be used to access keys.
+   *        beginIteration() should be called on accessor before calling this
+   *        method.
+   * @param key_attr_id The attribute ID of the keys to be read from accessor.
+   * @param check_for_null_keys If true, each key will be checked to see if it
+   *        is null before looking it up (null keys are skipped). This must be
+   *        set to true if some of the keys that will be read from accessor may
+   *        be null.
+   * @param functor A pointer to a functor, which should provide two functions:
+   *        1) An operator that takes 2 arguments: const ValueAccessor& (or better
+   *        yet, a templated call operator which takes a const reference to
+   *        some subclass of ValueAccessor as its first argument) and
+   *        const ValueT&. The operator will be invoked once for each pair of a
+   *        key taken from accessor and matching value.
+   *        2) A function hasMatch that takes 1 argument: const ValueAccessor&.
+   *        The function will be called only once for a key from accessor when
+   *        the first match is found.
+   */
+  template <typename FunctorT>
+  void getAllFromValueAccessorWithExtraWorkForFirstMatch(
+      ValueAccessor *accessor,
+      const attribute_id key_attr_id,
+      const bool check_for_null_keys,
+      FunctorT *functor) const;
+
+  /**
+   * @brief Lookup (multiple) keys from a ValueAccessor, apply a functor to
+   *        the matching values and additionally call a hasMatch() function of
+   *        the functor when the first match for a key is found. Composite key
+   *        version.
+   * @warning This method assumes that no concurrent calls to put(),
+   *          putCompositeKey(), putValueAccessor(),
+   *          putValueAccessorCompositeKey(), upsert(), upsertCompositeKey(),
+   *          upsertValueAccessor(), or upsertValueAccessorCompositeKey() are
+   *          taking place (i.e. that this HashTable is immutable for the
+   *          duration of the call and as long as the returned pointer may be
+   *          dereferenced). Concurrent calls to getSingle(),
+   *          getSingleCompositeKey(), getAll(), getAllCompositeKey(),
+   *          getAllFromValueAccessor(), getAllFromValueAccessorCompositeKey(),
+   *          forEach(), and forEachCompositeKey() are safe.
+   *
+   * @param accessor A ValueAccessor which will be used to access keys.
+   *        beginIteration() should be called on accessor before calling this
+   *        method.
+   * @param key_attr_id The attribute ID of the keys to be read from accessor.
+   * @param check_for_null_keys If true, each key will be checked to see if it
+   *        is null before looking it up (null keys are skipped). This must be
+   *        set to true if some of the keys that will be read from accessor may
+   *        be null.
+   * @param functor A pointer to a functor, which should provide two functions:
+   *        1) An operator that takes 2 arguments: const ValueAccessor& (or better
+   *        yet, a templated call operator which takes a const reference to
+   *        some subclass of ValueAccessor as its first argument) and
+   *        const ValueT&. The operator will be invoked once for each pair of a
+   *        key taken from accessor and matching value.
+   *        2) A function hasMatch that takes 1 argument: const ValueAccessor&.
+   *        The function will be called only once for a key from accessor when
+   *        the first match is found.
+   */
+  template <typename FunctorT>
+  void getAllFromValueAccessorCompositeKeyWithExtraWorkForFirstMatch(
+      ValueAccessor *accessor,
+      const std::vector<attribute_id> &key_attr_ids,
+      const bool check_for_null_keys,
+      FunctorT *functor) const;
+
+  /**
    * @brief Lookup (multiple) keys from a ValueAccessor and apply a functor to
    *        the matching values. Composite key version.
    *
@@ -746,6 +829,113 @@ class HashTable : public HashTableBase<resizable,
                                            FunctorT *functor) const;
 
   /**
+   * @brief Apply the functor to each key with a match in the hash table.
+   *
+   * @param accessor A ValueAccessor which will be used to access keys.
+   *        beginIteration() should be called on accessor before calling this
+   *        method.
+   * @param key_attr_id The attribute ID of the keys to be read from accessor.
+   * @param check_for_null_keys If true, each key will be checked to see if it
+   *        is null before looking it up (null keys are skipped). This must be
+   *        set to true if some of the keys that will be read from accessor may
+   *        be null.
+   * @param functor A pointer to a functor which should provide an operator that
+   *        takes 1 argument: const ValueAccessor&. The operator will be called
+   *        only once for a key from accessor if there is a match.
+   */
+  template <typename FunctorT>
+  void runOverKeysFromValueAccessorIfMatchFound(ValueAccessor *accessor,
+                                                const attribute_id key_attr_id,
+                                                const bool check_for_null_keys,
+                                                FunctorT *functor) const {
+    return runOverKeysFromValueAccessor<true>(accessor,
+                                              key_attr_id,
+                                              check_for_null_keys,
+                                              functor);
+  }
+
+  /**
+   * @brief Apply the functor to each key with a match in the hash table.
+   *
+   * @param accessor A ValueAccessor which will be used to access keys.
+   *        beginIteration() should be called on accessor before calling this
+   *        method.
+   * @param key_attr_id The attribute ID of the keys to be read from accessor.
+   * @param check_for_null_keys If true, each key will be checked to see if it
+   *        is null before looking it up (null keys are skipped). This must be
+   *        set to true if some of the keys that will be read from accessor may
+   *        be null.
+   * @param functor A pointer to a functor which should provide an operator that
+   *        takes 1 argument: const ValueAccessor&. The operator will be called
+   *        only once for a key from accessor if there is a match.
+   */
+  template <typename FunctorT>
+  void runOverKeysFromValueAccessorIfMatchFoundCompositeKey(
+      ValueAccessor *accessor,
+      const std::vector<attribute_id> &key_attr_ids,
+      const bool check_for_null_keys,
+      FunctorT *functor) const {
+    return runOverKeysFromValueAccessorCompositeKey<true>(accessor,
+                                                          key_attr_ids,
+                                                          check_for_null_keys,
+                                                          functor);
+  }
+
+  /**
+   * @brief Apply the functor to each key without a match in the hash table.
+   *
+   * @param accessor A ValueAccessor which will be used to access keys.
+   *        beginIteration() should be called on accessor before calling this
+   *        method.
+   * @param key_attr_id The attribute ID of the keys to be read from accessor.
+   * @param check_for_null_keys If true, each key will be checked to see if it
+   *        is null before looking it up (null keys are skipped). This must be
+   *        set to true if some of the keys that will be read from accessor may
+   *        be null.
+   * @param functor A pointer to a functor which should provide an operator that
+   *        takes 1 argument: const ValueAccessor&. The operator will be called
+   *        only once for a key from accessor if there is no match.
+   */
+  template <typename FunctorT>
+  void runOverKeysFromValueAccessorIfMatchNotFound(
+      ValueAccessor *accessor,
+      const attribute_id key_attr_id,
+      const bool check_for_null_keys,
+      FunctorT *functor) const {
+    return runOverKeysFromValueAccessor<false>(accessor,
+                                               key_attr_id,
+                                               check_for_null_keys,
+                                               functor);
+  }
+
+  /**
+   * @brief Apply the functor to each key without a match in the hash table.
+   *
+   * @param accessor A ValueAccessor which will be used to access keys.
+   *        beginIteration() should be called on accessor before calling this
+   *        method.
+   * @param key_attr_id The attribute ID of the keys to be read from accessor.
+   * @param check_for_null_keys If true, each key will be checked to see if it
+   *        is null before looking it up (null keys are skipped). This must be
+   *        set to true if some of the keys that will be read from accessor may
+   *        be null.
+   * @param functor A pointer to a functor which should provide an operator that
+   *        takes 1 argument: const ValueAccessor&. The operator will be called
+   *        only once for a key from accessor if there is no match.
+   */
+  template <typename FunctorT>
+  void runOverKeysFromValueAccessorIfMatchNotFoundCompositeKey(
+      ValueAccessor *accessor,
+      const std::vector<attribute_id> &key_attr_ids,
+      const bool check_for_null_keys,
+      FunctorT *functor) const {
+    return runOverKeysFromValueAccessorCompositeKey<false>(accessor,
+                                                           key_attr_ids,
+                                                           check_for_null_keys,
+                                                           functor);
+  }
+
+  /**
    * @brief Apply a functor to each key, value pair in this hash table.
    *
    * @warning This method assumes that no concurrent calls to put(),
@@ -965,6 +1155,10 @@ class HashTable : public HashTableBase<resizable,
                                            const ValueT **value,
                                            std::size_t *entry_num) const = 0;
 
+  // Return true if key exists in the hash table.
+  virtual bool hasKey(const TypedValue &key) const = 0;
+  virtual bool hasCompositeKey(const std::vector<TypedValue> &key) const = 0;
+
   // For a resizable HashTable, grow to accomodate more entries. If
   // 'extra_buckets' is not zero, it may serve as a "hint" to implementations
   // that at least the requested number of extra buckets are required when
@@ -1048,6 +1242,21 @@ class HashTable : public HashTableBase<resizable,
     return false;
   }
 
+  // If run_if_match_found is true, apply the functor to each key if a match is
+  // found; otherwise, apply the functor if no match is found.
+  template <bool run_if_match_found, typename FunctorT>
+  void runOverKeysFromValueAccessor(ValueAccessor *accessor,
+                                    const attribute_id key_attr_id,
+                                    const bool check_for_null_keys,
+                                    FunctorT *functor) const;
+
+  template <bool run_if_match_found, typename FunctorT>
+  void runOverKeysFromValueAccessorCompositeKey(
+      ValueAccessor *accessor,
+      const std::vector<attribute_id> &key_attr_ids,
+      const bool check_for_null_keys,
+      FunctorT *functor) const;
+
   // Method containing the actual logic implementing getAllFromValueAccessor().
   // Has extra template parameters that control behavior to avoid some
   // inner-loop branching.
@@ -1678,6 +1887,184 @@ template <typename ValueT,
           bool force_key_copy,
           bool allow_duplicate_keys>
 template <typename FunctorT>
+void HashTable<ValueT,
+               resizable,
+               serializable,
+               force_key_copy,
+               allow_duplicate_keys>::
+    getAllFromValueAccessorWithExtraWorkForFirstMatch(
+        ValueAccessor *accessor,
+        const attribute_id key_attr_id,
+        const bool check_for_null_keys,
+        FunctorT *functor) const {
+  InvokeOnAnyValueAccessor(
+      accessor,
+      [&](auto *accessor) -> void {  // NOLINT(build/c++11)
+    while (accessor->next()) {
+      TypedValue key = accessor->getTypedValue(key_attr_id);
+      if (check_for_null_keys && key.isNull()) {
+        continue;
+      }
+      const std::size_t hash_code = adjust_hashes_ ? AdjustHash(key.getHash())
+                                                   : key.getHash();
+      std::size_t entry_num = 0;
+      const ValueT *value;
+      if (getNextEntryForKey(key, hash_code, &value, &entry_num)) {
+        functor->recordMatch(*accessor);
+        (*functor)(*accessor, *value);
+        if (!allow_duplicate_keys) {
+           continue;
+        }
+        while (getNextEntryForKey(key, hash_code, &value, &entry_num)) {
+          (*functor)(*accessor, *value);
+        }
+      }
+    }
+  });  // NOLINT(whitespace/parens)
+}
+
+template <typename ValueT,
+          bool resizable,
+          bool serializable,
+          bool force_key_copy,
+          bool allow_duplicate_keys>
+template <typename FunctorT>
+void HashTable<ValueT, resizable, serializable, force_key_copy, allow_duplicate_keys>
+    ::getAllFromValueAccessorCompositeKeyWithExtraWorkForFirstMatch(
+        ValueAccessor *accessor,
+        const std::vector<attribute_id> &key_attr_ids,
+        const bool check_for_null_keys,
+        FunctorT *functor) const {
+  DEBUG_ASSERT(key_types_.size() == key_attr_ids.size());
+  std::vector<TypedValue> key_vector;
+  key_vector.resize(key_attr_ids.size());
+  InvokeOnAnyValueAccessor(
+      accessor,
+      [&](auto *accessor) -> void {  // NOLINT(build/c++11)
+    while (accessor->next()) {
+      bool null_key = false;
+      for (std::vector<attribute_id>::size_type key_idx = 0;
+           key_idx < key_types_.size();
+           ++key_idx) {
+        key_vector[key_idx] = accessor->getTypedValue(key_attr_ids[key_idx]);
+        if (check_for_null_keys && key_vector[key_idx].isNull()) {
+          null_key = true;
+          break;
+        }
+      }
+      if (null_key) {
+        continue;
+      }
+
+      const std::size_t hash_code = adjust_hashes_ ? AdjustHash(hashCompositeKey(key_vector))
+                                                   : hashCompositeKey(key_vector);
+      std::size_t entry_num = 0;
+      const ValueT *value;
+      if (getNextEntryForCompositeKey(key_vector, hash_code, &value, &entry_num)) {
+        functor->recordMatch(*accessor);
+        (*functor)(*accessor, *value);
+        if (!allow_duplicate_keys) {
+          continue;
+        }
+        while (getNextEntryForCompositeKey(key_vector, hash_code, &value, &entry_num)) {
+          (*functor)(*accessor, *value);
+        }
+      }
+    }
+  });  // NOLINT(whitespace/parens)
+}
+
+template <typename ValueT,
+          bool resizable,
+          bool serializable,
+          bool force_key_copy,
+          bool allow_duplicate_keys>
+template <bool run_if_match_found, typename FunctorT>
+void HashTable<ValueT,
+               resizable,
+               serializable,
+               force_key_copy,
+               allow_duplicate_keys>::
+    runOverKeysFromValueAccessor(ValueAccessor *accessor,
+                                 const attribute_id key_attr_id,
+                                 const bool check_for_null_keys,
+                                 FunctorT *functor) const {
+  InvokeOnAnyValueAccessor(
+      accessor,
+      [&](auto *accessor) -> void {  // NOLINT(build/c++11)
+    while (accessor->next()) {
+      TypedValue key = accessor->getTypedValue(key_attr_id);
+      if (check_for_null_keys && key.isNull()) {
+        if (!run_if_match_found) {
+          (*functor)(*accessor);
+          continue;
+        }
+      }
+      if (run_if_match_found) {
+        if (this->hasKey(key)) {
+          (*functor)(*accessor);
+        }
+      } else {
+        if (!this->hasKey(key)) {
+          (*functor)(*accessor);
+        }
+      }
+    }
+  });  // NOLINT(whitespace/parens)
+}
+
+template <typename ValueT,
+          bool resizable,
+          bool serializable,
+          bool force_key_copy,
+          bool allow_duplicate_keys>
+template <bool run_if_match_found, typename FunctorT>
+void HashTable<ValueT, resizable, serializable, force_key_copy, allow_duplicate_keys>
+    ::runOverKeysFromValueAccessorCompositeKey(ValueAccessor *accessor,
+                                               const std::vector<attribute_id> &key_attr_ids,
+                                               const bool check_for_null_keys,
+                                               FunctorT *functor) const {
+  DEBUG_ASSERT(key_types_.size() == key_attr_ids.size());
+  std::vector<TypedValue> key_vector;
+  key_vector.resize(key_attr_ids.size());
+  InvokeOnAnyValueAccessor(
+      accessor,
+      [&](auto *accessor) -> void {  // NOLINT(build/c++11)
+    while (accessor->next()) {
+      bool null_key = false;
+      for (std::vector<attribute_id>::size_type key_idx = 0;
+           key_idx < key_types_.size();
+           ++key_idx) {
+        key_vector[key_idx] = accessor->getTypedValue(key_attr_ids[key_idx]);
+        if (check_for_null_keys && key_vector[key_idx].isNull()) {
+          null_key = true;
+          break;
+        }
+      }
+      if (null_key) {
+        if (!run_if_match_found) {
+          (*functor)(*accessor);
+          continue;
+        }
+      }
+
+      if (run_if_match_found) {
+        if (this->hasCompositeKey(key_vector)) {
+          (*functor)(*accessor);
+        }
+      } else if (!this->hasCompositeKey(key_vector)) {
+        (*functor)(*accessor);
+      }
+    }
+  });  // NOLINT(whitespace/parens)
+}
+
+template <typename ValueT,
+          bool resizable,
+          bool serializable,
+          bool force_key_copy,
+          bool allow_duplicate_keys>
+template <typename FunctorT>
 std::size_t HashTable<ValueT, resizable, serializable, force_key_copy, allow_duplicate_keys>
     ::forEach(FunctorT *functor) const {
   std::size_t entries_visited = 0;



[02/24] incubator-quickstep git commit: Support, and tests for SMA index creation via parser.

Posted by zu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/57e12d53/parser/preprocessed/SqlParser_gen.cpp
----------------------------------------------------------------------
diff --git a/parser/preprocessed/SqlParser_gen.cpp b/parser/preprocessed/SqlParser_gen.cpp
index 0a3ccba..fd050a9 100644
--- a/parser/preprocessed/SqlParser_gen.cpp
+++ b/parser/preprocessed/SqlParser_gen.cpp
@@ -1,8 +1,8 @@
-/* A Bison parser, made by GNU Bison 3.0.4.  */
+/* A Bison parser, made by GNU Bison 3.0.2.  */
 
 /* Bison implementation for Yacc-like parsers in C
 
-   Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
+   Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -44,7 +44,7 @@
 #define YYBISON 1
 
 /* Bison version.  */
-#define YYBISON_VERSION "3.0.4"
+#define YYBISON_VERSION "3.0.2"
 
 /* Skeleton name.  */
 #define YYSKELETON_NAME "yacc.c"
@@ -276,30 +276,31 @@ extern int quickstep_yydebug;
     TOKEN_ROW_DELIMITER = 348,
     TOKEN_SELECT = 349,
     TOKEN_SET = 350,
-    TOKEN_SMALLINT = 351,
-    TOKEN_TABLE = 352,
-    TOKEN_THEN = 353,
-    TOKEN_TIME = 354,
-    TOKEN_TIMESTAMP = 355,
-    TOKEN_TRUE = 356,
-    TOKEN_TUPLESAMPLE = 357,
-    TOKEN_UNIQUE = 358,
-    TOKEN_UPDATE = 359,
-    TOKEN_USING = 360,
-    TOKEN_VALUES = 361,
-    TOKEN_VARCHAR = 362,
-    TOKEN_WHEN = 363,
-    TOKEN_WHERE = 364,
-    TOKEN_WITH = 365,
-    TOKEN_YEARMONTH = 366,
-    TOKEN_EOF = 367,
-    TOKEN_LEX_ERROR = 368
+    TOKEN_SMA = 351,
+    TOKEN_SMALLINT = 352,
+    TOKEN_TABLE = 353,
+    TOKEN_THEN = 354,
+    TOKEN_TIME = 355,
+    TOKEN_TIMESTAMP = 356,
+    TOKEN_TRUE = 357,
+    TOKEN_TUPLESAMPLE = 358,
+    TOKEN_UNIQUE = 359,
+    TOKEN_UPDATE = 360,
+    TOKEN_USING = 361,
+    TOKEN_VALUES = 362,
+    TOKEN_VARCHAR = 363,
+    TOKEN_WHEN = 364,
+    TOKEN_WHERE = 365,
+    TOKEN_WITH = 366,
+    TOKEN_YEARMONTH = 367,
+    TOKEN_EOF = 368,
+    TOKEN_LEX_ERROR = 369
   };
 #endif
 
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-
+typedef union YYSTYPE YYSTYPE;
 union YYSTYPE
 {
 #line 116 "../SqlParser.ypp" /* yacc.c:355  */
@@ -392,10 +393,8 @@ union YYSTYPE
   quickstep::PtrVector<quickstep::ParseSubqueryTableReference> *with_list_;
   quickstep::ParseSubqueryTableReference *with_list_element_;
 
-#line 396 "SqlParser_gen.cpp" /* yacc.c:355  */
+#line 397 "SqlParser_gen.cpp" /* yacc.c:355  */
 };
-
-typedef union YYSTYPE YYSTYPE;
 # define YYSTYPE_IS_TRIVIAL 1
 # define YYSTYPE_IS_DECLARED 1
 #endif
@@ -427,7 +426,7 @@ int quickstep_yyparse (yyscan_t yyscanner, quickstep::ParseStatement **parsedSta
 #include "SqlLexer_gen.hpp"
 void NotSupported(const YYLTYPE *location, yyscan_t yyscanner, const std::string &feature);
 
-#line 431 "SqlParser_gen.cpp" /* yacc.c:358  */
+#line 430 "SqlParser_gen.cpp" /* yacc.c:358  */
 
 #ifdef short
 # undef short
@@ -671,21 +670,21 @@ union yyalloc
 /* YYFINAL -- State number of the termination state.  */
 #define YYFINAL  47
 /* YYLAST -- Last index in YYTABLE.  */
-#define YYLAST   1117
+#define YYLAST   1038
 
 /* YYNTOKENS -- Number of terminals.  */
-#define YYNTOKENS  125
+#define YYNTOKENS  126
 /* YYNNTS -- Number of nonterminals.  */
 #define YYNNTS  95
 /* YYNRULES -- Number of rules.  */
-#define YYNRULES  249
+#define YYNRULES  250
 /* YYNSTATES -- Number of states.  */
-#define YYNSTATES  485
+#define YYNSTATES  486
 
 /* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
    by yylex, with out-of-bounds checking.  */
 #define YYUNDEFTOK  2
-#define YYMAXUTOK   368
+#define YYMAXUTOK   369
 
 #define YYTRANSLATE(YYX)                                                \
   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
@@ -695,11 +694,11 @@ union yyalloc
 static const yytype_uint8 yytranslate[] =
 {
        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-     120,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+     121,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,   124,     2,     2,
-     121,   122,    23,    21,   123,    22,    27,    24,     2,     2,
-       2,     2,     2,     2,     2,     2,     2,     2,     2,   119,
+       2,     2,     2,     2,     2,     2,     2,   125,     2,     2,
+     122,   123,    23,    21,   124,    22,    27,    24,     2,     2,
+       2,     2,     2,     2,     2,     2,     2,     2,     2,   120,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
@@ -730,38 +729,39 @@ static const yytype_uint8 yytranslate[] =
       80,    81,    82,    83,    84,    85,    86,    87,    88,    89,
       90,    91,    92,    93,    94,    95,    96,    97,    98,    99,
      100,   101,   102,   103,   104,   105,   106,   107,   108,   109,
-     110,   111,   112,   113,   114,   115,   116,   117,   118
+     110,   111,   112,   113,   114,   115,   116,   117,   118,   119
 };
 
 #if YYDEBUG
   /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
 static const yytype_uint16 yyrline[] =
 {
-       0,   566,   566,   570,   574,   578,   582,   585,   592,   595,
-     598,   601,   604,   607,   610,   613,   616,   619,   625,   631,
-     638,   644,   651,   660,   665,   674,   679,   684,   688,   694,
-     699,   702,   705,   710,   713,   716,   719,   722,   725,   728,
-     731,   734,   737,   749,   752,   755,   773,   793,   796,   799,
-     804,   809,   815,   821,   830,   834,   840,   843,   848,   853,
-     858,   865,   872,   876,   882,   885,   890,   893,   898,   901,
-     906,   909,   928,   932,   938,   942,   948,   951,   954,   959,
-     962,   969,   974,   985,   989,   995,   998,  1004,  1012,  1015,
-    1018,  1024,  1029,  1032,  1037,  1041,  1045,  1049,  1055,  1060,
-    1065,  1069,  1075,  1081,  1084,  1089,  1094,  1098,  1104,  1110,
-    1116,  1119,  1123,  1129,  1132,  1137,  1141,  1147,  1150,  1153,
-    1158,  1163,  1166,  1172,  1176,  1182,  1188,  1194,  1200,  1206,
-    1212,  1218,  1224,  1232,  1237,  1240,  1243,  1248,  1252,  1256,
-    1259,  1263,  1268,  1271,  1276,  1279,  1284,  1288,  1294,  1297,
-    1302,  1305,  1310,  1313,  1318,  1321,  1340,  1344,  1350,  1357,
-    1360,  1363,  1368,  1371,  1374,  1380,  1383,  1388,  1393,  1402,
-    1407,  1416,  1421,  1424,  1429,  1432,  1437,  1443,  1449,  1452,
-    1455,  1463,  1466,  1471,  1474,  1479,  1482,  1487,  1490,  1493,
-    1496,  1499,  1502,  1507,  1511,  1515,  1518,  1523,  1528,  1531,
-    1536,  1540,  1546,  1551,  1555,  1561,  1566,  1569,  1574,  1578,
-    1584,  1587,  1590,  1593,  1605,  1609,  1628,  1643,  1647,  1653,
-    1656,  1661,  1665,  1672,  1675,  1678,  1681,  1684,  1687,  1690,
-    1693,  1696,  1699,  1704,  1715,  1718,  1723,  1726,  1729,  1735,
-    1739,  1745,  1748,  1756,  1759,  1762,  1765,  1771,  1776,  1781
+       0,   567,   567,   571,   575,   579,   583,   586,   593,   596,
+     599,   602,   605,   608,   611,   614,   617,   620,   626,   632,
+     639,   645,   652,   661,   666,   675,   680,   685,   689,   695,
+     700,   703,   706,   711,   714,   717,   720,   723,   726,   729,
+     732,   735,   738,   750,   753,   756,   774,   794,   797,   800,
+     805,   810,   816,   822,   831,   835,   841,   844,   849,   854,
+     859,   866,   873,   877,   883,   886,   891,   894,   899,   902,
+     907,   910,   929,   933,   939,   943,   949,   952,   955,   960,
+     963,   970,   975,   986,   990,   994,  1000,  1003,  1009,  1017,
+    1020,  1023,  1029,  1034,  1037,  1042,  1046,  1050,  1054,  1060,
+    1065,  1070,  1074,  1080,  1086,  1089,  1094,  1099,  1103,  1109,
+    1115,  1121,  1124,  1128,  1134,  1137,  1142,  1146,  1152,  1155,
+    1158,  1163,  1168,  1171,  1177,  1181,  1187,  1193,  1199,  1205,
+    1211,  1217,  1223,  1229,  1237,  1242,  1245,  1248,  1253,  1257,
+    1261,  1264,  1268,  1273,  1276,  1281,  1284,  1289,  1293,  1299,
+    1302,  1307,  1310,  1315,  1318,  1323,  1326,  1345,  1349,  1355,
+    1362,  1365,  1368,  1373,  1376,  1379,  1385,  1388,  1393,  1398,
+    1407,  1412,  1421,  1426,  1429,  1434,  1437,  1442,  1448,  1454,
+    1457,  1460,  1468,  1471,  1476,  1479,  1484,  1487,  1492,  1495,
+    1498,  1501,  1504,  1507,  1512,  1516,  1520,  1523,  1528,  1533,
+    1536,  1541,  1545,  1551,  1556,  1560,  1566,  1571,  1574,  1579,
+    1583,  1589,  1592,  1595,  1598,  1610,  1614,  1633,  1648,  1652,
+    1658,  1661,  1666,  1670,  1677,  1680,  1683,  1686,  1689,  1692,
+    1695,  1698,  1701,  1704,  1709,  1720,  1723,  1728,  1731,  1734,
+    1740,  1744,  1750,  1753,  1761,  1764,  1767,  1770,  1776,  1781,
+    1786
 };
 #endif
 
@@ -793,27 +793,27 @@ static const char *const yytname[] =
   "TOKEN_ON", "TOKEN_ORDER", "TOKEN_OUTER", "TOKEN_PARTITION",
   "TOKEN_PARTITIONS", "TOKEN_PERCENT", "TOKEN_PRIMARY", "TOKEN_QUIT",
   "TOKEN_RANGE", "TOKEN_REAL", "TOKEN_REFERENCES", "TOKEN_RIGHT",
-  "TOKEN_ROW_DELIMITER", "TOKEN_SELECT", "TOKEN_SET", "TOKEN_SMALLINT",
-  "TOKEN_TABLE", "TOKEN_THEN", "TOKEN_TIME", "TOKEN_TIMESTAMP",
-  "TOKEN_TRUE", "TOKEN_TUPLESAMPLE", "TOKEN_UNIQUE", "TOKEN_UPDATE",
-  "TOKEN_USING", "TOKEN_VALUES", "TOKEN_VARCHAR", "TOKEN_WHEN",
-  "TOKEN_WHERE", "TOKEN_WITH", "TOKEN_YEARMONTH", "TOKEN_EOF",
-  "TOKEN_LEX_ERROR", "';'", "'\\n'", "'('", "')'", "','", "'%'", "$accept",
-  "start", "sql_statement", "quit_statement", "alter_table_statement",
-  "create_table_statement", "create_index_statement",
-  "drop_table_statement", "column_def", "column_def_commalist",
-  "data_type", "column_constraint_def", "column_constraint_def_list",
-  "opt_column_constraint_def_list", "table_constraint_def",
-  "table_constraint_def_commalist", "opt_table_constraint_def_commalist",
-  "opt_column_list", "opt_block_properties", "opt_partition_clause",
-  "partition_type", "key_value_list", "key_value", "key_string_value",
-  "key_string_list", "key_integer_value", "index_type",
-  "opt_index_properties", "insert_statement", "copy_from_statement",
-  "opt_copy_from_params", "copy_from_params", "update_statement",
-  "delete_statement", "assignment_list", "assignment_item",
-  "select_statement", "with_clause", "with_list", "with_list_element",
-  "select_query", "opt_all_distinct", "selection",
-  "selection_item_commalist", "selection_item", "from_clause",
+  "TOKEN_ROW_DELIMITER", "TOKEN_SELECT", "TOKEN_SET", "TOKEN_SMA",
+  "TOKEN_SMALLINT", "TOKEN_TABLE", "TOKEN_THEN", "TOKEN_TIME",
+  "TOKEN_TIMESTAMP", "TOKEN_TRUE", "TOKEN_TUPLESAMPLE", "TOKEN_UNIQUE",
+  "TOKEN_UPDATE", "TOKEN_USING", "TOKEN_VALUES", "TOKEN_VARCHAR",
+  "TOKEN_WHEN", "TOKEN_WHERE", "TOKEN_WITH", "TOKEN_YEARMONTH",
+  "TOKEN_EOF", "TOKEN_LEX_ERROR", "';'", "'\\n'", "'('", "')'", "','",
+  "'%'", "$accept", "start", "sql_statement", "quit_statement",
+  "alter_table_statement", "create_table_statement",
+  "create_index_statement", "drop_table_statement", "column_def",
+  "column_def_commalist", "data_type", "column_constraint_def",
+  "column_constraint_def_list", "opt_column_constraint_def_list",
+  "table_constraint_def", "table_constraint_def_commalist",
+  "opt_table_constraint_def_commalist", "opt_column_list",
+  "opt_block_properties", "opt_partition_clause", "partition_type",
+  "key_value_list", "key_value", "key_string_value", "key_string_list",
+  "key_integer_value", "index_type", "opt_index_properties",
+  "insert_statement", "copy_from_statement", "opt_copy_from_params",
+  "copy_from_params", "update_statement", "delete_statement",
+  "assignment_list", "assignment_item", "select_statement", "with_clause",
+  "with_list", "with_list_element", "select_query", "opt_all_distinct",
+  "selection", "selection_item_commalist", "selection_item", "from_clause",
   "opt_join_chain", "join_chain", "join", "subquery_expression",
   "opt_sample_clause", "table_reference", "table_reference_signature",
   "table_reference_signature_primary", "table_reference_commalist",
@@ -849,15 +849,15 @@ static const yytype_uint16 yytoknum[] =
      330,   331,   332,   333,   334,   335,   336,   337,   338,   339,
      340,   341,   342,   343,   344,   345,   346,   347,   348,   349,
      350,   351,   352,   353,   354,   355,   356,   357,   358,   359,
-     360,   361,   362,   363,   364,   365,   366,   367,   368,    59,
-      10,    40,    41,    44,    37
+     360,   361,   362,   363,   364,   365,   366,   367,   368,   369,
+      59,    10,    40,    41,    44,    37
 };
 # endif
 
-#define YYPACT_NINF -222
+#define YYPACT_NINF -223
 
 #define yypact_value_is_default(Yystate) \
-  (!!((Yystate) == (-222)))
+  (!!((Yystate) == (-223)))
 
 #define YYTABLE_NINF -1
 
@@ -868,55 +868,55 @@ static const yytype_uint16 yytoknum[] =
      STATE-NUM.  */
 static const yytype_int16 yypact[] =
 {
-     164,  -222,  -222,    51,   165,    18,    45,   104,    55,  -222,
-      43,   165,   165,  -222,   121,    74,  -222,  -222,  -222,  -222,
-    -222,  -222,  -222,  -222,  -222,  -222,    13,  -222,    91,   210,
-     165,  -222,  -222,   159,   165,   165,   165,   165,   165,  -222,
-    -222,   585,   141,   123,  -222,   218,   132,  -222,  -222,  -222,
-     192,  -222,  -222,  -222,  -222,    19,   266,   196,   168,   180,
-    -222,    67,  -222,  -222,   294,   306,  -222,  -222,  -222,   670,
-     200,  -222,   273,  -222,  -222,   220,  -222,  -222,   312,  -222,
-    -222,  -222,  -222,  -222,  -222,   229,   278,   840,   351,   295,
-     251,  -222,   239,    16,  -222,  -222,  -222,  -222,  -222,  -222,
-    -222,   925,    -6,   165,   165,   261,   165,   165,   222,   234,
-     268,   165,   165,   500,  -222,  -222,   263,   165,  -222,  -222,
-    -222,   500,     3,   -28,  -222,   378,  -222,   165,  -222,   380,
-    -222,    24,  -222,     5,   180,   840,  -222,  -222,   165,   840,
-    -222,  -222,  -222,  -222,   840,   306,  -222,   165,   414,    89,
-    -222,   377,  -222,   290,  -222,   -40,  -222,   290,   165,    93,
-     165,   165,   269,  -222,   270,  -222,   163,  1001,   755,   261,
-     500,   384,   385,  -222,  -222,   293,   373,   957,   169,     6,
-     840,   -15,  -222,   840,  -222,   338,   276,   333,   279,  -222,
-     173,  -222,   103,   173,    29,   332,  -222,  -222,    16,  -222,
-    -222,   281,   840,  -222,   275,   176,   165,  -222,   840,   282,
-    -222,   165,  -222,  -222,   284,   328,   329,   287,  -222,  -222,
-    -222,    96,   165,   299,    93,   165,  -222,    68,  -222,  -222,
-      -3,    39,   500,   500,   257,  -222,  -222,  -222,  -222,  -222,
-    -222,  -222,  -222,   840,   840,     7,  -222,   209,   300,   840,
-      49,  -222,   352,   275,  -222,  -222,   840,  -222,   165,  -222,
-    -222,   154,   335,   165,   162,   179,     5,  -222,   147,  -222,
-    -222,   406,   407,   173,   376,   346,  -222,   211,  -222,   840,
-    -222,   275,  -222,  -222,   500,   296,   301,   165,   418,   110,
-     213,  -222,   215,   397,   302,  -222,   305,   310,  -222,   347,
-     308,   957,  -222,   353,   165,  -222,  -222,    68,  -222,  -222,
-     385,  -222,  -222,  -222,   840,    70,   275,   349,  -222,  -222,
-     957,   313,   275,   840,  -222,    41,  -222,   165,   356,   165,
-     -50,   165,   361,   165,   362,  -222,  -222,   350,   354,  -222,
-     840,   500,   363,  -222,   275,     2,   165,   165,   223,  -222,
-    -222,  -222,  -222,  -222,  -222,  -222,   181,  -222,   165,  -222,
-    -222,   319,    93,   408,   364,  -222,   500,  -222,  -222,   330,
-    -222,   208,   840,  -222,  -222,   957,   275,  -222,   -43,   165,
-     -42,   500,   -27,   165,   -22,   165,  -222,  -222,   334,   384,
-     413,   375,  -222,   237,   240,  -222,   453,   110,  -222,   165,
-    -222,  -222,   339,   420,  -222,    10,   165,   840,   275,   242,
-     500,   -19,   500,   384,   500,   -18,   500,   -17,   840,   457,
-    -222,   369,  -222,  -222,  -222,   244,  -222,  -222,  -222,  -222,
-       9,   165,    53,  -222,   344,   275,  -222,   384,   500,   384,
-     384,   500,   384,   500,   357,  -222,   152,  -222,   165,  -222,
-     165,  -222,  -222,   165,  -222,   246,  -222,  -222,   355,  -222,
-     384,   384,   384,   840,  -222,  -222,   386,   358,  -222,   248,
-    -222,   165,  -222,    14,  -222,   165,  -222,   250,  -222,  -222,
-     255,   382,  -222,   466,  -222
+     367,  -223,  -223,   -29,   233,    -6,    18,    34,    35,  -223,
+     138,   233,   233,  -223,    94,   132,  -223,  -223,  -223,  -223,
+    -223,  -223,  -223,  -223,  -223,  -223,   -20,  -223,   111,   165,
+     233,  -223,  -223,    98,   233,   233,   233,   233,   233,  -223,
+    -223,   564,    72,    52,  -223,   185,   103,  -223,  -223,  -223,
+     118,  -223,  -223,  -223,  -223,    68,   231,   167,   125,   142,
+    -223,    76,  -223,  -223,   256,   260,  -223,  -223,  -223,   627,
+     139,  -223,   213,  -223,  -223,   160,  -223,  -223,   287,  -223,
+    -223,  -223,  -223,  -223,  -223,   179,   228,   753,   300,   241,
+     187,  -223,   234,    33,  -223,  -223,  -223,  -223,  -223,  -223,
+    -223,   816,   -16,   233,   233,   204,   233,   233,   199,   237,
+     205,   233,   233,   501,  -223,  -223,   206,   233,  -223,  -223,
+    -223,   501,    49,   -28,  -223,   302,  -223,   233,  -223,   329,
+    -223,    30,  -223,    17,   142,   753,  -223,  -223,   233,   753,
+    -223,  -223,  -223,  -223,   753,   260,  -223,   233,   415,    81,
+    -223,   330,  -223,   248,  -223,   153,  -223,   248,   233,    27,
+     233,   233,   226,  -223,   245,  -223,   161,   908,   690,   204,
+     501,   342,   344,  -223,  -223,  1016,   335,   879,   163,    16,
+     753,    -2,  -223,   753,  -223,   299,   246,   305,   249,  -223,
+      56,  -223,   102,    56,   -18,   306,  -223,  -223,    33,  -223,
+    -223,   250,   753,  -223,   269,   171,   233,  -223,   753,   252,
+    -223,   233,  -223,  -223,   255,   301,   303,   261,  -223,  -223,
+    -223,   121,   233,   267,    27,   233,  -223,    26,  -223,  -223,
+       7,    28,   501,   501,   254,  -223,  -223,  -223,  -223,  -223,
+    -223,  -223,  -223,   753,   753,    15,  -223,   173,   272,   753,
+      51,  -223,   327,   269,  -223,  -223,   753,  -223,   233,  -223,
+    -223,   -13,   309,   233,     5,   113,    17,  -223,   147,  -223,
+    -223,   381,   382,    56,   351,   321,  -223,   175,  -223,   753,
+    -223,   269,  -223,  -223,   501,   270,   271,   233,   389,    99,
+     189,  -223,   191,   368,    43,  -223,   275,   284,  -223,   318,
+     280,   879,  -223,   326,   233,  -223,  -223,    26,  -223,  -223,
+     344,  -223,  -223,  -223,   753,   224,   269,   322,  -223,  -223,
+     879,   285,   269,   753,  -223,    37,  -223,   233,   331,   233,
+     -19,   233,   332,   233,   333,  -223,  -223,   315,   320,  -223,
+     753,   501,   328,  -223,   269,     8,   233,   233,   193,  -223,
+    -223,  -223,  -223,  -223,  -223,  -223,   141,  -223,   233,  -223,
+    -223,  -223,   292,    27,   390,   337,  -223,   501,  -223,  -223,
+     294,  -223,   257,   753,  -223,  -223,   879,   269,  -223,    -8,
+     233,    -3,   501,    24,   233,    54,   233,  -223,  -223,   293,
+     342,   385,   348,  -223,   207,   210,  -223,   425,    99,  -223,
+     233,  -223,  -223,   310,   392,  -223,     9,   233,   753,   269,
+     216,   501,    59,   501,   342,   501,    79,   501,    80,   753,
+     426,  -223,   338,  -223,  -223,  -223,   221,  -223,  -223,  -223,
+    -223,     6,   233,   101,  -223,   312,   269,  -223,   342,   501,
+     342,   342,   501,   342,   501,   317,  -223,   188,  -223,   233,
+    -223,   233,  -223,  -223,   233,  -223,   235,  -223,  -223,   324,
+    -223,   342,   342,   342,   753,  -223,  -223,   355,   336,  -223,
+     238,  -223,   233,  -223,    22,  -223,   233,  -223,   240,  -223,
+    -223,   242,   352,  -223,   437,  -223
 };
 
   /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
@@ -924,82 +924,82 @@ static const yytype_int16 yypact[] =
      means the default is an error.  */
 static const yytype_uint8 yydefact[] =
 {
-       0,     6,   249,     0,     0,     0,     0,     0,     0,    18,
-     110,     0,     0,     7,     0,     0,    15,     8,    10,    11,
-      13,    14,     9,    17,    12,    16,     0,   103,     0,   247,
-       0,   241,   242,     0,     0,     0,     0,     0,     0,   111,
-     112,     0,     0,   105,   106,     0,   144,     1,     3,     2,
-       0,   104,     5,     4,   248,     0,     0,     0,     0,   165,
-      25,     0,   214,   211,     0,   233,   113,    40,    29,     0,
+       0,     6,   250,     0,     0,     0,     0,     0,     0,    18,
+     111,     0,     0,     7,     0,     0,    15,     8,    10,    11,
+      13,    14,     9,    17,    12,    16,     0,   104,     0,   248,
+       0,   242,   243,     0,     0,     0,     0,     0,     0,   112,
+     113,     0,     0,   106,   107,     0,   145,     1,     3,     2,
+       0,   105,     5,     4,   249,     0,     0,     0,     0,   166,
+      25,     0,   215,   212,     0,   234,   114,    40,    29,     0,
        0,    30,    31,    34,    36,     0,    37,    39,     0,    41,
-     210,    35,    38,    32,    33,     0,     0,     0,     0,     0,
-     114,   115,   119,   182,   184,   186,   189,   190,   191,   188,
-     187,     0,   219,     0,     0,     0,     0,     0,     0,     0,
-      92,     0,     0,     0,    99,   166,     0,     0,    89,   212,
-     213,     0,     0,   206,   203,     0,    43,     0,   215,     0,
-      44,     0,   216,     0,   165,     0,   234,   235,     0,     0,
-     118,   237,   238,   236,     0,     0,   185,     0,     0,   165,
-     101,     0,   107,     0,   108,     0,   239,     0,     0,     0,
-       0,     0,     0,    91,    66,    27,     0,     0,     0,     0,
-       0,   167,   169,   171,   173,     0,   187,     0,     0,     0,
-       0,   206,   200,     0,   204,     0,     0,     0,     0,   192,
-       0,   146,   121,   141,   134,   148,   116,   117,   181,   183,
-     220,     0,     0,   193,   208,     0,     0,    98,     0,     0,
-     145,     0,    90,    19,     0,     0,     0,     0,    20,    21,
-      22,     0,     0,     0,    64,     0,    42,    56,   172,   180,
-       0,     0,     0,     0,     0,   223,   225,   226,   227,   228,
-     224,   229,   231,     0,     0,     0,   217,     0,     0,     0,
-       0,   201,     0,   207,   199,    45,     0,    46,     0,   137,
-     142,     0,     0,     0,     0,     0,     0,   120,   122,   124,
-     140,     0,     0,   139,     0,   150,   194,     0,   195,     0,
-     100,   102,   133,   240,     0,     0,     0,     0,     0,     0,
-       0,   221,     0,   219,     0,    63,    65,    68,    28,     0,
-       0,     0,    47,     0,     0,    49,    55,    57,    26,   179,
-     168,   170,   230,   232,     0,     0,   178,     0,   177,    88,
-       0,     0,   205,     0,   198,     0,   143,     0,     0,     0,
-       0,     0,     0,     0,     0,   147,   123,     0,     0,   138,
-       0,     0,   152,   196,   209,     0,     0,     0,     0,    94,
-     245,   246,   244,   243,    95,    93,     0,    67,     0,    83,
-      84,    85,     0,     0,    70,    48,     0,    51,    50,     0,
-      54,     0,     0,   176,   218,     0,   202,   197,     0,     0,
-       0,     0,     0,     0,     0,     0,   135,   136,   149,   151,
-       0,   154,    61,     0,     0,    58,     0,     0,   222,     0,
-      24,    62,     0,     0,    23,     0,     0,     0,   174,     0,
-       0,     0,     0,   126,     0,     0,     0,     0,     0,     0,
-     109,     0,    59,    96,    97,     0,    74,    76,    77,    78,
-       0,     0,     0,    52,     0,   175,    87,   132,     0,   125,
-     128,     0,   130,     0,   153,   156,   159,   155,     0,    86,
-       0,    82,    80,     0,    79,     0,    72,    73,     0,    53,
-     131,   127,   129,     0,   160,   161,   162,     0,    75,     0,
-      69,     0,   157,     0,   158,     0,    81,     0,   163,   164,
-       0,     0,    60,     0,    71
+     211,    35,    38,    32,    33,     0,     0,     0,     0,     0,
+     115,   116,   120,   183,   185,   187,   190,   191,   192,   189,
+     188,     0,   220,     0,     0,     0,     0,     0,     0,     0,
+      93,     0,     0,     0,   100,   167,     0,     0,    90,   213,
+     214,     0,     0,   207,   204,     0,    43,     0,   216,     0,
+      44,     0,   217,     0,   166,     0,   235,   236,     0,     0,
+     119,   238,   239,   237,     0,     0,   186,     0,     0,   166,
+     102,     0,   108,     0,   109,     0,   240,     0,     0,     0,
+       0,     0,     0,    92,    66,    27,     0,     0,     0,     0,
+       0,   168,   170,   172,   174,     0,   188,     0,     0,     0,
+       0,   207,   201,     0,   205,     0,     0,     0,     0,   193,
+       0,   147,   122,   142,   135,   149,   117,   118,   182,   184,
+     221,     0,     0,   194,   209,     0,     0,    99,     0,     0,
+     146,     0,    91,    19,     0,     0,     0,     0,    20,    21,
+      22,     0,     0,     0,    64,     0,    42,    56,   173,   181,
+       0,     0,     0,     0,     0,   224,   226,   227,   228,   229,
+     225,   230,   232,     0,     0,     0,   218,     0,     0,     0,
+       0,   202,     0,   208,   200,    45,     0,    46,     0,   138,
+     143,     0,     0,     0,     0,     0,     0,   121,   123,   125,
+     141,     0,     0,   140,     0,   151,   195,     0,   196,     0,
+     101,   103,   134,   241,     0,     0,     0,     0,     0,     0,
+       0,   222,     0,   220,     0,    63,    65,    68,    28,     0,
+       0,     0,    47,     0,     0,    49,    55,    57,    26,   180,
+     169,   171,   231,   233,     0,     0,   179,     0,   178,    89,
+       0,     0,   206,     0,   199,     0,   144,     0,     0,     0,
+       0,     0,     0,     0,     0,   148,   124,     0,     0,   139,
+       0,     0,   153,   197,   210,     0,     0,     0,     0,    95,
+     246,   247,   245,   244,    96,    94,     0,    67,     0,    83,
+      84,    85,    86,     0,     0,    70,    48,     0,    51,    50,
+       0,    54,     0,     0,   177,   219,     0,   203,   198,     0,
+       0,     0,     0,     0,     0,     0,     0,   136,   137,   150,
+     152,     0,   155,    61,     0,     0,    58,     0,     0,   223,
+       0,    24,    62,     0,     0,    23,     0,     0,     0,   175,
+       0,     0,     0,     0,   127,     0,     0,     0,     0,     0,
+       0,   110,     0,    59,    97,    98,     0,    74,    76,    77,
+      78,     0,     0,     0,    52,     0,   176,    88,   133,     0,
+     126,   129,     0,   131,     0,   154,   157,   160,   156,     0,
+      87,     0,    82,    80,     0,    79,     0,    72,    73,     0,
+      53,   132,   128,   130,     0,   161,   162,   163,     0,    75,
+       0,    69,     0,   158,     0,   159,     0,    81,     0,   164,
+     165,     0,     0,    60,     0,    71
 };
 
   /* YYPGOTO[NTERM-NUM].  */
 static const yytype_int16 yypgoto[] =
 {
-    -222,  -222,  -222,  -222,  -222,  -222,  -222,  -222,  -130,  -222,
-     307,   170,  -222,  -222,  -221,  -222,  -222,  -222,  -222,  -222,
-    -222,    50,    32,  -222,  -222,  -222,  -222,  -222,  -222,  -222,
-    -222,  -222,  -222,  -222,  -222,   277,  -222,  -222,  -222,   381,
-     -20,  -222,  -222,  -222,   359,  -222,  -222,  -222,   216,   -82,
-    -222,   221,  -156,   -10,  -222,  -222,  -222,  -222,  -222,  -222,
-      23,  -222,  -222,    48,  -222,   -86,   258,   259,   323,   -21,
-     360,   367,   392,  -121,  -222,  -222,  -222,   314,  -222,   379,
-     317,  -198,  -176,   125,   -94,  -222,  -222,  -222,  -222,  -222,
-     -95,    -4,   106,  -222,  -222
+    -223,  -223,  -223,  -223,  -223,  -223,  -223,  -223,  -136,  -223,
+     286,   144,  -223,  -223,  -222,  -223,  -223,  -223,  -223,  -223,
+    -223,    20,     3,  -223,  -223,  -223,  -223,  -223,  -223,  -223,
+    -223,  -223,  -223,  -223,  -223,   251,  -223,  -223,  -223,   357,
+      -7,  -223,  -223,  -223,   339,  -223,  -223,  -223,   197,   -78,
+    -223,   201,  -156,    -9,  -223,  -223,  -223,  -223,  -223,  -223,
+      -5,  -223,  -223,    63,  -223,   -93,   239,   247,   307,   -21,
+     334,   340,   377,  -128,  -223,  -223,  -223,   311,  -223,   358,
+     313,  -198,  -168,   106,  -107,  -223,  -223,  -223,  -223,  -223,
+    -116,    -4,    88,  -223,  -223
 };
 
   /* YYDEFGOTO[NTERM-NUM].  */
 static const yytype_int16 yydefgoto[] =
 {
       -1,    14,    15,    16,    17,    18,    19,    20,   165,   166,
-      88,   306,   307,   308,   218,   296,   297,   223,   364,   404,
-     458,   425,   426,   427,   428,   429,   361,   400,    21,    22,
+      88,   306,   307,   308,   218,   296,   297,   223,   365,   405,
+     459,   426,   427,   428,   429,   430,   362,   401,    21,    22,
      163,   290,    23,    24,   149,   150,    25,    26,    43,    44,
       27,    41,    89,    90,    91,   134,   267,   268,   269,   190,
-     273,   191,   259,   260,   192,   275,   342,   391,   420,   444,
-     445,   466,   474,   114,   115,   171,   172,   173,   174,   175,
+     273,   191,   259,   260,   192,   275,   342,   392,   421,   445,
+     446,   467,   475,   114,   115,   171,   172,   173,   174,   175,
       93,    94,    95,    96,    97,    98,   181,   182,   123,   124,
      185,   205,    99,   247,   100,   292,   244,   101,   139,   144,
      155,   102,   354,    28,    29
@@ -1010,234 +1010,218 @@ static const yytype_int16 yydefgoto[] =
      number is the opposite.  If YYTABLE_NINF, syntax error.  */
 static const yytype_uint16 yytable[] =
 {
-      33,   246,    45,   295,   277,   232,    51,    42,    46,    31,
-     232,    32,   193,    31,   232,    32,   451,   317,   232,   176,
-      92,   147,   178,   154,   136,   137,    55,   176,   213,   183,
-      57,    58,    59,    60,    61,   179,   381,   270,   452,   141,
-     142,   118,   183,   410,   412,   136,   137,   108,   122,   234,
-     235,   236,   237,   238,   239,   240,   241,   242,   243,   414,
-     136,   137,   136,   137,   416,   271,   131,   438,   441,   443,
-     136,   137,    39,   211,   176,   109,   176,   478,   299,   372,
-     211,   211,   210,   211,   230,   121,    50,   229,   140,    34,
-     318,   136,   137,   479,    45,   298,   211,    40,   180,   151,
-      46,   211,   156,   157,   211,   211,   211,   164,   167,   249,
-     300,    36,    10,   156,    92,   148,   180,   339,   301,   309,
-      35,    47,   456,   187,   392,   367,   153,   204,   291,   194,
-     453,    38,   433,   209,   197,   214,   272,   212,   176,   176,
-     143,   401,   388,   200,   374,   193,   189,   457,   288,   231,
-     148,   302,   323,    30,   167,   289,   219,   220,   215,   250,
-     303,   189,   253,   377,   304,     1,    10,     2,   330,    31,
-     261,    32,   350,   136,   137,   262,   305,    31,   116,    32,
-     263,   204,   195,   264,   464,   216,    46,   281,   117,    46,
-     176,    48,   348,    49,     3,   351,   352,   207,   345,   246,
-     265,   217,   151,   113,   258,   465,    37,   283,    52,     4,
-       5,    53,   206,    54,   261,     6,   353,   407,   293,   262,
-       7,   167,   315,   316,   263,    56,   266,   264,   322,   136,
-     137,   327,   378,   396,   380,   325,   382,     8,   384,   331,
-     397,   103,   328,    31,   265,    32,   104,   176,   326,   105,
-     332,   393,   394,   106,    46,   389,   333,     9,   344,   156,
-     136,   137,   194,    10,   398,   158,   159,   334,   107,    46,
-     138,   110,   176,    11,   312,   313,   314,   160,   161,    12,
-     405,    13,   111,   156,   411,   224,   225,   176,   415,   112,
-     417,   248,   211,   371,   113,   413,   136,   137,   278,   279,
-     369,   119,   376,   234,   235,   236,   237,   238,   239,   240,
-     241,   242,   243,   120,   136,   137,   176,   128,   176,   204,
-     176,   125,   176,   156,   437,   156,   439,   156,   440,   156,
-     442,   319,   320,   343,   279,   355,   356,   357,   358,   359,
-     360,   127,   156,   156,   176,   395,   211,   176,   126,   176,
-     129,   408,   460,   130,   293,   461,   132,   462,   469,   421,
-     211,   133,   422,   211,   436,   320,   449,   450,   470,   450,
-     476,   211,   481,   211,   135,   156,   477,   482,   211,   156,
-     480,   156,   153,   162,   177,   186,   435,   188,   208,    10,
-     221,   222,   232,   245,   233,   430,   254,   446,   255,   256,
-     274,   257,   434,   276,   282,   284,   285,   286,   287,   294,
-     324,   321,   329,   337,   338,   340,   341,   346,    31,    62,
-      32,    63,   347,   349,   147,   363,   454,   430,   362,   366,
-     365,   368,   373,   379,   375,    64,    65,   201,   383,   385,
-     399,   386,   446,   402,   467,   387,   430,    67,    68,   156,
-     390,   406,   418,   403,    69,    70,   419,   279,   423,   432,
-     431,    71,    72,    73,   447,   448,   459,   156,   202,    74,
-     473,   156,   483,   484,   227,    75,   471,   370,    76,   475,
-     463,   455,   468,   280,   336,   152,   472,   335,    77,    78,
-     310,   228,   311,   146,   196,   251,    79,    80,   252,   198,
-     409,     0,   184,   424,    31,    62,    32,    63,     0,    81,
-     168,   199,     0,     0,     0,    82,     0,     0,    83,    84,
-       0,    64,    65,     0,     0,     0,    85,     0,     0,     0,
-      86,     0,     0,    67,    68,    87,   203,     0,     0,     0,
-      69,    70,     0,     0,     0,     0,     0,    71,    72,    73,
-       0,     0,     0,     0,     0,    74,     0,     0,     0,     0,
-     169,    75,     0,     0,    76,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,    77,    78,     0,     0,     0,     0,
-       0,     0,    79,    80,     0,     0,     0,     0,     0,    31,
-      62,    32,    63,     0,     0,    81,     0,     0,     0,     0,
-       0,    82,     0,     0,    83,    84,    64,    65,    66,     0,
-       0,     0,    85,     0,     0,     0,    86,     0,    67,    68,
-       0,   170,     0,     0,     0,    69,    70,     0,     0,     0,
-       0,     0,    71,    72,    73,     0,     0,     0,     0,     0,
-      74,     0,     0,     0,     0,     0,    75,     0,     0,    76,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,    77,
-      78,     0,     0,     0,     0,     0,     0,    79,    80,     0,
-       0,     0,     0,     0,    31,    62,    32,    63,     0,     0,
-      81,     0,     0,     0,     0,     0,    82,     0,     0,    83,
-      84,    64,    65,     0,     0,     0,     0,    85,     0,     0,
-       0,    86,     0,    67,    68,     0,    87,     0,     0,     0,
-      69,    70,     0,     0,     0,     0,     0,    71,    72,    73,
-       0,     0,     0,     0,     0,    74,     0,     0,     0,     0,
-       0,    75,     0,     0,    76,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,    77,    78,     0,     0,     0,     0,
-       0,     0,    79,    80,     0,     0,     0,     0,     0,    31,
-      62,    32,    63,     0,     0,    81,     0,     0,     0,     0,
-       0,    82,     0,     0,    83,    84,    64,    65,     0,     0,
-       0,     0,    85,   121,     0,     0,    86,     0,    67,    68,
-       0,    87,     0,     0,     0,    69,    70,     0,     0,     0,
-       0,     0,    71,    72,    73,     0,     0,     0,     0,     0,
-      74,     0,     0,     0,     0,   169,    75,     0,     0,    76,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,    77,
-      78,     0,     0,     0,     0,     0,     0,    79,    80,     0,
-       0,     0,     0,     0,    31,    62,    32,    63,     0,     0,
-      81,     0,     0,     0,     0,     0,    82,     0,     0,    83,
-      84,    64,    65,     0,     0,     0,     0,    85,     0,     0,
-       0,    86,     0,    67,    68,     0,   170,     0,     0,     0,
-      69,    70,     0,     0,     0,     0,     0,    71,    72,    73,
-       0,     0,     0,     0,     0,    74,     0,     0,     0,     0,
-       0,    75,     0,     0,    76,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,    77,    78,     0,     0,     0,     0,
-       0,     0,    79,    80,     0,     0,     0,     0,     0,    31,
-      62,    32,    63,     0,     0,    81,     0,     0,     0,     0,
-       0,    82,     0,     0,    83,    84,    64,   145,     0,     0,
-       0,     0,    85,     0,     0,     0,    86,     0,    67,    68,
-       0,    87,    62,     0,    63,    69,    70,     0,     0,     0,
-       0,     0,    71,    72,    73,     0,     0,     0,    64,   145,
-      74,     0,     0,     0,     0,     0,    75,     0,     0,    76,
-      67,    68,     0,     0,     0,     0,     0,     0,    70,    77,
-      78,     0,     0,     0,    71,    72,    73,    79,    80,     0,
-       0,     0,    74,     0,     0,     0,     0,     0,     0,     0,
-      81,    76,     0,     0,     0,     0,    82,     0,     0,    83,
-      84,    77,    78,     0,    67,    68,     0,    85,     0,    79,
-      80,    86,    70,     0,     0,     0,    87,     0,    71,    72,
-      73,     0,    81,     0,     0,     0,    74,     0,    82,     0,
-       0,    83,    84,     0,     0,    76,     0,     0,     0,    85,
-       0,     0,     0,    86,     0,    77,   226,     0,     0,     0,
-       0,     0,     0,    79,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,    81,     0,     0,     0,
-       0,     0,    82,     0,     0,    83,    84,     0,     0,     0,
-       0,     0,     0,    85,     0,     0,     0,    86
+      33,   178,   295,    45,   277,   193,   176,    42,    46,   246,
+      31,   147,    32,   452,   176,   232,   232,   232,   271,    51,
+      92,    31,   213,    32,   232,   317,    55,   154,   179,   183,
+      57,    58,    59,    60,    61,   453,   299,   270,   234,   235,
+     236,   237,   238,   239,   240,   241,   242,   243,   122,   136,
+     137,   136,   137,    50,   118,   183,   141,   142,   136,   137,
+      31,   176,    32,   176,   327,    34,   131,   382,   300,   214,
+     136,   137,   136,   137,    30,   328,   301,   230,   411,    10,
+     359,   360,   331,   413,    36,   479,   121,   258,   140,   298,
+     272,   229,   215,   332,    47,    45,   108,    35,   318,   151,
+      46,   480,   156,   157,   148,   211,   148,   164,   167,   302,
+     415,    38,   180,   156,    92,   291,   211,   339,   303,   216,
+     249,   211,   304,   187,   109,   176,   176,   204,   454,   194,
+     309,   393,   434,   368,   197,   305,   217,    37,   193,   153,
+     417,   402,   389,   200,   361,   439,   209,   330,   211,   231,
+     212,   189,   375,   189,   167,   323,   219,   220,   143,   250,
+     378,   350,   253,   180,    56,   442,   444,    39,    54,   261,
+     457,   348,   103,   288,   262,    10,   104,   176,   211,   263,
+     289,   204,   264,   211,   351,   352,    46,   281,   116,    46,
+     333,   345,    40,   397,   107,   458,   113,   195,   117,   265,
+     398,   334,   151,   211,   211,   206,   353,   283,   246,   136,
+     137,   379,   207,   381,   261,   383,   105,   385,   293,   262,
+     465,   167,   315,   316,   263,   106,   266,   264,   322,    52,
+     394,   395,    53,   373,   176,   325,   110,    31,    31,    32,
+      32,   466,   158,   159,   265,   136,   137,   112,   390,   326,
+      48,   399,    49,   111,    46,   136,   137,   113,   344,   156,
+     176,   125,   194,   119,   412,   138,   408,   120,   416,    46,
+     418,   312,   313,   314,   406,   176,   210,   211,   136,   137,
+     160,   161,   127,   156,   224,   225,   248,   211,   126,   414,
+     136,   137,   128,   372,   278,   279,   319,   320,   343,   279,
+     370,   129,   377,   130,   176,   132,   176,   133,   176,   186,
+     176,   135,   355,   356,   357,   358,   396,   211,   438,   204,
+     440,   162,   441,   156,   443,   156,   153,   156,   177,   156,
+     422,   211,   176,   423,   211,   176,   188,   176,   470,   437,
+     320,   208,   156,   156,   450,   451,   461,    10,   221,   462,
+     232,   463,   409,   233,   293,   245,   478,   254,   471,   451,
+     481,   477,   211,   482,   211,   483,   211,   222,     1,   255,
+       2,   256,   257,   276,   274,   282,   156,   284,   294,   285,
+     156,   286,   156,   287,   321,   324,   329,   436,   337,   338,
+     340,   341,   346,   347,   349,   147,   431,     3,   447,   363,
+     364,   366,   367,   435,   369,   374,   387,   376,   380,   384,
+     386,   388,     4,     5,   400,   391,   407,   279,     6,    31,
+      62,    32,    63,     7,   419,   403,   404,   455,   431,   420,
+     424,   433,   432,   448,   449,   460,    64,    65,   201,   474,
+       8,   464,   484,   447,   485,   468,   472,   431,    67,    68,
+     156,   371,   456,   227,   469,    69,    70,   280,   476,   473,
+       9,   152,    71,    72,    73,   336,    10,   335,   156,   202,
+      74,   310,   156,   198,   196,   228,    75,    11,   146,    76,
+     311,   184,   410,    12,   199,    13,   425,     0,     0,    77,
+      78,     0,   251,     0,   252,     0,     0,    79,    80,     0,
+       0,     0,     0,     0,     0,    31,    62,    32,    63,     0,
+      81,   168,     0,     0,     0,     0,     0,    82,     0,     0,
+      83,    84,    64,    65,     0,     0,     0,     0,    85,     0,
+       0,     0,    86,     0,    67,    68,     0,    87,   203,     0,
+       0,    69,    70,     0,     0,     0,     0,     0,    71,    72,
+      73,     0,     0,     0,     0,     0,    74,     0,     0,     0,
+       0,   169,    75,     0,     0,    76,     0,     0,    31,    62,
+      32,    63,     0,     0,     0,    77,    78,     0,     0,     0,
+       0,     0,     0,    79,    80,    64,    65,    66,     0,     0,
+       0,     0,     0,     0,     0,     0,    81,    67,    68,     0,
+       0,     0,     0,    82,    69,    70,    83,    84,     0,     0,
+       0,    71,    72,    73,    85,     0,     0,     0,    86,    74,
+       0,     0,     0,   170,     0,    75,     0,     0,    76,     0,
+       0,    31,    62,    32,    63,     0,     0,     0,    77,    78,
+       0,     0,     0,     0,     0,     0,    79,    80,    64,    65,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,    81,
+      67,    68,     0,     0,     0,     0,    82,    69,    70,    83,
+      84,     0,     0,     0,    71,    72,    73,    85,     0,     0,
+       0,    86,    74,     0,     0,     0,    87,     0,    75,     0,
+       0,    76,     0,     0,    31,    62,    32,    63,     0,     0,
+       0,    77,    78,     0,     0,     0,     0,     0,     0,    79,
+      80,    64,    65,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,    81,    67,    68,     0,     0,     0,     0,    82,
+      69,    70,    83,    84,     0,     0,     0,    71,    72,    73,
+      85,   121,     0,     0,    86,    74,     0,     0,     0,    87,
+     169,    75,     0,     0,    76,     0,     0,    31,    62,    32,
+      63,     0,     0,     0,    77,    78,     0,     0,     0,     0,
+       0,     0,    79,    80,    64,    65,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,    81,    67,    68,     0,     0,
+       0,     0,    82,    69,    70,    83,    84,     0,     0,     0,
+      71,    72,    73,    85,     0,     0,     0,    86,    74,     0,
+       0,     0,   170,     0,    75,     0,     0,    76,     0,     0,
+      31,    62,    32,    63,     0,     0,     0,    77,    78,     0,
+       0,     0,     0,     0,     0,    79,    80,    64,   145,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,    81,    67,
+      68,     0,     0,     0,     0,    82,    69,    70,    83,    84,
+       0,     0,     0,    71,    72,    73,    85,     0,     0,     0,
+      86,    74,     0,     0,     0,    87,     0,    75,     0,     0,
+      76,     0,     0,     0,    62,     0,    63,     0,     0,     0,
+      77,    78,     0,     0,     0,     0,     0,     0,    79,    80,
+      64,   145,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,    81,    67,    68,     0,     0,     0,     0,    82,     0,
+      70,    83,    84,     0,     0,     0,    71,    72,    73,    85,
+       0,     0,     0,    86,    74,     0,     0,     0,    87,     0,
+       0,    67,    68,    76,     0,     0,     0,     0,     0,    70,
+       0,     0,     0,    77,    78,    71,    72,    73,     0,     0,
+       0,    79,    80,    74,     0,     0,     0,     0,     0,     0,
+       0,     0,    76,     0,    81,     0,     0,     0,     0,     0,
+       0,    82,    77,   226,    83,    84,     0,     0,     0,     0,
+      79,     0,    85,     0,     0,     0,    86,     0,     0,     0,
+       0,     0,     0,    81,     0,     0,     0,     0,     0,     0,
+      82,     0,     0,    83,    84,     0,     0,     0,     0,     0,
+       0,    85,     0,     0,     0,    86,   234,   235,   236,   237,
+     238,   239,   240,   241,   242,   243,     0,   136,   137
 };
 
 static const yytype_int16 yycheck[] =
 {
-       4,   177,    12,   224,   202,     8,    26,    11,    12,     4,
-       8,     6,   133,     4,     8,     6,     7,    10,     8,   113,
-      41,    27,   117,   105,    21,    22,    30,   121,   158,    57,
-      34,    35,    36,    37,    38,   121,    86,   193,    29,    23,
-      24,    61,    57,    86,    86,    21,    22,    28,    69,    10,
-      11,    12,    13,    14,    15,    16,    17,    18,    19,    86,
-      21,    22,    21,    22,    86,    36,    87,    86,    86,    86,
-      21,    22,    29,   123,   168,    56,   170,    63,    10,     9,
-     123,   123,   122,   123,   170,   113,    73,   169,    92,    71,
-      83,    21,    22,    79,   104,   225,   123,    54,   113,   103,
-     104,   123,   106,   107,   123,   123,   123,   111,   112,   103,
-      42,    66,    99,   117,   135,   121,   113,   273,    50,   122,
-     102,     0,    69,   127,   122,   301,   121,   148,   222,   133,
-     121,    76,   122,   153,   138,    42,   107,   157,   232,   233,
-     124,   362,   340,   147,   320,   266,   122,    94,    52,   170,
-     121,    83,   103,   102,   158,    59,   160,   161,    65,   180,
-      92,   122,   183,   122,    96,     1,    99,     3,   263,     4,
-      67,     6,    62,    21,    22,    72,   108,     4,   111,     6,
-      77,   202,   134,    80,    32,    92,   190,   208,   121,   193,
-     284,   117,   287,   119,    30,    85,    86,   149,   284,   375,
-      97,   108,   206,   114,    31,    53,   102,   211,   117,    45,
-      46,   120,   123,     3,    67,    51,   106,     9,   222,    72,
-      56,   225,   243,   244,    77,    66,   123,    80,   249,    21,
-      22,    77,   327,    52,   329,   256,   331,    73,   333,    77,
-      59,   100,    88,     4,    97,     6,   123,   341,   258,    31,
-      88,   346,   347,   121,   258,   341,    77,    93,   279,   263,
-      21,    22,   266,    99,   358,    43,    44,    88,    76,   273,
-      31,     5,   366,   109,    17,    18,    19,    43,    44,   115,
-     366,   117,    86,   287,   379,   122,   123,   381,   383,   121,
-     385,   122,   123,   314,   114,   381,    21,    22,   122,   123,
-     304,     7,   323,    10,    11,    12,    13,    14,    15,    16,
-      17,    18,    19,     7,    21,    22,   410,     5,   412,   340,
-     414,   121,   416,   327,   410,   329,   412,   331,   414,   333,
-     416,   122,   123,   122,   123,   122,   123,   122,   123,    37,
-      38,   121,   346,   347,   438,   122,   123,   441,    75,   443,
-     121,   372,   438,    75,   358,   441,     5,   443,   453,   122,
-     123,    66,   122,   123,   122,   123,   122,   123,   122,   123,
-     122,   123,   122,   123,   123,   379,   471,   122,   123,   383,
-     475,   385,   121,   115,   121,     7,   407,     7,    11,    99,
-     121,   121,     8,    20,     9,   399,    58,   418,   122,    66,
-      68,   122,   406,   122,   122,   121,    78,    78,   121,   110,
-      58,   111,    77,     7,     7,    39,    70,   121,     4,     5,
-       6,     7,   121,     5,    27,   115,   430,   431,   123,   121,
-      83,    78,    83,    77,   121,    21,    22,    23,    77,    77,
-     121,    91,   463,    35,   448,    91,   450,    33,    34,   453,
-      87,   121,    39,    89,    40,    41,    81,   123,     5,    39,
-     121,    47,    48,    49,     7,    96,   122,   471,    54,    55,
-      84,   475,    90,     7,   167,    61,   121,   307,    64,   121,
-     123,   431,   450,   206,   268,   104,   463,   266,    74,    75,
-     232,   168,   233,   101,   135,   181,    82,    83,   181,   139,
-     375,    -1,   123,   397,     4,     5,     6,     7,    -1,    95,
-      10,   144,    -1,    -1,    -1,   101,    -1,    -1,   104,   105,
-      -1,    21,    22,    -1,    -1,    -1,   112,    -1,    -1,    -1,
-     116,    -1,    -1,    33,    34,   121,   122,    -1,    -1,    -1,
-      40,    41,    -1,    -1,    -1,    -1,    -1,    47,    48,    49,
-      -1,    -1,    -1,    -1,    -1,    55,    -1,    -1,    -1,    -1,
-      60,    61,    -1,    -1,    64,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    74,    75,    -1,    -1,    -1,    -1,
-      -1,    -1,    82,    83,    -1,    -1,    -1,    -1,    -1,     4,
-       5,     6,     7,    -1,    -1,    95,    -1,    -1,    -1,    -1,
-      -1,   101,    -1,    -1,   104,   105,    21,    22,    23,    -1,
-      -1,    -1,   112,    -1,    -1,    -1,   116,    -1,    33,    34,
-      -1,   121,    -1,    -1,    -1,    40,    41,    -1,    -1,    -1,
-      -1,    -1,    47,    48,    49,    -1,    -1,    -1,    -1,    -1,
-      55,    -1,    -1,    -1,    -1,    -1,    61,    -1,    -1,    64,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    74,
-      75,    -1,    -1,    -1,    -1,    -1,    -1,    82,    83,    -1,
-      -1,    -1,    -1,    -1,     4,     5,     6,     7,    -1,    -1,
-      95,    -1,    -1,    -1,    -1,    -1,   101,    -1,    -1,   104,
-     105,    21,    22,    -1,    -1,    -1,    -1,   112,    -1,    -1,
-      -1,   116,    -1,    33,    34,    -1,   121,    -1,    -1,    -1,
-      40,    41,    -1,    -1,    -1,    -1,    -1,    47,    48,    49,
-      -1,    -1,    -1,    -1,    -1,    55,    -1,    -1,    -1,    -1,
-      -1,    61,    -1,    -1,    64,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    74,    75,    -1,    -1,    -1,    -1,
-      -1,    -1,    82,    83,    -1,    -1,    -1,    -1,    -1,     4,
-       5,     6,     7,    -1,    -1,    95,    -1,    -1,    -1,    -1,
-      -1,   101,    -1,    -1,   104,   105,    21,    22,    -1,    -1,
-      -1,    -1,   112,   113,    -1,    -1,   116,    -1,    33,    34,
-      -1,   121,    -1,    -1,    -1,    40,    41,    -1,    -1,    -1,
-      -1,    -1,    47,    48,    49,    -1,    -1,    -1,    -1,    -1,
-      55,    -1,    -1,    -1,    -1,    60,    61,    -1,    -1,    64,
-      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    74,
-      75,    -1,    -1,    -1,    -1,    -1,    -1,    82,    83,    -1,
-      -1,    -1,    -1,    -1,     4,     5,     6,     7,    -1,    -1,
-      95,    -1,    -1,    -1,    -1,    -1,   101,    -1,    -1,   104,
-     105,    21,    22,    -1,    -1,    -1,    -1,   112,    -1,    -1,
-      -1,   116,    -1,    33,    34,    -1,   121,    -1,    -1,    -1,
-      40,    41,    -1,    -1,    -1,    -1,    -1,    47,    48,    49,
-      -1,    -1,    -1,    -1,    -1,    55,    -1,    -1,    -1,    -1,
-      -1,    61,    -1,    -1,    64,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    74,    75,    -1,    -1,    -1,    -1,
-      -1,    -1,    82,    83,    -1,    -1,    -1,    -1,    -1,     4,
-       5,     6,     7,    -1,    -1,    95,    -1,    -1,    -1,    -1,
-      -1,   101,    -1,    -1,   104,   105,    21,    22,    -1,    -1,
-      -1,    -1,   112,    -1,    -1,    -1,   116,    -1,    33,    34,
-      -1,   121,     5,    -1,     7,    40,    41,    -1,    -1,    -1,
-      -1,    -1,    47,    48,    49,    -1,    -1,    -1,    21,    22,
-      55,    -1,    -1,    -1,    -1,    -1,    61,    -1,    -1,    64,
-      33,    34,    -1,    -1,    -1,    -1,    -1,    -1,    41,    74,
-      75,    -1,    -1,    -1,    47,    48,    49,    82,    83,    -1,
-      -1,    -1,    55,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
-      95,    64,    -1,    -1,    -1,    -1,   101,    -1,    -1,   104,
-     105,    74,    75,    -1,    33,    34,    -1,   112,    -1,    82,
-      83,   116,    41,    -1,    -1,    -1,   121,    -1,    47,    48,
-      49,    -1,    95,    -1,    -1,    -1,    55,    -1,   101,    -1,
-      -1,   104,   105,    -1,    -1,    64,    -1,    -1,    -1,   112,
-      -1,    -1,    -1,   116,    -1,    74,    75,    -1,    -1,    -1,
-      -1,    -1,    -1,    82,    -1,    -1,    -1,    -1,    -1,    -1,
-      -1,    -1,    -1,    -1,    -1,    -1,    95,    -1,    -1,    -1,
-      -1,    -1,   101,    -1,    -1,   104,   105,    -1,    -1,    -1,
-      -1,    -1,    -1,   112,    -1,    -1,    -1,   116
+       4,   117,   224,    12,   202,   133,   113,    11,    12,   177,
+       4,    27,     6,     7,   121,     8,     8,     8,    36,    26,
+      41,     4,   158,     6,     8,    10,    30,   105,   121,    57,
+      34,    35,    36,    37,    38,    29,    10,   193,    10,    11,
+      12,    13,    14,    15,    16,    17,    18,    19,    69,    21,
+      22,    21,    22,    73,    61,    57,    23,    24,    21,    22,
+       4,   168,     6,   170,    77,    71,    87,    86,    42,    42,
+      21,    22,    21,    22,   103,    88,    50,   170,    86,    99,
+      37,    38,    77,    86,    66,    63,   114,    31,    92,   225,
+     108,   169,    65,    88,     0,   104,    28,   103,    83,   103,
+     104,    79,   106,   107,   122,   124,   122,   111,   112,    83,
+      86,    76,   114,   117,   135,   222,   124,   273,    92,    92,
+     104,   124,    96,   127,    56,   232,   233,   148,   122,   133,
+     123,   123,   123,   301,   138,   109,   109,   103,   266,   122,
+      86,   363,   340,   147,   101,    86,   153,   263,   124,   170,
+     157,   123,   320,   123,   158,   104,   160,   161,   125,   180,
+     123,    62,   183,   114,    66,    86,    86,    29,     3,    67,
+      69,   287,   100,    52,    72,    99,   124,   284,   124,    77,
+      59,   202,    80,   124,    85,    86,   190,   208,   112,   193,
+      77,   284,    54,    52,    76,    94,   115,   134,   122,    97,
+      59,    88,   206,   124,   124,   124,   107,   211,   376,    21,
+      22,   327,   149,   329,    67,   331,    31,   333,   222,    72,
+      32,   225,   243,   244,    77,   122,   124,    80,   249,   118,
+     346,   347,   121,     9,   341,   256,     5,     4,     4,     6,
+       6,    53,    43,    44,    97,    21,    22,   122,   341,   258,
+     118,   358,   120,    86,   258,    21,    22,   115,   279,   263,
+     367,   122,   266,     7,   380,    31,     9,     7,   384,   273,
+     386,    17,    18,    19,   367,   382,   123,   124,    21,    22,
+      43,    44,   122,   287,   123,   124,   123,   124,    75,   382,
+      21,    22,     5,   314,   123,   124,   123,   124,   123,   124,
+     304,   122,   323,    75,   411,     5,   413,    66,   415,     7,
+     417,   124,   123,   124,   123,   124,   123,   124,   411,   340,
+     413,   116,   415,   327,   417,   329,   122,   331,   122,   333,
+     123,   124,   439,   123,   124,   442,     7,   444,   454,   123,
+     124,    11,   346,   347,   123,   124,   439,    99,   122,   442,
+       8,   444,   373,     9,   358,    20,   472,    58,   123,   124,
+     476,   123,   124,   123,   124,   123,   124,   122,     1,   123,
+       3,    66,   123,   123,    68,   123,   380,   122,   111,    78,
+     384,    78,   386,   122,   112,    58,    77,   408,     7,     7,
+      39,    70,   122,   122,     5,    27,   400,    30,   419,   124,
+     116,    83,   122,   407,    78,    83,    91,   122,    77,    77,
+      77,    91,    45,    46,   122,    87,   122,   124,    51,     4,
+       5,     6,     7,    56,    39,    35,    89,   431,   432,    81,
+       5,    39,   122,     7,    96,   123,    21,    22,    23,    84,
+      73,   124,    90,   464,     7,   449,   122,   451,    33,    34,
+     454,   307,   432,   167,   451,    40,    41,   206,   122,   464,
+      93,   104,    47,    48,    49,   268,    99,   266,   472,    54,
+      55,   232,   476,   139,   135,   168,    61,   110,   101,    64,
+     233,   123,   376,   116,   144,   118,   398,    -1,    -1,    74,
+      75,    -1,   181,    -1,   181,    -1,    -1,    82,    83,    -1,
+      -1,    -1,    -1,    -1,    -1,     4,     5,     6,     7,    -1,
+      95,    10,    -1,    -1,    -1,    -1,    -1,   102,    -1,    -1,
+     105,   106,    21,    22,    -1,    -1,    -1,    -1,   113,    -1,
+      -1,    -1,   117,    -1,    33,    34,    -1,   122,   123,    -1,
+      -1,    40,    41,    -1,    -1,    -1,    -1,    -1,    47,    48,
+      49,    -1,    -1,    -1,    -1,    -1,    55,    -1,    -1,    -1,
+      -1,    60,    61,    -1,    -1,    64,    -1,    -1,     4,     5,
+       6,     7,    -1,    -1,    -1,    74,    75,    -1,    -1,    -1,
+      -1,    -1,    -1,    82,    83,    21,    22,    23,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    95,    33,    34,    -1,
+      -1,    -1,    -1,   102,    40,    41,   105,   106,    -1,    -1,
+      -1,    47,    48,    49,   113,    -1,    -1,    -1,   117,    55,
+      -1,    -1,    -1,   122,    -1,    61,    -1,    -1,    64,    -1,
+      -1,     4,     5,     6,     7,    -1,    -1,    -1,    74,    75,
+      -1,    -1,    -1,    -1,    -1,    -1,    82,    83,    21,    22,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    95,
+      33,    34,    -1,    -1,    -1,    -1,   102,    40,    41,   105,
+     106,    -1,    -1,    -1,    47,    48,    49,   113,    -1,    -1,
+      -1,   117,    55,    -1,    -1,    -1,   122,    -1,    61,    -1,
+      -1,    64,    -1,    -1,     4,     5,     6,     7,    -1,    -1,
+      -1,    74,    75,    -1,    -1,    -1,    -1,    -1,    -1,    82,
+      83,    21,    22,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    95,    33,    34,    -1,    -1,    -1,    -1,   102,
+      40,    41,   105,   106,    -1,    -1,    -1,    47,    48,    49,
+     113,   114,    -1,    -1,   117,    55,    -1,    -1,    -1,   122,
+      60,    61,    -1,    -1,    64,    -1,    -1,     4,     5,     6,
+       7,    -1,    -1,    -1,    74,    75,    -1,    -1,    -1,    -1,
+      -1,    -1,    82,    83,    21,    22,    -1,    -1,    -1,    -1,
+      -1,    -1,    -1,    -1,    -1,    95,    33,    34,    -1,    -1,
+      -1,    -1,   102,    40,    41,   105,   106,    -1,    -1,    -1,
+      47,    48,    49,   113,    -1,    -1,    -1,   117,    55,    -1,
+      -1,    -1,   122,    -1,    61,    -1,    -1,    64,    -1,    -1,
+       4,     5,     6,     7,    -1,    -1,    -1,    74,    75,    -1,
+      -1,    -1,    -1,    -1,    -1,    82,    83,    21,    22,    -1,
+      -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    95,    33,
+      34,    -1,    -1,    -1,    -1,   102,    40,    41,   105,   106,
+      -1,    -1,    -1,    47,    48,    49,   113,    -1,    -1,    -1,
+     117,    55,    -1,    -1,    -1,   122,    -1,    61,    -1,    -1,
+      64,    -1,    -1,    -1,     5,    -1,     7,    -1,    -1,    -1,
+      74,    75,    -1,    -1,    -1,    -1,    -1,    -1,    82,    83,
+      21,    22,    -1,    -1,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    95,    33,    34,    -1,    -1,    -1,    -1,   102,    -1,
+      41,   105,   106,    -1,    -1,    -1,    47,    48,    49,   113,
+      -1,    -1,    -1,   117,    55,    -1,    -1,    -1,   122,    -1,
+      -1,    33,    34,    64,    -1,    -1,    -1,    -1,    -1,    41,
+      -1,    -1,    -1,    74,    75,    47,    48,    49,    -1,    -1,
+      -1,    82,    83,    55,    -1,    -1,    -1,    -1,    -1,    -1,
+      -1,    -1,    64,    -1,    95,    -1,    -1,    -1,    -1,    -1,
+      -1,   102,    74,    75,   105,   106,    -1,    -1,    -1,    -1,
+      82,    -1,   113,    -1,    -1,    -1,   117,    -1,    -1,    -1,
+      -1,    -1,    -1,    95,    -1,    -1,    -1,    -1,    -1,    -1,
+     102,    -1,    -1,   105,   106,    -1,    -1,    -1,    -1,    -1,
+      -1,   113,    -1,    -1,    -1,   117,    10,    11,    12,    13,
+      14,    15,    16,    17,    18,    19,    -1,    21,    22
 };
 
   /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
@@ -1245,84 +1229,85 @@ static const yytype_int16 yycheck[] =
 static const yytype_uint8 yystos[] =
 {
        0,     1,     3,    30,    45,    46,    51,    56,    73,    93,
-      99,   109,   115,   117,   126,   127,   128,   129,   130,   131,
-     132,   153,   154,   157,   158,   161,   162,   165,   218,   219,
-     102,     4,     6,   216,    71,   102,    66,   102,    76,    29,
-      54,   166,   216,   163,   164,   178,   216,     0,   117,   119,
-      73,   165,   117,   120,     3,   216,    66,   216,   216,   216,
-     216,   216,     5,     7,    21,    22,    23,    33,    34,    40,
+      99,   110,   116,   118,   127,   128,   129,   130,   131,   132,
+     133,   154,   155,   158,   159,   162,   163,   166,   219,   220,
+     103,     4,     6,   217,    71,   103,    66,   103,    76,    29,
+      54,   167,   217,   164,   165,   179,   217,     0,   118,   120,
+      73,   166,   118,   121,     3,   217,    66,   217,   217,   217,
+     217,   217,     5,     7,    21,    22,    23,    33,    34,    40,
       41,    47,    48,    49,    55,    61,    64,    74,    75,    82,
-      83,    95,   101,   104,   105,   112,   116,   121,   135,   167,
-     168,   169,   194,   195,   196,   197,   198,   199,   200,   207,
-     209,   212,   216,   100,   123,    31,   121,    76,    28,    56,
-       5,    86,   121,   114,   188,   189,   111,   121,   165,     7,
-       7,   113,   194,   203,   204,   121,    75,   121,     5,   121,
-      75,   194,     5,    66,   170,   123,    21,    22,    31,   213,
-     216,    23,    24,   124,   214,    22,   197,    27,   121,   159,
-     160,   216,   164,   121,   174,   215,   216,   216,    43,    44,
-      43,    44,   115,   155,   216,   133,   134,   216,    10,    60,
-     121,   190,   191,   192,   193,   194,   209,   121,   215,   190,
-     113,   201,   202,    57,   204,   205,     7,   216,     7,   122,
-     174,   176,   179,   198,   216,   188,   169,   216,   195,   196,
-     216,    23,    54,   122,   194,   206,   123,   188,    11,   165,
-     122,   123,   165,   133,    42,    65,    92,   108,   139,   216,
-     216,   121,   121,   142,   122,   123,    75,   135,   193,   174,
-     190,   194,     8,     9,    10,    11,    12,    13,    14,    15,
-      16,    17,    18,    19,   211,    20,   207,   208,   122,   103,
-     194,   202,   205,   194,    58,   122,    66,   122,    31,   177,
-     178,    67,    72,    77,    80,    97,   123,   171,   172,   173,
-     177,    36,   107,   175,    68,   180,   122,   206,   122,   123,
-     160,   194,   122,   216,   121,    78,    78,   121,    52,    59,
-     156,   209,   210,   216,   110,   139,   140,   141,   133,    10,
-      42,    50,    83,    92,    96,   108,   136,   137,   138,   122,
-     191,   192,    17,    18,    19,   194,   194,    10,    83,   122,
-     123,   111,   194,   103,    58,   194,   178,    77,    88,    77,
-     215,    77,    88,    77,    88,   176,   173,     7,     7,   177,
-      39,    70,   181,   122,   194,   190,   121,   121,   215,     5,
-      62,    85,    86,   106,   217,   122,   123,   122,   123,    37,
-      38,   151,   123,   115,   143,    83,   121,   207,    78,   216,
-     136,   194,     9,    83,   207,   121,   194,   122,   215,    77,
-     215,    86,   215,    77,   215,    77,    91,    91,   206,   190,
-      87,   182,   122,   215,   215,   122,    52,    59,   209,   121,
-     152,   139,    35,    89,   144,   190,   121,     9,   194,   208,
-      86,   215,    86,   190,    86,   215,    86,   215,    39,    81,
-     183,   122,   122,     5,   217,   146,   147,   148,   149,   150,
-     216,   121,    39,   122,   216,   194,   122,   190,    86,   190,
-     190,    86,   190,    86,   184,   185,   194,     7,    96,   122,
-     123,     7,    29,   121,   216,   146,    69,    94,   145,   122,
-     190,   190,   190,   123,    32,    53,   186,   216,   147,   215,
-     122,   121,   185,    84,   187,   121,   122,   215,    63,    79,
-     215,   122,   122,    90,     7
+      83,    95,   102,   105,   106,   113,   117,   122,   136,   168,
+     169,   170,   195,   196,   197,   198,   199,   200,   201,   208,
+     210,   213,   217,   100,   124,    31,   122,    76,    28,    56,
+       5,    86,   122,   115,   189,   190,   112,   122,   166,     7,
+       7,   114,   195,   204,   205,   122,    75,   122,     5,   122,
+      75,   195,     5,    66,   171,   124,    21,    22,    31,   214,
+     217,    23,    24,   125,   215,    22,   198,    27,   122,   160,
+     161,   217,   165,   122,   175,   216,   217,   217,    43,    44,
+      43,    44,   116,   156,   217,   134,   135,   217,    10,    60,
+     122,   191,   192,   193,   194,   195,   210,   122,   216,   191,
+     114,   202,   203,    57,   205,   206,     7,   217,     7,   123,
+     175,   177,   180,   199,   217,   189,   170,   217,   196,   197,
+     217,    23,    54,   123,   195,   207,   124,   189,    11,   166,
+     123,   124,   166,   134,    42,    65,    92,   109,   140,   217,
+     217,   122,   122,   143,   123,   124,    75,   136,   194,   175,
+     191,   195,     8,     9,    10,    11,    12,    13,    14,    15,
+      16,    17,    18,    19,   212,    20,   208,   209,   123,   104,
+     195,   203,   206,   195,    58,   123,    66,   123,    31,   178,
+     179,    67,    72,    77,    80,    97,   124,   172,   173,   174,
+     178,    36,   108,   176,    68,   181,   123,   207,   123,   124,
+     161,   195,   123,   217,   122,    78,    78,   122,    52,    59,
+     157,   210,   211,   217,   111,   140,   141,   142,   134,    10,
+      42,    50,    83,    92,    96,   109,   137,   138,   139,   123,
+     192,   193,    17,    18,    19,   195,   195,    10,    83,   123,
+     124,   112,   195,   104,    58,   195,   179,    77,    88,    77,
+     216,    77,    88,    77,    88,   177,   174,     7,     7,   178,
+      39,    70,   182,   123,   195,   191,   122,   122,   216,     5,
+      62,    85,    86,   107,   218,   123,   124,   123,   124,    37,
+      38,   101,   152,   124,   116,   144,    83,   122,   208,    78,
+     217,   137,   195,     9,    83,   208,   122,   195,   123,   216,
+      77,   216,    86,   216,    77,   216,    77,    91,    91,   207,
+     191,    87,   183,   123,   216,   216,   123,    52,    59,   210,
+     122,   153,   140,    35,    89,   145,   191,   122,     9,   195,
+     209,    86,   216,    86,   191,    86,   216,    86,   216,    39,
+      81,   184,   123,   123,     5,   218,   147,   148,   149,   150,
+     151,   217,   122,    39,   123,   217,   195,   123,   191,    86,
+     191,   191,    86,   191,    86,   185,   186,   195,     7,    96,
+     123,   124,     7,    29,   122,   217,   147,    69,    94,   146,
+     123,   191,   191,   191,   124,    32,    53,   187,   217,   148,
+     216,   123,   122,   186,    84,   188,   122,   123,   216,    63,
+      79,   216,   123,   123,    90,     7
 };
 
   /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
 static const yytype_uint8 yyr1[] =
 {
-       0,   125,   126,   126,   126,   126,   126,   126,   127,   127,
-     127,   127,   127,   127,   127,   127,   127,   127,   128,   129,
-     129,   129,   129,   130,   131,   132,   133,   134,   134,   135,
-     135,   135,   135,   135,   135,   135,   135,   135,   135,   135,
-     135,   135,   135,   135,   135,   135,   135,   136,   136,   136,
-     136,   136,   136,   136,   137,   137,   138,   138,   139,   139,
-     139,   139,   140,   140,   141,   141,   142,   142,   143,   143,
-     144,   144,   145,   145,   146,   146,   147,   147,   147,   148,
-     148,   149,   150,   151,   151,   152,   152,   153,   153,   153,
-     153,   154,   155,   155,   156,   156,   156,   156,   157,   158,
-     159,   159,   160,   161,   161,   162,   163,   163,   164,   165,
-     166,   166,   166,   167,   167,   168,   168,   169,   169,   169,
-     170,   171,   171,   172,   172,   173,   173,   173,   173,   173,
-     173,   173,   173,   174,   175,   175,   175,   176,   176,   176,
-     176,   176,   177,   177,   178,   178,   179,   179,   180,   180,
-     181,   181,   182,   182,   183,   183,   184,   184,   185,   186,
-     186,   186,   187,   187,   187,   188,   188,   189,   190,   190,
-     191,   191,   192,   192,   193,   193,   193,   193,   193,   193,
-     193,   194,   194,   195,   195,   196,   196,   197,   197,   197,
-     197,   197,   197,   198,   198,   198,   198,   199,   200,   200,
-     201,   201,   202,   203,   203,   204,   205,   205,   206,   206,
-     207,   207,   207,   207,   207,   207,   207,   208,   208,   209,
-     209,   210,   210,   211,   211,   211,   211,   211,   211,   211,
-     211,   211,   211,   212,   213,   213,   214,   214,   214,   215,
-     215,   216,   216,   217,   217,   217,   217,   218,   219,   219
+       0,   126,   127,   127,   127,   127,   127,   127,   128,   128,
+     128,   128,   128,   128,   128,   128,   128,   128,   129,   130,
+     130,   130,   130,   131,   132,   133,   134,   135,   135,   136,
+     136,   136,   136,   136,   136,   136,   136,   136,   136,   136,
+     136,   136,   136,   136,   136,   136,   136,   137,   137,   137,
+     137,   137,   137,   137,   138,   138,   139,   139,   140,   140,
+     140,   140,   141,   141,   142,   142,   143,   143,   144,   144,
+     145,   145,   146,   146,   147,   147,   148,   148,   148,   149,
+     149,   150,   151,   152,   152,   152,   153,   153,   154,   154,
+     154,   154,   155,   156,   156,   157,   157,   157,   157,   158,
+     159,   160,   160,   161,   162,   162,   163,   164,   164,   165,
+     166,   167,   167,   167,   168,   168,   169,   169,   170,   170,
+     170,   171,   172,   172,   173,   173,   174,   174,   174,   174,
+     174,   174,   174,   174,   175,   176,   176,   176,   177,   177,
+     177,   177,   177,   178,   178,   179,   179,   180,   180,   181,
+     181,   182,   182,   183,   183,   184,   184,   185,   185,   186,
+     187,   187,   187,   188,   188,   188,   189,   189,   190,   191,
+     191,   192,   192,   193,   193,   194,   194,   194,   194,   194,
+     194,   194,   195,   195,   196,   196,   197,   197,   198,   198,
+     198,   198,   198,   198,   199,   199,   199,   199,   200,   201,
+     201,   202,   202,   203,   204,   204,   205,   206,   206,   207,
+     207,   208,   208,   208,   208,   208,   208,   208,   209,   209,
+     210,   210,   211,   211,   212,   212,   212,   212,   212,   212,
+     212,   212,   212,   212,   213,   214,   214,   215,   215,   215,
+     216,   216,   217,   217,   218,   218,   218,   218,   219,   220,
+     220
 };
 
   /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
@@ -1336,23 +1321,24 @@ static const yytype_uint8 yyr2[] =
        2,     2,     4,     5,     2,     1,     0,     1,     4,     5,
       10,     4,     3,     1,     0,     1,     0,     3,     0,     5,
        0,     8,     1,     1,     1,     3,     1,     1,     1,     2,
-       2,     4,     2,     1,     1,     0,     3,    10,     7,     4,
-       5,     5,     0,     4,     2,     2,     4,     4,     5,     4,
-       3,     1,     3,     1,     2,     2,     1,     3,     3,     9,
-       0,     1,     1,     1,     1,     1,     3,     3,     2,     1,
-       3,     0,     1,     2,     1,     5,     4,     6,     5,     6,
-       5,     6,     5,     3,     0,     3,     3,     2,     3,     2,
-       2,     1,     1,     2,     1,     4,     1,     3,     0,     3,
-       0,     2,     0,     3,     0,     2,     1,     3,     3,     0,
-       1,     1,     0,     2,     2,     0,     1,     2,     3,     1,
-       3,     1,     2,     1,     5,     6,     4,     3,     3,     3,
-       2,     3,     1,     3,     1,     2,     1,     1,     1,     1,
-       1,     1,     3,     3,     4,     4,     5,     6,     5,     4,
-       1,     2,     4,     1,     2,     4,     0,     2,     1,     3,
-       1,     1,     2,     2,     1,     2,     2,     1,     3,     1,
-       3,     1,     3,     1,     1,     1,     1,     1,     1,     1,
-       2,     1,     2,     1,     1,     1,     1,     1,     1,     1,
-       3,     1,     1,     1,     1,     1,     1,     2,     2,     0
+       2,     4,     2,     1,     1,     1,     0,     3,    10,     7,
+       4,     5,     5,     0,     4,     2,     2,     4,     4,     5,
+       4,     3,     1,     3,     1,     2,     2,     1,     3,     3,
+       9,     0,     1,     1,     1,     1,     1,     3,     3,     2,
+       1,     3,     0,     1,     2,     1,     5,     4,     6,     5,
+       6,     5,     6,     5,     3,     0,     3,     3,     2,     3,
+       2,     2,     1,     1,     2,     1,     4,     1,     3,     0,
+       3,     0,     2,     0,     3,     0,     2,     1,     3,     3,
+       0,     1,     1,     0,     2,     2,     0,     1,     2,     3,
+       1,     3,     1,     2,     1,     5,     6,     4,     3,     3,
+       3,     2,     3,     1,     3,     1,     2,     1,     1,     1,
+       1,     1,     1,     3,     3,     4,     4,     5,     6,     5,
+       4,     1,     2,     4,     1,     2,     4,     0,     2,     1,
+       3,     1,     1,     2,     2,     1,     2,     2,     1,     3,
+       1,     3,     1,     3,     1,     1,     1,     1,     1,     1,
+       1,     2,     1,     2,     1,     1,     1,     1,     1,     1,
+       1,     3,     1,     1,     1,     1,     1,     1,     2,     2,
+       0
 };
 
 
@@ -1849,893 +1835,893 @@ yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocatio
   switch (yytype)
     {
           case 3: /* TOKEN_COMMAND  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 1859 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1845 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 4: /* TOKEN_NAME  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 1869 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1855 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 5: /* TOKEN_STRING_SINGLE_QUOTED  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 1879 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1865 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 6: /* TOKEN_STRING_DOUBLE_QUOTED  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 1889 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1875 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
     case 7: /* TOKEN_UNSIGNED_NUMVAL  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).numeric_literal_value_) != nullptr) {
     delete ((*yyvaluep).numeric_literal_value_);
   }
 }
-#line 1899 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1885 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 127: /* sql_statement  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 128: /* sql_statement  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).statement_) != nullptr) {
     delete ((*yyvaluep).statement_);
   }
 }
-#line 1909 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1895 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 128: /* quit_statement  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 129: /* quit_statement  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).quit_statement_) != nullptr) {
     delete ((*yyvaluep).quit_statement_);
   }
 }
-#line 1919 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1905 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 129: /* alter_table_statement  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 130: /* alter_table_statement  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).statement_) != nullptr) {
     delete ((*yyvaluep).statement_);
   }
 }
-#line 1929 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1915 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 130: /* create_table_statement  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 131: /* create_table_statement  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).create_table_statement_) != nullptr) {
     delete ((*yyvaluep).create_table_statement_);
   }
 }
-#line 1939 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1925 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 131: /* create_index_statement  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 132: /* create_index_statement  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).statement_) != nullptr) {
     delete ((*yyvaluep).statement_);
   }
 }
-#line 1949 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1935 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 132: /* drop_table_statement  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 133: /* drop_table_statement  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).drop_table_statement_) != nullptr) {
     delete ((*yyvaluep).drop_table_statement_);
   }
 }
-#line 1959 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1945 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 133: /* column_def  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 134: /* column_def  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).attribute_definition_) != nullptr) {
     delete ((*yyvaluep).attribute_definition_);
   }
 }
-#line 1969 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1955 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 134: /* column_def_commalist  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 135: /* column_def_commalist  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).attribute_definition_list_) != nullptr) {
     delete ((*yyvaluep).attribute_definition_list_);
   }
 }
-#line 1979 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1965 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 135: /* data_type  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 136: /* data_type  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).data_type_) != nullptr) {
     delete ((*yyvaluep).data_type_);
   }
 }
-#line 1989 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1975 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 136: /* column_constraint_def  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 137: /* column_constraint_def  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).column_constraint_) != nullptr) {
     delete ((*yyvaluep).column_constraint_);
   }
 }
-#line 1999 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1985 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 137: /* column_constraint_def_list  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 138: /* column_constraint_def_list  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).column_constraint_list_) != nullptr) {
     delete ((*yyvaluep).column_constraint_list_);
   }
 }
-#line 2009 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 1995 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 138: /* opt_column_constraint_def_list  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 139: /* opt_column_constraint_def_list  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).column_constraint_list_) != nullptr) {
     delete ((*yyvaluep).column_constraint_list_);
   }
 }
-#line 2019 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2005 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 142: /* opt_column_list  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 143: /* opt_column_list  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).attribute_list_) != nullptr) {
     delete ((*yyvaluep).attribute_list_);
   }
 }
-#line 2029 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2015 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 143: /* opt_block_properties  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 144: /* opt_block_properties  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).block_properties_) != nullptr) {
     delete ((*yyvaluep).block_properties_);
   }
 }
-#line 2039 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2025 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 144: /* opt_partition_clause  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 145: /* opt_partition_clause  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).partition_clause_) != nullptr) {
     delete ((*yyvaluep).partition_clause_);
   }
 }
-#line 2049 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2035 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 145: /* partition_type  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 146: /* partition_type  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 2059 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2045 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 146: /* key_value_list  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 147: /* key_value_list  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_value_list_) != nullptr) {
     delete ((*yyvaluep).key_value_list_);
   }
 }
-#line 2069 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2055 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 147: /* key_value  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 148: /* key_value  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_value_) != nullptr) {
     delete ((*yyvaluep).key_value_);
   }
 }
-#line 2079 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2065 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 148: /* key_string_value  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 149: /* key_string_value  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_string_value_) != nullptr) {
     delete ((*yyvaluep).key_string_value_);
   }
 }
-#line 2089 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2075 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 149: /* key_string_list  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 150: /* key_string_list  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_string_list_) != nullptr) {
     delete ((*yyvaluep).key_string_list_);
   }
 }
-#line 2099 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2085 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 150: /* key_integer_value  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 151: /* key_integer_value  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_integer_value_) != nullptr) {
     delete ((*yyvaluep).key_integer_value_);
   }
 }
-#line 2109 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2095 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 151: /* index_type  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 152: /* index_type  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).string_value_) != nullptr) {
     delete ((*yyvaluep).string_value_);
   }
 }
-#line 2119 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2105 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 152: /* opt_index_properties  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 153: /* opt_index_properties  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).key_value_list_) != nullptr) {
     delete ((*yyvaluep).key_value_list_);
   }
 }
-#line 2129 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2115 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 153: /* insert_statement  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 154: /* insert_statement  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).insert_statement_) != nullptr) {
     delete ((*yyvaluep).insert_statement_);
   }
 }
-#line 2139 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2125 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 154: /* copy_from_statement  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 155: /* copy_from_statement  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).copy_from_statement_) != nullptr) {
     delete ((*yyvaluep).copy_from_statement_);
   }
 }
-#line 2149 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2135 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 155: /* opt_copy_from_params  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 156: /* opt_copy_from_params  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).copy_from_params_) != nullptr) {
     delete ((*yyvaluep).copy_from_params_);
   }
 }
-#line 2159 "SqlParser_gen.cpp" /* yacc.c:1257  */
+#line 2145 "SqlParser_gen.cpp" /* yacc.c:1257  */
         break;
 
-    case 156: /* copy_from_params  */
-#line 557 "../SqlParser.ypp" /* yacc.c:1257  */
+    case 157: /* copy_from_params  */
+#line 558 "../SqlParser.ypp" /* yacc.c:1257  */
       {
   if (((*yyvaluep).copy_from_params_) != nullptr) {
     delete ((*yyva

<TRUNCATED>


[10/24] incubator-quickstep git commit: Change Travis to use gold linker. (#143)

Posted by zu...@apache.org.
Change Travis to use gold linker. (#143)

Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/ff202779
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/ff202779
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/ff202779

Branch: refs/heads/master
Commit: ff202779dca86c025f054de45581e5714df48868
Parents: 6dba6e1
Author: Hakan Memisoglu <ha...@gmail.com>
Authored: Thu Apr 14 22:37:25 2016 -0500
Committer: Jignesh Patel <pa...@users.noreply.github.com>
Committed: Thu Apr 14 22:37:25 2016 -0500

----------------------------------------------------------------------
 .travis.yml | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/ff202779/.travis.yml
----------------------------------------------------------------------
diff --git a/.travis.yml b/.travis.yml
index 16bb6fb..4e10e2a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -32,6 +32,7 @@ install:
       export CC="clang-3.7";
       export CXX="clang++-3.7";
     fi
+  - export CLINKER=`which gold`
   - export DEBUG_FLAGS="-g0";
   - export RELEASE_FLAGS="-O0 -DNDEBUG";
   - export LINKER_FLAGS="-s"
@@ -39,6 +40,7 @@ install:
 before_script:
   - $CC --version
   - $CXX --version
+  - $CLINKER --version
   - (cd build &&
      cmake -D CMAKE_BUILD_TYPE=$BUILD_TYPE
            -D CMAKE_C_FLAGS_DEBUG="$DEBUG_FLAGS"
@@ -48,6 +50,7 @@ before_script:
            -D CMAKE_EXE_LINKER_FLAGS="$LINKER_FLAGS"
            -D CMAKE_C_COMPILER=$CC
            -D CMAKE_CXX_COMPILER=$CXX
+           -D CMAKE_LINKER=$CLINKER
            -D USE_TCMALLOC=0
            -D VECTOR_COPY_ELISION_LEVEL=$VECTOR_COPY_ELISION_LEVEL ..)
 
@@ -77,6 +80,7 @@ addons:
       - gcc-5
       - g++-5
       - clang-3.7
+      - binutils-gold
       - libprotobuf-dev
       - protobuf-compiler
       - python-networkx


[11/24] incubator-quickstep git commit: Adds support for IN predicate (#167)

Posted by zu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/query_optimizer/tests/physical_generator/Select.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/physical_generator/Select.test b/query_optimizer/tests/physical_generator/Select.test
index 61ba01c..2fa3720 100644
--- a/query_optimizer/tests/physical_generator/Select.test
+++ b/query_optimizer/tests/physical_generator/Select.test
@@ -1802,3 +1802,314 @@ TopLevelPlan
 |     relation=generate_series,type=Int]
 +-output_attributes=
   +-AttributeReference[id=1,name=i,relation=,type=Int]
+==
+
+# IN predicate
+SELECT char_col
+FROM test
+WHERE int_col IN (1, 2, 3);
+--
+[Optimized Logical Plan]
+TopLevelPlan
++-plan=Project
+| +-input=Filter
+| | +-input=TableReference[relation_name=Test,relation_alias=test]
+| | | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| | | +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+| | | +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+| | | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+| | | +-AttributeReference[id=5,name=vchar_col,relation=test,
+| | |   type=VarChar(20) NULL]
+| | +-filter_predicate=InValueList
+| |   +-test_expression=AttributeReference[id=0,name=int_col,relation=test,
+| |   | type=Int NULL]
+| |   +-match_expressions=
+| |     +-Literal[value=1,type=Int]
+| |     +-Literal[value=2,type=Int]
+| |     +-Literal[value=3,type=Int]
+| +-project_list=
+|   +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
++-output_attributes=
+  +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+[Physical Plan]
+TopLevelPlan
++-plan=Selection
+| +-input=TableReference[relation=Test,alias=test]
+| | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| | +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+| | +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+| | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+| | +-AttributeReference[id=5,name=vchar_col,relation=test,type=VarChar(20) NULL]
+| +-filter_predicate=InValueList
+| | +-test_expression=AttributeReference[id=0,name=int_col,relation=test,
+| | | type=Int NULL]
+| | +-match_expressions=
+| |   +-Literal[value=1,type=Int]
+| |   +-Literal[value=2,type=Int]
+| |   +-Literal[value=3,type=Int]
+| +-project_expressions=
+|   +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
++-output_attributes=
+  +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+==
+
+SELECT char_col
+FROM test
+WHERE int_col*2 NOT IN (
+        long_col+1,
+        CASE WHEN float_col > 0 THEN 1
+             ELSE double_col END);
+--
+[Optimized Logical Plan]
+TopLevelPlan
++-plan=Project
+| +-input=Filter
+| | +-input=TableReference[relation_name=Test,relation_alias=test]
+| | | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| | | +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+| | | +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+| | | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+| | | +-AttributeReference[id=5,name=vchar_col,relation=test,
+| | |   type=VarChar(20) NULL]
+| | +-filter_predicate=NOT
+| |   +-InValueList
+| |     +-test_expression=Multiply
+| |     | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| |     | +-Literal[value=2,type=Int]
+| |     +-match_expressions=
+| |       +-Add
+| |       | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| |       | +-Literal[value=1,type=Int]
+| |       +-SearchedCase
+| |         +-else_result_expression=AttributeReference[id=3,name=double_col,
+| |         | relation=test,type=Double NULL]
+| |         +-condition_perdicates=
+| |         | +-Greater
+| |         |   +-AttributeReference[id=2,name=float_col,relation=test,
+| |         |   | type=Float]
+| |         |   +-Literal[value=0,type=Int]
+| |         +-conditional_result_expressions=
+| |           +-Cast[target_type=Double NULL]
+| |             +-operand=Literal[value=1,type=Int]
+| +-project_list=
+|   +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
++-output_attributes=
+  +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+[Physical Plan]
+TopLevelPlan
++-plan=Selection
+| +-input=TableReference[relation=Test,alias=test]
+| | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| | +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+| | +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+| | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+| | +-AttributeReference[id=5,name=vchar_col,relation=test,type=VarChar(20) NULL]
+| +-filter_predicate=NOT
+| | +-InValueList
+| |   +-test_expression=Multiply
+| |   | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| |   | +-Literal[value=2,type=Int]
+| |   +-match_expressions=
+| |     +-Add
+| |     | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| |     | +-Literal[value=1,type=Int]
+| |     +-SearchedCase
+| |       +-else_result_expression=AttributeReference[id=3,name=double_col,
+| |       | relation=test,type=Double NULL]
+| |       +-condition_perdicates=
+| |       | +-Greater
+| |       |   +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+| |       |   +-Literal[value=0,type=Int]
+| |       +-conditional_result_expressions=
+| |         +-Cast[target_type=Double NULL]
+| |           +-operand=Literal[value=1,type=Int]
+| +-project_expressions=
+|   +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
++-output_attributes=
+  +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+==
+
+SELECT char_col
+FROM test
+WHERE int_col IN (
+  SELECT SUM(long_col) - 10
+  FROM test
+  GROUP BY vchar_col
+);
+--
+[Optimized Logical Plan]
+TopLevelPlan
++-plan=Project
+| +-input=HashLeftSemiJoin
+| | +-left=TableReference[relation_name=Test,relation_alias=test]
+| | | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| | | +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+| | | +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+| | | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+| | | +-AttributeReference[id=5,name=vchar_col,relation=test,
+| | |   type=VarChar(20) NULL]
+| | +-right=Project
+| | | +-input=Aggregate
+| | | | +-input=TableReference[relation_name=Test,relation_alias=test]
+| | | | | +-AttributeReference[id=6,name=int_col,relation=test,type=Int NULL]
+| | | | | +-AttributeReference[id=7,name=long_col,relation=test,type=Long]
+| | | | | +-AttributeReference[id=8,name=float_col,relation=test,type=Float]
+| | | | | +-AttributeReference[id=9,name=double_col,relation=test,
+| | | | | | type=Double NULL]
+| | | | | +-AttributeReference[id=10,name=char_col,relation=test,type=Char(20)]
+| | | | | +-AttributeReference[id=11,name=vchar_col,relation=test,
+| | | | |   type=VarChar(20) NULL]
+| | | | +-grouping_expressions=
+| | | | | +-AttributeReference[id=11,name=vchar_col,relation=test,
+| | | | |   type=VarChar(20) NULL]
+| | | | +-aggregate_expressions=
+| | | |   +-Alias[id=12,name=,alias=$aggregate0,relation=$aggregate,
+| | | |     type=Long NULL]
+| | | |     +-AggregateFunction[function=SUM]
+| | | |       +-AttributeReference[id=7,name=long_col,relation=test,type=Long]
+| | | +-project_list=
+| | |   +-Alias[id=13,name=,alias=(SUM(long_col)-10),relation=,type=Long NULL]
+| | |     +-Subtract
+| | |       +-AttributeReference[id=12,name=,alias=$aggregate0,
+| | |       | relation=$aggregate,type=Long NULL]
+| | |       +-Literal[value=10,type=Int]
+| | +-left_join_attributes=
+| | | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | +-right_join_attributes=
+| |   +-AttributeReference[id=13,name=,alias=(SUM(long_col)-10),relation=,
+| |     type=Long NULL]
+| +-project_list=
+|   +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
++-output_attributes=
+  +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+[Physical Plan]
+TopLevelPlan
++-plan=HashLeftSemiJoin
+| +-left=TableReference[relation=Test,alias=test]
+| | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| | +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+| | +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+| | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+| | +-AttributeReference[id=5,name=vchar_col,relation=test,type=VarChar(20) NULL]
+| +-right=Selection
+| | +-input=Aggregate
+| | | +-input=TableReference[relation=Test,alias=test]
+| | | | +-AttributeReference[id=6,name=int_col,relation=test,type=Int NULL]
+| | | | +-AttributeReference[id=7,name=long_col,relation=test,type=Long]
+| | | | +-AttributeReference[id=8,name=float_col,relation=test,type=Float]
+| | | | +-AttributeReference[id=9,name=double_col,relation=test,type=Double NULL]
+| | | | +-AttributeReference[id=10,name=char_col,relation=test,type=Char(20)]
+| | | | +-AttributeReference[id=11,name=vchar_col,relation=test,
+| | | |   type=VarChar(20) NULL]
+| | | +-grouping_expressions=
+| | | | +-AttributeReference[id=11,name=vchar_col,relation=test,
+| | | |   type=VarChar(20) NULL]
+| | | +-aggregate_expressions=
+| | |   +-Alias[id=12,name=,alias=$aggregate0,relation=$aggregate,type=Long NULL]
+| | |     +-AggregateFunction[function=SUM]
+| | |       +-AttributeReference[id=7,name=long_col,relation=test,type=Long]
+| | +-project_expressions=
+| |   +-Alias[id=13,name=,alias=(SUM(long_col)-10),relation=,type=Long NULL]
+| |     +-Subtract
+| |       +-AttributeReference[id=12,name=,alias=$aggregate0,
+| |       | relation=$aggregate,type=Long NULL]
+| |       +-Literal[value=10,type=Int]
+| +-project_expressions=
+| | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+| +-left_join_attributes=
+| | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| +-right_join_attributes=
+|   +-AttributeReference[id=13,name=,alias=(SUM(long_col)-10),relation=,
+|     type=Long NULL]
++-output_attributes=
+  +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+==
+
+SELECT char_col
+FROM test
+WHERE int_col NOT IN (
+  SELECT long_col
+  FROM test
+  WHERE long_col IN (1, 2)
+);
+--
+[Optimized Logical Plan]
+TopLevelPlan
++-plan=Project
+| +-input=HashLeftAntiJoin
+| | +-left=TableReference[relation_name=Test,relation_alias=test]
+| | | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| | | +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+| | | +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+| | | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+| | | +-AttributeReference[id=5,name=vchar_col,relation=test,
+| | |   type=VarChar(20) NULL]
+| | +-right=Project
+| | | +-input=Filter
+| | | | +-input=TableReference[relation_name=Test,relation_alias=test]
+| | | | | +-AttributeReference[id=6,name=int_col,relation=test,type=Int NULL]
+| | | | | +-AttributeReference[id=7,name=long_col,relation=test,type=Long]
+| | | | | +-AttributeReference[id=8,name=float_col,relation=test,type=Float]
+| | | | | +-AttributeReference[id=9,name=double_col,relation=test,
+| | | | | | type=Double NULL]
+| | | | | +-AttributeReference[id=10,name=char_col,relation=test,type=Char(20)]
+| | | | | +-AttributeReference[id=11,name=vchar_col,relation=test,
+| | | | |   type=VarChar(20) NULL]
+| | | | +-filter_predicate=InValueList
+| | | |   +-test_expression=AttributeReference[id=7,name=long_col,relation=test,
+| | | |   | type=Long]
+| | | |   +-match_expressions=
+| | | |     +-Literal[value=1,type=Long]
+| | | |     +-Literal[value=2,type=Long]
+| | | +-project_list=
+| | |   +-AttributeReference[id=7,name=long_col,relation=test,type=Long]
+| | +-left_join_attributes=
+| | | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | +-right_join_attributes=
+| |   +-AttributeReference[id=7,name=long_col,relation=test,type=Long]
+| +-project_list=
+|   +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
++-output_attributes=
+  +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+[Physical Plan]
+TopLevelPlan
++-plan=HashLeftAntiJoin
+| +-left=TableReference[relation=Test,alias=test]
+| | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| | +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+| | +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+| | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+| | +-AttributeReference[id=5,name=vchar_col,relation=test,type=VarChar(20) NULL]
+| +-right=Selection
+| | +-input=TableReference[relation=Test,alias=test]
+| | | +-AttributeReference[id=6,name=int_col,relation=test,type=Int NULL]
+| | | +-AttributeReference[id=7,name=long_col,relation=test,type=Long]
+| | | +-AttributeReference[id=8,name=float_col,relation=test,type=Float]
+| | | +-AttributeReference[id=9,name=double_col,relation=test,type=Double NULL]
+| | | +-AttributeReference[id=10,name=char_col,relation=test,type=Char(20)]
+| | | +-AttributeReference[id=11,name=vchar_col,relation=test,
+| | |   type=VarChar(20) NULL]
+| | +-filter_predicate=InValueList
+| | | +-test_expression=AttributeReference[id=7,name=long_col,relation=test,
+| | | | type=Long]
+| | | +-match_expressions=
+| | |   +-Literal[value=1,type=Long]
+| | |   +-Literal[value=2,type=Long]
+| | +-project_expressions=
+| |   +-AttributeReference[id=7,name=long_col,relation=test,type=Long]
+| +-project_expressions=
+| | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+| +-left_join_attributes=
+| | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| +-right_join_attributes=
+|   +-AttributeReference[id=7,name=long_col,relation=test,type=Long]
++-output_attributes=
+  +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fd8c039/query_optimizer/tests/resolver/Select.test
----------------------------------------------------------------------
diff --git a/query_optimizer/tests/resolver/Select.test b/query_optimizer/tests/resolver/Select.test
index 2276de3..82bdb55 100644
--- a/query_optimizer/tests/resolver/Select.test
+++ b/query_optimizer/tests/resolver/Select.test
@@ -2599,3 +2599,197 @@ TopLevelPlan
 |       type=Long NULL]
 +-output_attributes=
   +-AttributeReference[id=6,name=result,relation=,type=Long NULL]
+==
+
+# IN predicate
+SELECT char_col
+FROM test
+WHERE int_col IN (1, 2, 3);
+--
+TopLevelPlan
++-plan=Project
+| +-input=Filter
+| | +-input=TableReference[relation_name=Test,relation_alias=test]
+| | | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| | | +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+| | | +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+| | | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+| | | +-AttributeReference[id=5,name=vchar_col,relation=test,
+| | |   type=VarChar(20) NULL]
+| | +-filter_predicate=InValueList
+| |   +-test_expression=AttributeReference[id=0,name=int_col,relation=test,
+| |   | type=Int NULL]
+| |   +-match_expressions=
+| |     +-Literal[value=1,type=Int]
+| |     +-Literal[value=2,type=Int]
+| |     +-Literal[value=3,type=Int]
+| +-project_list=
+|   +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
++-output_attributes=
+  +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+==
+
+SELECT char_col
+FROM test
+WHERE int_col*2 NOT IN (
+        long_col+1,
+        CASE WHEN float_col > 0 THEN 1
+             ELSE double_col END);
+--
+TopLevelPlan
++-plan=Project
+| +-input=Filter
+| | +-input=TableReference[relation_name=Test,relation_alias=test]
+| | | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| | | +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+| | | +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+| | | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+| | | +-AttributeReference[id=5,name=vchar_col,relation=test,
+| | |   type=VarChar(20) NULL]
+| | +-filter_predicate=NOT
+| |   +-InValueList
+| |     +-test_expression=Multiply
+| |     | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| |     | +-Literal[value=2,type=Int]
+| |     +-match_expressions=
+| |       +-Add
+| |       | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| |       | +-Literal[value=1,type=Int]
+| |       +-SearchedCase
+| |         +-else_result_expression=AttributeReference[id=3,name=double_col,
+| |         | relation=test,type=Double NULL]
+| |         +-condition_perdicates=
+| |         | +-Greater
+| |         |   +-AttributeReference[id=2,name=float_col,relation=test,
+| |         |   | type=Float]
+| |         |   +-Literal[value=0,type=Int]
+| |         +-conditional_result_expressions=
+| |           +-Cast[target_type=Double NULL]
+| |             +-operand=Literal[value=1,type=Int]
+| +-project_list=
+|   +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
++-output_attributes=
+  +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+==
+
+SELECT char_col
+FROM test
+WHERE int_col IN (
+  SELECT SUM(long_col) - 10
+  FROM test
+  GROUP BY vchar_col
+);
+--
+TopLevelPlan
++-plan=Project
+| +-input=Filter
+| | +-input=TableReference[relation_name=Test,relation_alias=test]
+| | | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| | | +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+| | | +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+| | | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+| | | +-AttributeReference[id=5,name=vchar_col,relation=test,
+| | |   type=VarChar(20) NULL]
+| | +-filter_predicate=InTableQuery
+| |   +-test_expression=AttributeReference[id=0,name=int_col,relation=test,
+| |   | type=Int NULL]
+| |   +-table_query=SubqueryExpression
+| |     +-subquery=Project
+| |       +-input=Aggregate
+| |       | +-input=TableReference[relation_name=Test,relation_alias=test]
+| |       | | +-AttributeReference[id=6,name=int_col,relation=test,type=Int NULL]
+| |       | | +-AttributeReference[id=7,name=long_col,relation=test,type=Long]
+| |       | | +-AttributeReference[id=8,name=float_col,relation=test,type=Float]
+| |       | | +-AttributeReference[id=9,name=double_col,relation=test,
+| |       | | | type=Double NULL]
+| |       | | +-AttributeReference[id=10,name=char_col,relation=test,
+| |       | | | type=Char(20)]
+| |       | | +-AttributeReference[id=11,name=vchar_col,relation=test,
+| |       | |   type=VarChar(20) NULL]
+| |       | +-grouping_expressions=
+| |       | | +-AttributeReference[id=11,name=vchar_col,relation=test,
+| |       | |   type=VarChar(20) NULL]
+| |       | +-aggregate_expressions=
+| |       |   +-Alias[id=12,name=,alias=$aggregate0,relation=$aggregate,
+| |       |     type=Long NULL]
+| |       |     +-AggregateFunction[function=SUM]
+| |       |       +-AttributeReference[id=7,name=long_col,relation=test,
+| |       |         type=Long]
+| |       +-project_list=
+| |         +-Alias[id=13,name=,alias=(SUM(long_col)-10),relation=,
+| |           type=Long NULL]
+| |           +-Subtract
+| |             +-AttributeReference[id=12,name=,alias=$aggregate0,
+| |             | relation=$aggregate,type=Long NULL]
+| |             +-Literal[value=10,type=Int]
+| +-project_list=
+|   +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
++-output_attributes=
+  +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+==
+
+SELECT char_col
+FROM test
+WHERE int_col NOT IN (
+  SELECT long_col
+  FROM test
+  WHERE long_col IN (1, 2)
+);
+--
+TopLevelPlan
++-plan=Project
+| +-input=Filter
+| | +-input=TableReference[relation_name=Test,relation_alias=test]
+| | | +-AttributeReference[id=0,name=int_col,relation=test,type=Int NULL]
+| | | +-AttributeReference[id=1,name=long_col,relation=test,type=Long]
+| | | +-AttributeReference[id=2,name=float_col,relation=test,type=Float]
+| | | +-AttributeReference[id=3,name=double_col,relation=test,type=Double NULL]
+| | | +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+| | | +-AttributeReference[id=5,name=vchar_col,relation=test,
+| | |   type=VarChar(20) NULL]
+| | +-filter_predicate=NOT
+| |   +-InTableQuery
+| |     +-test_expression=AttributeReference[id=0,name=int_col,relation=test,
+| |     | type=Int NULL]
+| |     +-table_query=SubqueryExpression
+| |       +-subquery=Project
+| |         +-input=Filter
+| |         | +-input=TableReference[relation_name=Test,relation_alias=test]
+| |         | | +-AttributeReference[id=6,name=int_col,relation=test,
+| |         | | | type=Int NULL]
+| |         | | +-AttributeReference[id=7,name=long_col,relation=test,type=Long]
+| |         | | +-AttributeReference[id=8,name=float_col,relation=test,
+| |         | | | type=Float]
+| |         | | +-AttributeReference[id=9,name=double_col,relation=test,
+| |         | | | type=Double NULL]
+| |         | | +-AttributeReference[id=10,name=char_col,relation=test,
+| |         | | | type=Char(20)]
+| |         | | +-AttributeReference[id=11,name=vchar_col,relation=test,
+| |         | |   type=VarChar(20) NULL]
+| |         | +-filter_predicate=InValueList
+| |         |   +-test_expression=AttributeReference[id=7,name=long_col,
+| |         |   | relation=test,type=Long]
+| |         |   +-match_expressions=
+| |         |     +-Literal[value=1,type=Long]
+| |         |     +-Literal[value=2,type=Long]
+| |         +-project_list=
+| |           +-AttributeReference[id=7,name=long_col,relation=test,type=Long]
+| +-project_list=
+|   +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
++-output_attributes=
+  +-AttributeReference[id=4,name=char_col,relation=test,type=Char(20)]
+==
+
+SELECT *
+FROM generate_series(1, 10) AS gs1(i)
+WHERE i IN (
+  SELECT j, j+1
+  FROM generate_series(1, 5) AS gs2(j)
+);
+--
+ERROR: Subquery must return exactly one column (3 : 12)
+WHERE i IN (
+           ^


[05/24] incubator-quickstep git commit: Adds backend support for hash semi/anti joins. (#164)

Posted by zu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a39ad965/storage/LinearOpenAddressingHashTable.hpp
----------------------------------------------------------------------
diff --git a/storage/LinearOpenAddressingHashTable.hpp b/storage/LinearOpenAddressingHashTable.hpp
index e5ca0b0..438a2d1 100644
--- a/storage/LinearOpenAddressingHashTable.hpp
+++ b/storage/LinearOpenAddressingHashTable.hpp
@@ -151,6 +151,9 @@ class LinearOpenAddressingHashTable : public HashTable<ValueT,
                                    const ValueT **value,
                                    std::size_t *entry_num) const override;
 
+  bool hasKey(const TypedValue &key) const override;
+  bool hasCompositeKey(const std::vector<TypedValue> &key) const override;
+
   void resize(const std::size_t extra_buckets,
               const std::size_t extra_variable_storage,
               const std::size_t retry_num = 0) override;
@@ -1099,6 +1102,75 @@ bool LinearOpenAddressingHashTable<ValueT, resizable, serializable, force_key_co
   return false;
 }
 
+template <typename ValueT,
+          bool resizable,
+          bool serializable,
+          bool force_key_copy,
+          bool allow_duplicate_keys>
+bool LinearOpenAddressingHashTable<ValueT, resizable, serializable, force_key_copy, allow_duplicate_keys>
+    ::hasKey(const TypedValue &key) const {
+  DCHECK_EQ(1u, this->key_types_.size());
+  DCHECK(key.isPlausibleInstanceOf(this->key_types_.front()->getSignature()));
+
+  const std::size_t hash_code = this->AdjustHash(key.getHash());
+  for (std::size_t bucket_num = hash_code % header_->num_buckets;
+       bucket_num < header_->num_buckets + header_->num_overflow_buckets;
+       ++bucket_num) {
+    const char *bucket = static_cast<const char*>(hash_buckets_) + bucket_num * bucket_size_;
+    const std::size_t bucket_hash
+        = reinterpret_cast<const std::atomic<std::size_t>*>(bucket)->load(std::memory_order_relaxed);
+    if (bucket_hash == kEmptyHash) {
+      // Hit an empty bucket, so the search is finished
+      // without finding any match.
+      return false;
+    }
+
+    // None of the get methods should be called while inserts are still taking
+    // place.
+    DCHECK(bucket_hash != kPendingHash);
+
+    if ((bucket_hash == hash_code) && key_manager_.scalarKeyCollisionCheck(key, bucket)) {
+      // Match located.
+      return true;
+    }
+  }
+  return false;
+}
+
+template <typename ValueT,
+          bool resizable,
+          bool serializable,
+          bool force_key_copy,
+          bool allow_duplicate_keys>
+bool LinearOpenAddressingHashTable<ValueT, resizable, serializable, force_key_copy, allow_duplicate_keys>
+    ::hasCompositeKey(const std::vector<TypedValue> &key) const {
+  DEBUG_ASSERT(this->key_types_.size() == key.size());
+
+  const std::size_t hash_code = this->AdjustHash(this->hashCompositeKey(key));
+  for (std::size_t bucket_num = hash_code % header_->num_buckets;
+       bucket_num < header_->num_buckets + header_->num_overflow_buckets;
+       ++bucket_num) {
+    const char *bucket = static_cast<const char*>(hash_buckets_) + bucket_num * bucket_size_;
+    const std::size_t bucket_hash
+        = reinterpret_cast<const std::atomic<std::size_t>*>(bucket)->load(std::memory_order_relaxed);
+    if (bucket_hash == kEmptyHash) {
+      // Hit an empty bucket, so the search is finished
+      // without finding any match.
+      return false;
+    }
+
+    // None of the get methods should be called while inserts are still taking
+    // place.
+    DEBUG_ASSERT(bucket_hash != kPendingHash);
+
+    if ((bucket_hash == hash_code) && key_manager_.compositeKeyCollisionCheck(key, bucket)) {
+      // Match located.
+      return true;
+    }
+  }
+  return false;
+}
+
 // TODO(chasseur): Smarter heuristics that are more selective about whether
 // to grow hash buckets, variable-length storage, or both, and to what degree.
 template <typename ValueT,

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a39ad965/storage/SeparateChainingHashTable.hpp
----------------------------------------------------------------------
diff --git a/storage/SeparateChainingHashTable.hpp b/storage/SeparateChainingHashTable.hpp
index c93e783..c096b1b 100644
--- a/storage/SeparateChainingHashTable.hpp
+++ b/storage/SeparateChainingHashTable.hpp
@@ -145,6 +145,9 @@ class SeparateChainingHashTable : public HashTable<ValueT,
                                    const ValueT **value,
                                    std::size_t *entry_num) const override;
 
+  bool hasKey(const TypedValue &key) const override;
+  bool hasCompositeKey(const std::vector<TypedValue> &key) const override;
+
   void resize(const std::size_t extra_buckets,
               const std::size_t extra_variable_storage,
               const std::size_t retry_num = 0) override;
@@ -1054,6 +1057,57 @@ template <typename ValueT,
           bool serializable,
           bool force_key_copy,
           bool allow_duplicate_keys>
+bool SeparateChainingHashTable<ValueT, resizable, serializable, force_key_copy, allow_duplicate_keys>
+    ::hasKey(const TypedValue &key) const {
+  DEBUG_ASSERT(this->key_types_.size() == 1);
+  DEBUG_ASSERT(key.isPlausibleInstanceOf(this->key_types_.front()->getSignature()));
+
+  const std::size_t hash_code = key.getHash();
+  std::size_t bucket_ref = slots_[hash_code % header_->num_slots].load(std::memory_order_relaxed);
+  while (bucket_ref != 0) {
+    DEBUG_ASSERT(bucket_ref != std::numeric_limits<std::size_t>::max());
+    const char *bucket = static_cast<const char*>(buckets_) + (bucket_ref - 1) * bucket_size_;
+    const std::size_t bucket_hash = *reinterpret_cast<const std::size_t*>(
+        bucket + sizeof(std::atomic<std::size_t>));
+    if ((bucket_hash == hash_code) && key_manager_.scalarKeyCollisionCheck(key, bucket)) {
+      // Find a match.
+      return true;
+    }
+    bucket_ref = reinterpret_cast<const std::atomic<std::size_t>*>(bucket)->load(std::memory_order_relaxed);
+  }
+  return false;
+}
+
+template <typename ValueT,
+          bool resizable,
+          bool serializable,
+          bool force_key_copy,
+          bool allow_duplicate_keys>
+bool SeparateChainingHashTable<ValueT, resizable, serializable, force_key_copy, allow_duplicate_keys>
+    ::hasCompositeKey(const std::vector<TypedValue> &key) const {
+  DEBUG_ASSERT(this->key_types_.size() == key.size());
+
+  const std::size_t hash_code = this->hashCompositeKey(key);
+  std::size_t bucket_ref = slots_[hash_code % header_->num_slots].load(std::memory_order_relaxed);
+  while (bucket_ref != 0) {
+    DEBUG_ASSERT(bucket_ref != std::numeric_limits<std::size_t>::max());
+    const char *bucket = static_cast<const char*>(buckets_) + (bucket_ref - 1) * bucket_size_;
+    const std::size_t bucket_hash = *reinterpret_cast<const std::size_t*>(
+        bucket + sizeof(std::atomic<std::size_t>));
+    if ((bucket_hash == hash_code) && key_manager_.compositeKeyCollisionCheck(key, bucket)) {
+      // Find a match.
+      return true;
+    }
+    bucket_ref = reinterpret_cast<const std::atomic<std::size_t>*>(bucket)->load(std::memory_order_relaxed);
+  }
+  return false;
+}
+
+template <typename ValueT,
+          bool resizable,
+          bool serializable,
+          bool force_key_copy,
+          bool allow_duplicate_keys>
 void SeparateChainingHashTable<ValueT, resizable, serializable, force_key_copy, allow_duplicate_keys>
     ::resize(const std::size_t extra_buckets,
              const std::size_t extra_variable_storage,

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a39ad965/storage/SimpleScalarSeparateChainingHashTable.hpp
----------------------------------------------------------------------
diff --git a/storage/SimpleScalarSeparateChainingHashTable.hpp b/storage/SimpleScalarSeparateChainingHashTable.hpp
index b2d894d..eda6c86 100644
--- a/storage/SimpleScalarSeparateChainingHashTable.hpp
+++ b/storage/SimpleScalarSeparateChainingHashTable.hpp
@@ -182,6 +182,12 @@ class SimpleScalarSeparateChainingHashTable : public HashTable<ValueT,
     return getNextEntryForKey(key.front(), hash_code, value, entry_num);
   }
 
+  bool hasKey(const TypedValue &key) const override;
+
+  bool hasCompositeKey(const std::vector<TypedValue> &key) const override {
+    return false;
+  }
+
   void resize(const std::size_t extra_buckets,
               const std::size_t extra_variable_storage,
               const std::size_t retry_num = 0) override;
@@ -772,6 +778,37 @@ template <typename ValueT,
           bool serializable,
           bool force_key_copy,
           bool allow_duplicate_keys>
+bool SimpleScalarSeparateChainingHashTable<ValueT,
+                                           resizable,
+                                           serializable,
+                                           force_key_copy,
+                                           allow_duplicate_keys>
+    ::hasKey(const TypedValue &key) const {
+  DCHECK_EQ(1u, this->key_types_.size());
+  DCHECK(key.isPlausibleInstanceOf(this->key_types_.front()->getSignature()));
+
+  const std::size_t hash_code = key.getHashScalarLiteral();
+  std::size_t bucket_ref = slots_[hash_code % header_->num_slots].load(std::memory_order_relaxed);
+  while (bucket_ref != 0) {
+    DCHECK_NE(bucket_ref, std::numeric_limits<std::size_t>::max());
+
+    const Bucket &bucket = buckets_[bucket_ref - 1];
+    if (bucket.hash == hash_code) {
+      // Match located.
+      return true;
+    }
+    bucket_ref = bucket.next.load(std::memory_order_relaxed);
+  }
+
+  // Reached the end of the chain and didn't find a match.
+  return false;
+}
+
+template <typename ValueT,
+          bool resizable,
+          bool serializable,
+          bool force_key_copy,
+          bool allow_duplicate_keys>
 void SimpleScalarSeparateChainingHashTable<ValueT,
                                            resizable,
                                            serializable,

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/a39ad965/storage/StorageBlock.hpp
----------------------------------------------------------------------
diff --git a/storage/StorageBlock.hpp b/storage/StorageBlock.hpp
index da3bc70..97813e2 100644
--- a/storage/StorageBlock.hpp
+++ b/storage/StorageBlock.hpp
@@ -187,6 +187,17 @@ class StorageBlock : public StorageBlockBase {
   }
 
   /**
+   * @brief Get the flag vector indicating for each IndexSubBlock
+   *        whether it is consistent.
+   *
+   * @return The flag vector indicating for each IndexSubBlock
+   *         whether it is consistent.
+   */
+  const std::vector<bool>& getIndicesConsistent() const {
+    return indices_consistent_;
+  }
+
+  /**
    * @brief Get one of this block's IndexSubBlocks.
    *
    * @param index_id The ID of the IndexSubBlock. This is simply a serial
@@ -201,6 +212,15 @@ class StorageBlock : public StorageBlockBase {
   }
 
   /**
+   * @brief Get the IndexSubBlock vector.
+   *
+   * @return The IndexSubBlock vector.
+   */
+  const PtrVector<IndexSubBlock>& getIndices() const {
+    return indices_;
+  }
+
+  /**
    * @brief Insert a single tuple into this block.
    *
    * @param tuple The tuple to insert.


[16/24] incubator-quickstep git commit: Added hook (not actual code) to BitWeaving. (#169)

Posted by zu...@apache.org.
http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/cbd169e5/parser/preprocessed/SqlParser_gen.hpp
----------------------------------------------------------------------
diff --git a/parser/preprocessed/SqlParser_gen.hpp b/parser/preprocessed/SqlParser_gen.hpp
index 807a39b..e35664f 100644
--- a/parser/preprocessed/SqlParser_gen.hpp
+++ b/parser/preprocessed/SqlParser_gen.hpp
@@ -1,8 +1,8 @@
-/* A Bison parser, made by GNU Bison 3.0.4.  */
+/* A Bison parser, made by GNU Bison 3.0.2.  */
 
 /* Bison interface for Yacc-like parsers in C
 
-   Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
+   Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
 
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
@@ -72,101 +72,102 @@ extern int quickstep_yydebug;
     TOKEN_ASC = 282,
     TOKEN_BIGINT = 283,
     TOKEN_BIT = 284,
-    TOKEN_BLOCKPROPERTIES = 285,
-    TOKEN_BLOCKSAMPLE = 286,
-    TOKEN_BLOOM_FILTER = 287,
-    TOKEN_CSB_TREE = 288,
-    TOKEN_BY = 289,
-    TOKEN_CASE = 290,
-    TOKEN_CHARACTER = 291,
-    TOKEN_CHECK = 292,
-    TOKEN_COLUMN = 293,
-    TOKEN_CONSTRAINT = 294,
-    TOKEN_COPY = 295,
-    TOKEN_CREATE = 296,
-    TOKEN_DATE = 297,
-    TOKEN_DATETIME = 298,
-    TOKEN_DECIMAL = 299,
-    TOKEN_DEFAULT = 300,
-    TOKEN_DELETE = 301,
-    TOKEN_DELIMITER = 302,
-    TOKEN_DESC = 303,
-    TOKEN_DISTINCT = 304,
-    TOKEN_DOUBLE = 305,
-    TOKEN_DROP = 306,
-    TOKEN_ELSE = 307,
-    TOKEN_END = 308,
-    TOKEN_ESCAPE_STRINGS = 309,
-    TOKEN_EXISTS = 310,
-    TOKEN_EXTRACT = 311,
-    TOKEN_FALSE = 312,
-    TOKEN_FIRST = 313,
-    TOKEN_FLOAT = 314,
-    TOKEN_FOREIGN = 315,
-    TOKEN_FROM = 316,
-    TOKEN_FULL = 317,
-    TOKEN_GROUP = 318,
-    TOKEN_HASH = 319,
-    TOKEN_HAVING = 320,
-    TOKEN_IN = 321,
-    TOKEN_INDEX = 322,
-    TOKEN_INNER = 323,
-    TOKEN_INSERT = 324,
-    TOKEN_INTEGER = 325,
-    TOKEN_INTERVAL = 326,
-    TOKEN_INTO = 327,
-    TOKEN_JOIN = 328,
-    TOKEN_KEY = 329,
-    TOKEN_LAST = 330,
-    TOKEN_LEFT = 331,
-    TOKEN_LIMIT = 332,
-    TOKEN_LONG = 333,
-    TOKEN_NULL = 334,
-    TOKEN_NULLS = 335,
-    TOKEN_OFF = 336,
-    TOKEN_ON = 337,
-    TOKEN_ORDER = 338,
-    TOKEN_OUTER = 339,
-    TOKEN_PARTITION = 340,
-    TOKEN_PARTITIONS = 341,
-    TOKEN_PERCENT = 342,
-    TOKEN_PRIMARY = 343,
-    TOKEN_QUIT = 344,
-    TOKEN_RANGE = 345,
-    TOKEN_REAL = 346,
-    TOKEN_REFERENCES = 347,
-    TOKEN_RIGHT = 348,
-    TOKEN_ROW_DELIMITER = 349,
-    TOKEN_SELECT = 350,
-    TOKEN_SET = 351,
-    TOKEN_SMA = 352,
-    TOKEN_SMALLINT = 353,
-    TOKEN_TABLE = 354,
-    TOKEN_THEN = 355,
-    TOKEN_TIME = 356,
-    TOKEN_TIMESTAMP = 357,
-    TOKEN_TRUE = 358,
-    TOKEN_TUPLESAMPLE = 359,
-    TOKEN_UNIQUE = 360,
-    TOKEN_UPDATE = 361,
-    TOKEN_USING = 362,
-    TOKEN_VALUES = 363,
-    TOKEN_VARCHAR = 364,
-    TOKEN_WHEN = 365,
-    TOKEN_WHERE = 366,
-    TOKEN_WITH = 367,
-    TOKEN_YEARMONTH = 368,
-    TOKEN_EOF = 369,
-    TOKEN_LEX_ERROR = 370
+    TOKEN_BITWEAVING = 285,
+    TOKEN_BLOCKPROPERTIES = 286,
+    TOKEN_BLOCKSAMPLE = 287,
+    TOKEN_BLOOM_FILTER = 288,
+    TOKEN_CSB_TREE = 289,
+    TOKEN_BY = 290,
+    TOKEN_CASE = 291,
+    TOKEN_CHARACTER = 292,
+    TOKEN_CHECK = 293,
+    TOKEN_COLUMN = 294,
+    TOKEN_CONSTRAINT = 295,
+    TOKEN_COPY = 296,
+    TOKEN_CREATE = 297,
+    TOKEN_DATE = 298,
+    TOKEN_DATETIME = 299,
+    TOKEN_DECIMAL = 300,
+    TOKEN_DEFAULT = 301,
+    TOKEN_DELETE = 302,
+    TOKEN_DELIMITER = 303,
+    TOKEN_DESC = 304,
+    TOKEN_DISTINCT = 305,
+    TOKEN_DOUBLE = 306,
+    TOKEN_DROP = 307,
+    TOKEN_ELSE = 308,
+    TOKEN_END = 309,
+    TOKEN_ESCAPE_STRINGS = 310,
+    TOKEN_EXISTS = 311,
+    TOKEN_EXTRACT = 312,
+    TOKEN_FALSE = 313,
+    TOKEN_FIRST = 314,
+    TOKEN_FLOAT = 315,
+    TOKEN_FOREIGN = 316,
+    TOKEN_FROM = 317,
+    TOKEN_FULL = 318,
+    TOKEN_GROUP = 319,
+    TOKEN_HASH = 320,
+    TOKEN_HAVING = 321,
+    TOKEN_IN = 322,
+    TOKEN_INDEX = 323,
+    TOKEN_INNER = 324,
+    TOKEN_INSERT = 325,
+    TOKEN_INTEGER = 326,
+    TOKEN_INTERVAL = 327,
+    TOKEN_INTO = 328,
+    TOKEN_JOIN = 329,
+    TOKEN_KEY = 330,
+    TOKEN_LAST = 331,
+    TOKEN_LEFT = 332,
+    TOKEN_LIMIT = 333,
+    TOKEN_LONG = 334,
+    TOKEN_NULL = 335,
+    TOKEN_NULLS = 336,
+    TOKEN_OFF = 337,
+    TOKEN_ON = 338,
+    TOKEN_ORDER = 339,
+    TOKEN_OUTER = 340,
+    TOKEN_PARTITION = 341,
+    TOKEN_PARTITIONS = 342,
+    TOKEN_PERCENT = 343,
+    TOKEN_PRIMARY = 344,
+    TOKEN_QUIT = 345,
+    TOKEN_RANGE = 346,
+    TOKEN_REAL = 347,
+    TOKEN_REFERENCES = 348,
+    TOKEN_RIGHT = 349,
+    TOKEN_ROW_DELIMITER = 350,
+    TOKEN_SELECT = 351,
+    TOKEN_SET = 352,
+    TOKEN_SMA = 353,
+    TOKEN_SMALLINT = 354,
+    TOKEN_TABLE = 355,
+    TOKEN_THEN = 356,
+    TOKEN_TIME = 357,
+    TOKEN_TIMESTAMP = 358,
+    TOKEN_TRUE = 359,
+    TOKEN_TUPLESAMPLE = 360,
+    TOKEN_UNIQUE = 361,
+    TOKEN_UPDATE = 362,
+    TOKEN_USING = 363,
+    TOKEN_VALUES = 364,
+    TOKEN_VARCHAR = 365,
+    TOKEN_WHEN = 366,
+    TOKEN_WHERE = 367,
+    TOKEN_WITH = 368,
+    TOKEN_YEARMONTH = 369,
+    TOKEN_EOF = 370,
+    TOKEN_LEX_ERROR = 371
   };
 #endif
 
 /* Value type.  */
 #if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
-
+typedef union YYSTYPE YYSTYPE;
 union YYSTYPE
 {
-#line 117 "../SqlParser.ypp" /* yacc.c:1915  */
+#line 117 "../SqlParser.ypp" /* yacc.c:1909  */
 
   quickstep::ParseString *string_value_;
 
@@ -256,10 +257,8 @@ union YYSTYPE
   quickstep::PtrVector<quickstep::ParseSubqueryTableReference> *with_list_;
   quickstep::ParseSubqueryTableReference *with_list_element_;
 
-#line 260 "SqlParser_gen.hpp" /* yacc.c:1915  */
+#line 261 "SqlParser_gen.hpp" /* yacc.c:1909  */
 };
-
-typedef union YYSTYPE YYSTYPE;
 # define YYSTYPE_IS_TRIVIAL 1
 # define YYSTYPE_IS_DECLARED 1
 #endif

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/cbd169e5/parser/tests/Index.test
----------------------------------------------------------------------
diff --git a/parser/tests/Index.test b/parser/tests/Index.test
index b5184bd..605768b 100644
--- a/parser/tests/Index.test
+++ b/parser/tests/Index.test
@@ -57,3 +57,12 @@ CreateIndexStatement[index_name=bloomIndex,relation_name=test,
 CREATE INDEX csbIndex ON test USING CSBTREE
 --
 CreateIndexStatement[index_name=csbIndex,relation_name=test,index_type=cs_b_tree]
+==
+# Bitweaving is supported on builds where it was included as a submodule. The
+# parser should create code to change the catalog, but on Block creation, no
+# index will be created.
+CREATE INDEX bwIndex ON test(int_col) USING bitweaving;
+--
+CreateIndexStatement[index_name=bwIndex,relation_name=test,index_type=bitweaving]
++-attribute_list=
+  +-AttributeReference[attribute_name=int_col]

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/cbd169e5/query_optimizer/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/query_optimizer/CMakeLists.txt b/query_optimizer/CMakeLists.txt
index 60319d4..44c8750 100644
--- a/query_optimizer/CMakeLists.txt
+++ b/query_optimizer/CMakeLists.txt
@@ -118,6 +118,7 @@ target_link_libraries(quickstep_queryoptimizer_ExecutionGenerator
                       quickstep_storage_InsertDestination_proto
                       quickstep_storage_StorageBlockLayout
                       quickstep_storage_StorageBlockLayout_proto
+                      quickstep_storage_SubBlockTypeRegistry
                       quickstep_types_Type
                       quickstep_types_Type_proto
                       quickstep_types_TypedValue

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/cbd169e5/query_optimizer/ExecutionGenerator.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/ExecutionGenerator.cpp b/query_optimizer/ExecutionGenerator.cpp
index 43825b9..38ab09e 100644
--- a/query_optimizer/ExecutionGenerator.cpp
+++ b/query_optimizer/ExecutionGenerator.cpp
@@ -99,6 +99,7 @@
 #include "storage/InsertDestination.pb.h"
 #include "storage/StorageBlockLayout.hpp"
 #include "storage/StorageBlockLayout.pb.h"
+#include "storage/SubBlockTypeRegistry.hpp"
 #include "types/Type.hpp"
 #include "types/Type.pb.h"
 #include "types/TypedValue.hpp"
@@ -870,7 +871,7 @@ void ExecutionGenerator::convertCreateIndex(
     THROW_SQL_ERROR() << "The relation " << input_relation->getName()
         << " already defines this index on the given attribute(s).";
   }
-  if (!index_description.IsInitialized()) {
+  if (!SubBlockTypeRegistry::IndexDescriptionIsValid(*input_relation, index_description)) {
     // Check if the given index description is valid.
     THROW_SQL_ERROR() << "The index with given properties cannot be created.";
   }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/cbd169e5/storage/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/storage/CMakeLists.txt b/storage/CMakeLists.txt
index 37cfc3d..11c2819 100644
--- a/storage/CMakeLists.txt
+++ b/storage/CMakeLists.txt
@@ -138,6 +138,19 @@ add_library(quickstep_storage_BasicColumnStoreValueAccessor
             ../empty_src.cpp
             BasicColumnStoreValueAccessor.hpp)
 add_library(quickstep_storage_BloomFilterIndexSubBlock BloomFilterIndexSubBlock.cpp BloomFilterIndexSubBlock.hpp)
+# CMAKE_VALIDATE_IGNORE_BEGIN
+if(QUICKSTEP_HAVE_BITWEAVING)
+  add_library(quickstep_storage_BitWeavingIndexSubBlock
+              bitweaving/BitWeavingIndexSubBlock.cpp
+              bitweaving/BitWeavingIndexSubBlock.hpp)
+  add_library(quickstep_storage_BitWeavingHIndexSubBlock
+              bitweaving/BitWeavingHIndexSubBlock.cpp
+              bitweaving/BitWeavingHIndexSubBlock.hpp)
+  add_library(quickstep_storage_BitWeavingVIndexSubBlock
+              bitweaving/BitWeavingVIndexSubBlock.cpp
+              bitweaving/BitWeavingVIndexSubBlock.hpp)
+endif()
+# CMAKE_VALIDATE_IGNORE_END
 add_library(quickstep_storage_ColumnStoreUtil ColumnStoreUtil.cpp ColumnStoreUtil.hpp)
 add_library(quickstep_storage_CompressedBlockBuilder CompressedBlockBuilder.cpp CompressedBlockBuilder.hpp)
 add_library(quickstep_storage_CompressedColumnStoreTupleStorageSubBlock
@@ -316,6 +329,74 @@ target_link_libraries(quickstep_storage_BloomFilterIndexSubBlock
                       quickstep_types_operations_comparisons_ComparisonID
                       quickstep_utility_BloomFilter
                       quickstep_utility_Macros)
+# CMAKE_VALIDATE_IGNORE_BEGIN
+if(QUICKSTEP_HAVE_BITWEAVING)
+  target_link_libraries(quickstep_storage_BitWeavingHIndexSubBlock
+                        glog
+                        quickstep_catalog_CatalogTypedefs
+                        quickstep_compression_CompressionDictionary
+                        quickstep_compression_CompressionDictionaryBuilder
+                        quickstep_expressions_predicate_ComparisonPredicate
+                        quickstep_expressions_predicate_PredicateCost
+                        quickstep_storage_BitWeavingIndexSubBlock
+                        quickstep_storage_CompressedTupleStorageSubBlock
+                        quickstep_storage_StorageBlockInfo
+                        quickstep_storage_StorageBlockLayout_proto
+                        quickstep_storage_SubBlockTypeRegistry
+                        quickstep_storage_SubBlockTypeRegistryMacros
+                        quickstep_storage_TupleStorageSubBlock
+                        quickstep_types_TypedValue
+                        quickstep_types_operations_comparisons_ComparisonID
+                        quickstep_utility_Macros)
+  target_link_libraries(quickstep_storage_BitWeavingIndexSubBlock
+                        glog
+                        quickstep_catalog_CatalogAttribute
+                        quickstep_catalog_CatalogRelationSchema
+                        quickstep_catalog_CatalogTypedefs
+                        quickstep_compression_CompressionDictionary
+                        quickstep_compression_CompressionDictionaryBuilder
+                        quickstep_expressions_predicate_ComparisonPredicate
+                        quickstep_expressions_predicate_Predicate
+                        quickstep_expressions_scalar_Scalar
+                        quickstep_expressions_scalar_ScalarAttribute
+                        quickstep_storage_CompressedStoreUtil
+                        quickstep_storage_CompressedTupleStorageSubBlock
+                        quickstep_storage_IndexSubBlock
+                        quickstep_storage_StorageBlockInfo
+                        quickstep_storage_StorageBlockLayout_proto
+                        quickstep_storage_StorageConstants
+                        quickstep_storage_StorageErrors
+                        quickstep_storage_TupleIdSequence
+                        quickstep_storage_TupleStorageSubBlock
+                        quickstep_storage_ValueAccessor
+                        quickstep_storage_ValueAccessorUtil
+                        quickstep_types_Type
+                        quickstep_types_TypedValue
+                        quickstep_types_operations_comparisons_ComparisonID
+                        quickstep_utility_BitManipulation
+                        quickstep_utility_Macros)
+  target_link_libraries(quickstep_storage_BitWeavingVIndexSubBlock
+                        glog
+                        quickstep_catalog_CatalogTypedefs
+                        quickstep_compression_CompressionDictionary
+                        quickstep_compression_CompressionDictionaryBuilder
+                        quickstep_expressions_predicate_ComparisonPredicate
+                        quickstep_expressions_predicate_PredicateCost
+                        quickstep_storage_BitWeavingIndexSubBlock
+                        quickstep_storage_CompressedTupleStorageSubBlock
+                        quickstep_storage_StorageBlockInfo
+                        quickstep_storage_StorageBlockLayout_proto
+                        quickstep_storage_StorageConstants
+                        quickstep_storage_SubBlockTypeRegistry
+                        quickstep_storage_SubBlockTypeRegistryMacros
+                        quickstep_storage_TupleStorageSubBlock
+                        quickstep_storage_ValueAccessor
+                        quickstep_storage_ValueAccessorUtil
+                        quickstep_types_TypedValue
+                        quickstep_types_operations_comparisons_ComparisonID
+                        quickstep_utility_Macros)
+endif()
+# CMAKE_VALIDATE_IGNORE_END
 target_link_libraries(quickstep_storage_ColumnStoreUtil
                       quickstep_catalog_CatalogAttribute
                       quickstep_catalog_CatalogRelationSchema
@@ -795,6 +876,14 @@ target_link_libraries(quickstep_storage_StorageBlock
                       quickstep_types_operations_comparisons_ComparisonUtil
                       quickstep_utility_Macros
                       quickstep_utility_PtrVector)
+# CMAKE_VALIDATE_IGNORE_BEGIN
+if(QUICKSTEP_HAVE_BITWEAVING)
+  target_link_libraries(quickstep_storage_StorageBlock
+                        quickstep_storage_BitWeavingHIndexSubBlock
+                        quickstep_storage_BitWeavingIndexSubBlock
+                        quickstep_storage_BitWeavingVIndexSubBlock)
+endif()
+# CMAKE_VALIDATE_IGNORE_END
 target_link_libraries(quickstep_storage_StorageBlockBase
                       glog
                       quickstep_storage_StorageBlockInfo
@@ -956,6 +1045,14 @@ elseif (QUICKSTEP_HAVE_FILE_MANAGER_WINDOWS)
   target_link_libraries(quickstep_storage
                         quickstep_storage_FileManagerWindows)
 endif()
+# CMAKE_VALIDATE_IGNORE_BEGIN
+if(QUICKSTEP_HAVE_BITWEAVING)
+  target_link_libraries(quickstep_storage
+                        quickstep_storage_BitWeavingHIndexSubBlock
+                        quickstep_storage_BitWeavingIndexSubBlock
+                        quickstep_storage_BitWeavingVIndexSubBlock)
+endif()
+# CMAKE_VALIDATE_IGNORE_END
 
 # Tests:
 include(CheckTypeSize)
@@ -1094,6 +1191,49 @@ target_link_libraries(BloomFilterIndexSubBlock_unittest
                       ${LIBS})
 add_test(BloomFilterIndexSubBlock_unittest BloomFilterIndexSubBlock_unittest)
 
+if(QUICKSTEP_HAVE_BITWEAVING)
+  add_executable(BitWeavingIndexSubBlock_unittest 
+                 "${CMAKE_CURRENT_SOURCE_DIR}/bitweaving/tests/BitWeavingIndexSubBlock_unittest.cpp")
+  target_link_libraries(BitWeavingIndexSubBlock_unittest
+                        glog
+                        gtest
+                        gtest_main
+                        quickstep_catalog_CatalogAttribute
+                        quickstep_catalog_CatalogRelation
+                        quickstep_catalog_CatalogTypedefs
+                        quickstep_expressions_predicate_ComparisonPredicate
+                        quickstep_expressions_scalar_Scalar
+                        quickstep_expressions_scalar_ScalarAttribute
+                        quickstep_expressions_scalar_ScalarLiteral
+                        quickstep_storage_BitWeavingHIndexSubBlock
+                        quickstep_storage_BitWeavingIndexSubBlock
+                        quickstep_storage_BitWeavingVIndexSubBlock
+                        quickstep_storage_StorageBlock
+                        quickstep_storage_StorageBlockInfo
+                        quickstep_storage_StorageBlockLayout_proto
+                        quickstep_storage_StorageErrors
+                        quickstep_storage_StorageManager
+                        quickstep_storage_TupleIdSequence
+                        quickstep_storage_TupleStorageSubBlock
+                        quickstep_types_CharType
+                        quickstep_types_FloatType
+                        quickstep_types_LongType
+                        quickstep_types_Type
+                        quickstep_types_TypeFactory
+                        quickstep_types_TypeID
+                        quickstep_types_TypedValue
+                        quickstep_types_VarCharType
+                        quickstep_types_containers_Tuple
+                        quickstep_types_operations_comparisons_Comparison
+                        quickstep_types_operations_comparisons_ComparisonFactory
+                        quickstep_types_operations_comparisons_ComparisonID
+                        quickstep_types_operations_comparisons_ComparisonUtil
+                        quickstep_utility_Macros
+                        quickstep_utility_ScopedBuffer
+                        ${LIBS})
+  add_test(BitWeavingIndexSubBlock_unittest BitWeavingIndexSubBlock_unittest)
+endif()
+
 add_executable(CompressedColumnStoreTupleStorageSubBlock_unittest "${CMAKE_CURRENT_SOURCE_DIR}/tests/CompressedColumnStoreTupleStorageSubBlock_unittest.cpp")
 target_link_libraries(CompressedColumnStoreTupleStorageSubBlock_unittest
                       gtest

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/cbd169e5/storage/IndexSubBlockDescriptionFactory.hpp
----------------------------------------------------------------------
diff --git a/storage/IndexSubBlockDescriptionFactory.hpp b/storage/IndexSubBlockDescriptionFactory.hpp
index a9992ef..5e7f5a1 100644
--- a/storage/IndexSubBlockDescriptionFactory.hpp
+++ b/storage/IndexSubBlockDescriptionFactory.hpp
@@ -28,7 +28,7 @@ namespace quickstep {
  */
 
 /**
- * @brief A class that describes factories of IndexSubBlockDescriptionFactory
+ * @brief A class that describes factories of IndexSubBlockDescriptionFactory.
  */
 class IndexSubBlockDescriptionFactory {
  public:
@@ -51,6 +51,13 @@ class IndexSubBlockDescriptionFactory {
     // Different types of indexes can specify their own validation checks here.
     // Currently these are trivial for CSBTree and SMAIndex.
     switch (index_description.sub_block_type()) {
+      case IndexSubBlockDescription_IndexSubBlockType_BITWEAVING_H:  // Fall through.
+      case IndexSubBlockDescription_IndexSubBlockType_BITWEAVING_V:
+        // Only singular keys are allowed.
+        if (index_description.indexed_attribute_ids_size() == 1) {
+          return true;
+        }
+        return false;
       case IndexSubBlockDescription_IndexSubBlockType_CSB_TREE:
         return true;
       case IndexSubBlockDescription_IndexSubBlockType_SMA:

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/cbd169e5/storage/StorageBlock.cpp
----------------------------------------------------------------------
diff --git a/storage/StorageBlock.cpp b/storage/StorageBlock.cpp
index fba4d60..476a130 100644
--- a/storage/StorageBlock.cpp
+++ b/storage/StorageBlock.cpp
@@ -63,6 +63,12 @@
 
 #include "glog/logging.h"
 
+#ifdef QUICKSTEP_HAVE_BITWEAVING
+#include "storage/bitweaving/BitWeavingIndexSubBlock.hpp"
+#include "storage/bitweaving/BitWeavingHIndexSubBlock.hpp"
+#include "storage/bitweaving/BitWeavingVIndexSubBlock.hpp"
+#endif
+
 using std::make_pair;
 using std::pair;
 using std::size_t;
@@ -172,8 +178,7 @@ StorageBlock::StorageBlock(const CatalogRelationSchema &relation,
        ++index_num) {
     indices_.push_back(CreateIndexSubBlock(*tuple_store_,
                                            block_header_.layout().index_description(index_num),
-                                           new_block,
-                                           sub_block_address,
+                                           new_block, sub_block_address,
                                            block_header_.index_size(index_num)));
     sub_block_address += block_header_.index_size(index_num);
     if (!indices_.back().supportsAdHocAdd()) {
@@ -1044,6 +1049,25 @@ IndexSubBlock* StorageBlock::CreateIndexSubBlock(
                                   new_block,
                                   sub_block_memory,
                                   sub_block_memory_size);
+#ifdef QUICKSTEP_HAVE_BITWEAVING
+    case IndexSubBlockDescription::BITWEAVING_V:
+      return new BitWeavingVIndexSubBlock(tuple_store,
+                                          description,
+                                          new_block,
+                                          sub_block_memory,
+                                          sub_block_memory_size);
+    case IndexSubBlockDescription::BITWEAVING_H:
+      return new BitWeavingHIndexSubBlock(tuple_store,
+                                          description,
+                                          new_block,
+                                          sub_block_memory,
+                                          sub_block_memory_size);
+#else
+    case IndexSubBlockDescription::BITWEAVING_V:  // Fall through.
+    case IndexSubBlockDescription::BITWEAVING_H:
+      LOG(FATAL) << "Attempted to create a block with a bitweaving index "
+                 << "but Quickstep was not compiled with bitweaving.";
+#endif
     default:
       if (new_block) {
         FATAL_ERROR("A StorageBlockLayout provided an unknown IndexBlockType.");

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/cbd169e5/storage/StorageBlockInfo.hpp
----------------------------------------------------------------------
diff --git a/storage/StorageBlockInfo.hpp b/storage/StorageBlockInfo.hpp
index ecda854..c18a8a2 100644
--- a/storage/StorageBlockInfo.hpp
+++ b/storage/StorageBlockInfo.hpp
@@ -137,6 +137,8 @@ enum IndexSubBlockType {
   kCSBTree = 0,
   kSMA,
   kBloomFilter,
+  kBitWeavingV,
+  kBitWeavingH,
   kNumIndexSubBlockTypes  // Not an actual IndexSubBlockType, exists for counting purposes.
 };
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/cbd169e5/storage/StorageBlockLayout.proto
----------------------------------------------------------------------
diff --git a/storage/StorageBlockLayout.proto b/storage/StorageBlockLayout.proto
index 571c700..9e13fbe 100644
--- a/storage/StorageBlockLayout.proto
+++ b/storage/StorageBlockLayout.proto
@@ -65,6 +65,8 @@ message IndexSubBlockDescription {
     CSB_TREE = 0;
     SMA = 1;
     BLOOM_FILTER = 2;
+    BITWEAVING_H = 3;
+    BITWEAVING_V = 4;    
   }
 
   required IndexSubBlockType sub_block_type = 1;

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/cbd169e5/storage/StorageConfig.h.in
----------------------------------------------------------------------
diff --git a/storage/StorageConfig.h.in b/storage/StorageConfig.h.in
index 2344bba..eee1be9 100644
--- a/storage/StorageConfig.h.in
+++ b/storage/StorageConfig.h.in
@@ -15,6 +15,7 @@
  *   limitations under the License.
  **/
 
+#cmakedefine QUICKSTEP_HAVE_BITWEAVING
 #cmakedefine QUICKSTEP_HAVE_FILE_MANAGER_POSIX
 #cmakedefine QUICKSTEP_HAVE_FILE_MANAGER_WINDOWS
 #cmakedefine QUICKSTEP_HAVE_FILE_MANAGER_HDFS

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/cbd169e5/storage/SubBlockTypeRegistry.cpp
----------------------------------------------------------------------
diff --git a/storage/SubBlockTypeRegistry.cpp b/storage/SubBlockTypeRegistry.cpp
index 35ee502..f519c73 100644
--- a/storage/SubBlockTypeRegistry.cpp
+++ b/storage/SubBlockTypeRegistry.cpp
@@ -82,6 +82,28 @@ bool SubBlockTypeRegistry::LayoutDescriptionIsValid(
   return true;
 }
 
+bool SubBlockTypeRegistry::IndexDescriptionIsValid(
+      const CatalogRelationSchema &relation,
+      const IndexSubBlockDescription &description) {
+  if (!description.IsInitialized()) {
+    return false;
+  }
+
+  std::unordered_map<IndexTypeIntegral,
+                     IndexDescriptionIsValidFunction>::const_iterator
+      index_it = Instance()->index_description_is_valid_functions_.find(
+          static_cast<IndexTypeIntegral>(description.sub_block_type()));
+  // No validity function was registered.
+  if (index_it == Instance()->index_description_is_valid_functions_.end()) {
+    return false;
+  }
+
+  if (!(*index_it->second)(relation, description)) {
+    return false;
+  }
+  return true;
+}
+
 std::size_t SubBlockTypeRegistry::EstimateBytesPerTupleForTupleStore(
     const CatalogRelationSchema &relation,
     const TupleStorageSubBlockDescription &description) {

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/cbd169e5/storage/SubBlockTypeRegistry.hpp
----------------------------------------------------------------------
diff --git a/storage/SubBlockTypeRegistry.hpp b/storage/SubBlockTypeRegistry.hpp
index a223e7c..e930fb4 100644
--- a/storage/SubBlockTypeRegistry.hpp
+++ b/storage/SubBlockTypeRegistry.hpp
@@ -142,6 +142,10 @@ class SubBlockTypeRegistry {
       const CatalogRelationSchema &relation,
       const StorageBlockLayoutDescription &description);
 
+  static bool IndexDescriptionIsValid(
+      const CatalogRelationSchema &relation,
+      const IndexSubBlockDescription &description);
+
   static std::size_t EstimateBytesPerTupleForTupleStore(
       const CatalogRelationSchema &relation,
       const TupleStorageSubBlockDescription &description);

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/cbd169e5/validate_cmakelists.py
----------------------------------------------------------------------
diff --git a/validate_cmakelists.py b/validate_cmakelists.py
index a064a1c..c7b5883 100755
--- a/validate_cmakelists.py
+++ b/validate_cmakelists.py
@@ -42,12 +42,16 @@ EXCLUDED_TOP_LEVEL_DIRS = ["build", "third_party"]
 IGNORED_DEPENDENCIES = frozenset(
     ["quickstep_threading_WinThreadsAPI",
      "quickstep_utility_textbasedtest_TextBasedTest",
-     "quickstep_utility_textbasedtest_TextBasedTestDriver"])
+     "quickstep_utility_textbasedtest_TextBasedTestDriver",
+     "quickstep_storage_bitweaving_BitWeavingHIndexSubBlock",
+     "quickstep_storage_bitweaving_BitWeavingIndexSubBlock",
+     "quickstep_storage_bitweaving_BitWeavingVIndexSubBlock"])
 
 # States when scanning a CMakeLists.txt file.
 CMAKE_SCANNING_NONE = 0
 CMAKE_SCANNING_LIBRARY = 1
 CMAKE_SCANNING_TARGET_LINK_LIBRARIES = 2
+CMAKE_SCANNING_IGNORE = 3
 
 def convert_path_to_targetname(include_path):
     """Convert an included header file's path to a quickstep library target in
@@ -315,10 +319,26 @@ def process_cmakelists_file(cmakelists_filename, qs_module_dirs):
     skipped_targets = set()
     generated_targets = set()
     scan_state = CMAKE_SCANNING_NONE
+    previous_state = CMAKE_SCANNING_NONE
     stitched_string = ""
     with open(cmakelists_filename, "r") as cmakelists_file:
         for line in cmakelists_file:
-            if scan_state == CMAKE_SCANNING_NONE:
+            if ("CMAKE_VALIDATE_IGNORE_BEGIN" in line and
+                scan_state != CMAKE_SCANNING_IGNORE):
+                previous_state = scan_state
+                scan_state = CMAKE_SCANNING_IGNORE
+                continue
+
+            if scan_state == CMAKE_SCANNING_IGNORE:
+                if "CMAKE_VALIDATE_IGNORE_END" in line:
+                    scan_state = previous_state
+                elif "CMAKE_VALIDATE_IGNORE_BEGIN" in line:
+                    print "Nested IGNORE_BEGIN directives found in: "\
+                        + cmakelists_filename + ", exiting"
+                    exit(-1)
+                else:
+                    continue
+            elif scan_state == CMAKE_SCANNING_NONE:
                 add_library_pos = line.find("add_library(")
                 if add_library_pos != -1:
                     scan_state = CMAKE_SCANNING_LIBRARY


[15/24] incubator-quickstep git commit: Introduced QueryManager and its test (#152)

Posted by zu...@apache.org.
Introduced QueryManager and its test (#152)

Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/d3725840
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/d3725840
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/d3725840

Branch: refs/heads/master
Commit: d372584096651be14721ab1ffe1696dfdb70382b
Parents: 0fd8c03
Author: Harshad Deshmukh <d....@gmail.com>
Authored: Fri Apr 15 17:36:15 2016 -0500
Committer: Zuyu ZHANG <zu...@users.noreply.github.com>
Committed: Fri Apr 15 17:36:15 2016 -0500

----------------------------------------------------------------------
 query_execution/CMakeLists.txt                  |  58 +-
 query_execution/Foreman.cpp                     |   4 +-
 query_execution/QueryManager.cpp                | 469 ++++++++++
 query_execution/QueryManager.hpp                | 371 ++++++++
 query_execution/WorkOrdersContainer.hpp         |   4 +-
 query_execution/WorkerMessage.hpp               |  12 +-
 query_execution/tests/QueryManager_unittest.cpp | 933 +++++++++++++++++++
 storage/InsertDestination.hpp                   |   1 +
 8 files changed, 1842 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d3725840/query_execution/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/query_execution/CMakeLists.txt b/query_execution/CMakeLists.txt
index b682618..5887237 100644
--- a/query_execution/CMakeLists.txt
+++ b/query_execution/CMakeLists.txt
@@ -29,9 +29,10 @@ add_library(quickstep_queryexecution_QueryContext_proto
 add_library(quickstep_queryexecution_QueryExecutionMessages_proto
             ${queryexecution_QueryExecutionMessages_proto_srcs}
             ${queryexecution_QueryExecutionMessages_proto_hdrs})
-add_library(quickstep_queryexecution_QueryExecutionState ../empty_src.cpp QueryExecutionState.hpp) 
+add_library(quickstep_queryexecution_QueryExecutionState ../empty_src.cpp QueryExecutionState.hpp)
 add_library(quickstep_queryexecution_QueryExecutionTypedefs ../empty_src.cpp QueryExecutionTypedefs.hpp)
 add_library(quickstep_queryexecution_QueryExecutionUtil ../empty_src.cpp QueryExecutionUtil.hpp)
+add_library(quickstep_queryexecution_QueryManager QueryManager.cpp QueryManager.hpp)
 add_library(quickstep_queryexecution_WorkOrdersContainer WorkOrdersContainer.cpp WorkOrdersContainer.hpp)
 add_library(quickstep_queryexecution_Worker Worker.cpp Worker.hpp)
 add_library(quickstep_queryexecution_WorkerDirectory ../empty_src.cpp WorkerDirectory.hpp)
@@ -112,6 +113,26 @@ target_link_libraries(quickstep_queryexecution_QueryExecutionUtil
                       quickstep_queryexecution_QueryExecutionTypedefs
                       quickstep_utility_Macros
                       tmb)
+target_link_libraries(quickstep_queryexecution_QueryManager
+                      quickstep_catalog_CatalogDatabase
+                      quickstep_catalog_CatalogRelation
+                      quickstep_catalog_CatalogTypedefs
+                      quickstep_catalog_PartitionScheme
+                      quickstep_queryexecution_QueryContext
+                      quickstep_queryexecution_QueryExecutionMessages_proto
+                      quickstep_queryexecution_QueryExecutionState
+                      quickstep_queryexecution_QueryExecutionTypedefs
+                      quickstep_queryexecution_WorkOrdersContainer
+                      quickstep_queryexecution_WorkerMessage
+                      quickstep_queryoptimizer_QueryHandle
+                      quickstep_relationaloperators_RebuildWorkOrder
+                      quickstep_relationaloperators_RelationalOperator
+                      quickstep_relationaloperators_WorkOrder
+                      quickstep_storage_StorageBlock
+                      quickstep_storage_StorageBlockInfo
+                      quickstep_utility_DAG
+                      quickstep_utility_Macros
+                      tmb)
 target_link_libraries(quickstep_queryexecution_WorkOrdersContainer
                       glog
                       quickstep_relationaloperators_WorkOrder
@@ -147,6 +168,7 @@ target_link_libraries(quickstep_queryexecution
                       quickstep_queryexecution_QueryExecutionState
                       quickstep_queryexecution_QueryExecutionTypedefs
                       quickstep_queryexecution_QueryExecutionUtil
+                      quickstep_queryexecution_QueryManager
                       quickstep_queryexecution_WorkOrdersContainer
                       quickstep_queryexecution_Worker
                       quickstep_queryexecution_WorkerDirectory
@@ -154,7 +176,7 @@ target_link_libraries(quickstep_queryexecution
                       quickstep_queryexecution_WorkerSelectionPolicy)
 # Tests:
 add_executable(Foreman_unittest
-               "${CMAKE_CURRENT_SOURCE_DIR}/tests/Foreman_unittest.cpp")
+  "${CMAKE_CURRENT_SOURCE_DIR}/tests/Foreman_unittest.cpp")
 target_link_libraries(Foreman_unittest
                       glog
                       gtest
@@ -183,6 +205,38 @@ target_link_libraries(Foreman_unittest
                       tmb)
 add_test(Foreman_unittest Foreman_unittest)
 
+add_executable(QueryManager_unittest
+  "${CMAKE_CURRENT_SOURCE_DIR}/tests/QueryManager_unittest.cpp")
+target_link_libraries(QueryManager_unittest
+                      glog
+                      gtest
+                      gtest_main
+                      quickstep_catalog_CatalogDatabase
+                      quickstep_catalog_CatalogRelation
+                      quickstep_catalog_CatalogTypedefs
+                      quickstep_queryexecution_QueryContext
+                      quickstep_queryexecution_QueryContext_proto
+                      quickstep_queryexecution_QueryExecutionMessages_proto
+                      quickstep_queryexecution_QueryExecutionState
+                      quickstep_queryexecution_QueryExecutionTypedefs
+                      quickstep_queryexecution_QueryManager
+                      quickstep_queryexecution_WorkOrdersContainer
+                      quickstep_queryexecution_WorkerDirectory
+                      quickstep_queryexecution_WorkerMessage
+                      quickstep_queryoptimizer_QueryHandle
+                      quickstep_queryoptimizer_QueryPlan
+                      quickstep_relationaloperators_RelationalOperator
+                      quickstep_relationaloperators_WorkOrder
+                      quickstep_storage_InsertDestination
+                      quickstep_storage_InsertDestination_proto
+                      quickstep_storage_StorageBlock
+                      quickstep_storage_StorageBlockInfo
+                      quickstep_storage_StorageManager
+                      quickstep_utility_DAG
+                      quickstep_utility_Macros
+                      tmb)
+add_test(QueryManager_unittest QueryManager_unittest)
+
 add_executable(WorkOrdersContainer_unittest
                "${CMAKE_CURRENT_SOURCE_DIR}/tests/WorkOrdersContainer_unittest.cpp")
 target_link_libraries(WorkOrdersContainer_unittest

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d3725840/query_execution/Foreman.cpp
----------------------------------------------------------------------
diff --git a/query_execution/Foreman.cpp b/query_execution/Foreman.cpp
index 2b2581a..304c429 100644
--- a/query_execution/Foreman.cpp
+++ b/query_execution/Foreman.cpp
@@ -371,9 +371,9 @@ WorkerMessage* Foreman::getNextWorkerMessage(
 void Foreman::sendWorkerMessage(const std::size_t worker_thread_index,
                                 const WorkerMessage &message) {
   message_type_id type;
-  if (message.getType() == WorkerMessage::kRebuildWorkOrder) {
+  if (message.getType() == WorkerMessage::WorkerMessageType::kRebuildWorkOrder) {
     type = kRebuildWorkOrderMessage;
-  } else if (message.getType() == WorkerMessage::kWorkOrder) {
+  } else if (message.getType() == WorkerMessage::WorkerMessageType::kWorkOrder) {
     type = kWorkOrderMessage;
   } else {
     FATAL_ERROR("Invalid WorkerMessageType");

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d3725840/query_execution/QueryManager.cpp
----------------------------------------------------------------------
diff --git a/query_execution/QueryManager.cpp b/query_execution/QueryManager.cpp
new file mode 100644
index 0000000..02c5d4c
--- /dev/null
+++ b/query_execution/QueryManager.cpp
@@ -0,0 +1,469 @@
+/**
+ *   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.
+ **/
+
+#include "query_execution/QueryManager.hpp"
+
+#include <cstddef>
+#include <memory>
+#include <utility>
+#include <vector>
+
+#include "catalog/CatalogDatabase.hpp"
+#include "catalog/CatalogRelation.hpp"
+#include "catalog/CatalogTypedefs.hpp"
+#include "catalog/PartitionScheme.hpp"
+#include "query_execution/QueryExecutionMessages.pb.h"
+#include "query_execution/QueryExecutionTypedefs.hpp"
+#include "query_execution/WorkerMessage.hpp"
+#include "query_optimizer/QueryHandle.hpp"
+#include "relational_operators/RebuildWorkOrder.hpp"
+#include "relational_operators/WorkOrder.hpp"
+#include "storage/StorageBlock.hpp"
+#include "storage/StorageBlockInfo.hpp"
+
+#include "glog/logging.h"
+
+using std::pair;
+
+namespace quickstep {
+class CatalogDatabaseLite;
+class StorageManager;
+}
+
+namespace quickstep {
+
+QueryManager::QueryManager(const tmb::client_id foreman_client_id,
+                           const std::size_t num_numa_nodes,
+                           QueryHandle *query_handle,
+                           CatalogDatabaseLite *catalog_database,
+                           StorageManager *storage_manager,
+                           tmb::MessageBus *bus)
+      : foreman_client_id_(foreman_client_id),
+        query_id_(DCHECK_NOTNULL(query_handle)->query_id()),
+        catalog_database_(DCHECK_NOTNULL(catalog_database)),
+        storage_manager_(DCHECK_NOTNULL(storage_manager)),
+        bus_(DCHECK_NOTNULL(bus)) {
+  DCHECK(query_handle->getQueryPlanMutable() != nullptr);
+  query_dag_ = query_handle->getQueryPlanMutable()->getQueryPlanDAGMutable();
+  DCHECK(query_dag_ != nullptr);
+
+  const dag_node_index num_operators_in_dag = query_dag_->size();
+
+  output_consumers_.resize(num_operators_in_dag);
+  blocking_dependencies_.resize(num_operators_in_dag);
+
+  query_exec_state_.reset(new QueryExecutionState(num_operators_in_dag));
+  workorders_container_.reset(
+      new WorkOrdersContainer(num_operators_in_dag, num_numa_nodes));
+
+  query_context_.reset(new QueryContext(query_handle->getQueryContextProto(),
+                                        *catalog_database_,
+                                        storage_manager_,
+                                        foreman_client_id_,
+                                        bus_));
+
+  for (dag_node_index node_index = 0;
+       node_index < num_operators_in_dag;
+       ++node_index) {
+    const QueryContext::insert_destination_id insert_destination_index =
+        query_dag_->getNodePayload(node_index).getInsertDestinationID();
+    if (insert_destination_index != QueryContext::kInvalidInsertDestinationId) {
+      // Rebuild is necessary whenever InsertDestination is present.
+      query_exec_state_->setRebuildRequired(node_index);
+      query_exec_state_->setRebuildStatus(node_index, 0, false);
+    }
+
+    for (const pair<dag_node_index, bool> &dependent_link :
+         query_dag_->getDependents(node_index)) {
+      const dag_node_index dependent_op_index = dependent_link.first;
+      if (!query_dag_->getLinkMetadata(node_index, dependent_op_index)) {
+        // The link is not a pipeline-breaker. Streaming of blocks is possible
+        // between these two operators.
+        output_consumers_[node_index].push_back(dependent_op_index);
+      } else {
+        // The link is a pipeline-breaker. Streaming of blocks is not possible
+        // between these two operators.
+        blocking_dependencies_[dependent_op_index].push_back(node_index);
+      }
+    }
+  }
+
+  // Collect all the workorders from all the relational operators in the DAG.
+  for (dag_node_index index = 0; index < num_operators_in_dag; ++index) {
+    if (checkAllBlockingDependenciesMet(index)) {
+      query_dag_->getNodePayloadMutable(index)->informAllBlockingDependenciesMet();
+      processOperator(index, false);
+    }
+  }
+}
+
+WorkerMessage* QueryManager::getNextWorkerMessage(
+    const dag_node_index start_operator_index, const int numa_node) {
+  // Default policy: Operator with lowest index first.
+  WorkOrder *work_order = nullptr;
+  size_t num_operators_checked = 0;
+  for (dag_node_index index = start_operator_index;
+       num_operators_checked < query_dag_->size();
+       index = (index + 1) % query_dag_->size(), ++num_operators_checked) {
+    if (query_exec_state_->hasExecutionFinished(index)) {
+      continue;
+    }
+    if (numa_node != -1) {
+      // First try to get a normal WorkOrder from the specified NUMA node.
+      work_order = workorders_container_->getNormalWorkOrderForNUMANode(index, numa_node);
+      if (work_order != nullptr) {
+        // A WorkOrder found on the given NUMA node.
+        query_exec_state_->incrementNumQueuedWorkOrders(index);
+        return WorkerMessage::WorkOrderMessage(work_order, index);
+      } else {
+        // Normal workorder not found on this node. Look for a rebuild workorder
+        // on this NUMA node.
+        work_order = workorders_container_->getRebuildWorkOrderForNUMANode(index, numa_node);
+        if (work_order != nullptr) {
+          return WorkerMessage::RebuildWorkOrderMessage(work_order, index);
+        }
+      }
+    }
+    // Either no workorder found on the given NUMA node, or numa_node is -1.
+    // Try to get a normal WorkOrder from other NUMA nodes.
+    work_order = workorders_container_->getNormalWorkOrder(index);
+    if (work_order != nullptr) {
+      query_exec_state_->incrementNumQueuedWorkOrders(index);
+      return WorkerMessage::WorkOrderMessage(work_order, index);
+    } else {
+      // Normal WorkOrder not found, look for a RebuildWorkOrder.
+      work_order = workorders_container_->getRebuildWorkOrder(index);
+      if (work_order != nullptr) {
+        return WorkerMessage::RebuildWorkOrderMessage(work_order, index);
+      }
+    }
+  }
+  // No WorkOrders available right now.
+  return nullptr;
+}
+
+QueryManager::QueryStatusCode QueryManager::processMessage(
+    const TaggedMessage &tagged_message) {
+  dag_node_index op_index;
+  switch (tagged_message.message_type()) {
+    case kWorkOrderCompleteMessage: {
+      serialization::WorkOrderCompletionMessage proto;
+      CHECK(proto.ParseFromArray(tagged_message.message(),
+                                 tagged_message.message_bytes()));
+
+      op_index = proto.operator_index();
+      processWorkOrderCompleteMessage(proto.operator_index());
+      break;
+    }
+    case kRebuildWorkOrderCompleteMessage: {
+      serialization::WorkOrderCompletionMessage proto;
+      CHECK(proto.ParseFromArray(tagged_message.message(),
+                                 tagged_message.message_bytes()));
+
+      op_index = proto.operator_index();
+      processRebuildWorkOrderCompleteMessage(proto.operator_index());
+      break;
+    }
+    case kCatalogRelationNewBlockMessage: {
+      serialization::CatalogRelationNewBlockMessage proto;
+      CHECK(proto.ParseFromArray(tagged_message.message(),
+                                 tagged_message.message_bytes()));
+
+      const block_id block = proto.block_id();
+
+      CatalogRelation *relation =
+          static_cast<CatalogDatabase*>(catalog_database_)->getRelationByIdMutable(proto.relation_id());
+      relation->addBlock(block);
+
+      if (proto.has_partition_id()) {
+        relation->getPartitionSchemeMutable()->addBlockToPartition(
+            proto.partition_id(), block);
+      }
+      return QueryStatusCode::kNone;
+    }
+    case kDataPipelineMessage: {
+      // Possible message senders include InsertDestinations and some
+      // operators which modify existing blocks.
+      serialization::DataPipelineMessage proto;
+      CHECK(proto.ParseFromArray(tagged_message.message(),
+                                 tagged_message.message_bytes()));
+
+      op_index = proto.operator_index();
+      processDataPipelineMessage(proto.operator_index(),
+                                 proto.block_id(),
+                                 proto.relation_id());
+      break;
+    }
+    case kWorkOrdersAvailableMessage: {
+      serialization::WorkOrdersAvailableMessage proto;
+      CHECK(proto.ParseFromArray(tagged_message.message(),
+                                 tagged_message.message_bytes()));
+
+      op_index = proto.operator_index();
+
+      // Check if new work orders are available.
+      fetchNormalWorkOrders(op_index);
+
+      // Dispatch the WorkerMessages to the workers. We prefer to start the search
+      // for the schedulable WorkOrders beginning from 'op_index'. The first
+      // candidate worker to receive the next WorkOrder is the one that sent the
+      // response message to Foreman.
+      // TODO(zuyu): Improve the data locality for the next WorkOrder.
+      break;
+    }
+    case kWorkOrderFeedbackMessage: {
+      WorkOrder::FeedbackMessage msg(
+          const_cast<void *>(tagged_message.message()),
+          tagged_message.message_bytes());
+
+      op_index = msg.header().rel_op_index;
+      processFeedbackMessage(msg);
+      break;
+    }
+    default:
+      LOG(FATAL) << "Unknown message type found in QueryManager";
+  }
+
+  if (query_exec_state_->hasExecutionFinished(op_index)) {
+    return QueryStatusCode::kOperatorExecuted;
+  }
+
+  // As kQueryExecuted takes precedence over kOperatorExecuted, we check again.
+  if (query_exec_state_->hasQueryExecutionFinished()) {
+    return QueryStatusCode::kQueryExecuted;
+  }
+
+  return QueryStatusCode::kNone;
+}
+
+void QueryManager::processFeedbackMessage(
+    const WorkOrder::FeedbackMessage &msg) {
+  RelationalOperator *op =
+      query_dag_->getNodePayloadMutable(msg.header().rel_op_index);
+  op->receiveFeedbackMessage(msg);
+}
+
+void QueryManager::processWorkOrderCompleteMessage(
+    const dag_node_index op_index) {
+  query_exec_state_->decrementNumQueuedWorkOrders(op_index);
+
+  // Check if new work orders are available and fetch them if so.
+  fetchNormalWorkOrders(op_index);
+
+  if (checkRebuildRequired(op_index)) {
+    if (checkNormalExecutionOver(op_index)) {
+      if (!checkRebuildInitiated(op_index)) {
+        if (initiateRebuild(op_index)) {
+          // Rebuild initiated and completed right away.
+          markOperatorFinished(op_index);
+        } else {
+          // Rebuild under progress.
+        }
+      } else if (checkRebuildOver(op_index)) {
+        // Rebuild was under progress and now it is over.
+        markOperatorFinished(op_index);
+      }
+    } else {
+      // Normal execution under progress for this operator.
+    }
+  } else if (checkOperatorExecutionOver(op_index)) {
+    // Rebuild not required for this operator and its normal execution is
+    // complete.
+    markOperatorFinished(op_index);
+  }
+
+  for (const pair<dag_node_index, bool> &dependent_link :
+       query_dag_->getDependents(op_index)) {
+    const dag_node_index dependent_op_index = dependent_link.first;
+    if (checkAllBlockingDependenciesMet(dependent_op_index)) {
+      // Process the dependent operator (of the operator whose WorkOrder
+      // was just executed) for which all the dependencies have been met.
+      processOperator(dependent_op_index, true);
+    }
+  }
+}
+
+void QueryManager::processRebuildWorkOrderCompleteMessage(const dag_node_index op_index) {
+  query_exec_state_->decrementNumRebuildWorkOrders(op_index);
+
+  if (checkRebuildOver(op_index)) {
+    markOperatorFinished(op_index);
+
+    for (const pair<dag_node_index, bool> &dependent_link :
+         query_dag_->getDependents(op_index)) {
+      const dag_node_index dependent_op_index = dependent_link.first;
+      if (checkAllBlockingDependenciesMet(dependent_op_index)) {
+        processOperator(dependent_op_index, true);
+      }
+    }
+  }
+}
+
+void QueryManager::processOperator(const dag_node_index index,
+                                   const bool recursively_check_dependents) {
+  if (fetchNormalWorkOrders(index)) {
+    // Fetched work orders. Return to wait for the generated work orders to
+    // execute, and skip the execution-finished checks.
+    return;
+  }
+
+  if (checkNormalExecutionOver(index)) {
+    if (checkRebuildRequired(index)) {
+      if (!checkRebuildInitiated(index)) {
+        // Rebuild hasn't started, initiate it.
+        if (initiateRebuild(index)) {
+          // Rebuild initiated and completed right away.
+          markOperatorFinished(index);
+        } else {
+          // Rebuild WorkOrders have been generated.
+          return;
+        }
+      } else if (checkRebuildOver(index)) {
+        // Rebuild had been initiated and it is over.
+        markOperatorFinished(index);
+      }
+    } else {
+      // Rebuild is not required and normal execution over, mark finished.
+      markOperatorFinished(index);
+    }
+    // If we reach here, that means the operator has been marked as finished.
+    if (recursively_check_dependents) {
+      for (const pair<dag_node_index, bool> &dependent_link :
+           query_dag_->getDependents(index)) {
+        const dag_node_index dependent_op_index = dependent_link.first;
+        if (checkAllBlockingDependenciesMet(dependent_op_index)) {
+          processOperator(dependent_op_index, true);
+        }
+      }
+    }
+  }
+}
+
+void QueryManager::processDataPipelineMessage(const dag_node_index op_index,
+                                              const block_id block,
+                                              const relation_id rel_id) {
+  for (const dag_node_index consumer_index :
+       output_consumers_[op_index]) {
+    // Feed the streamed block to the consumer. Note that 'output_consumers_'
+    // only contain those dependents of operator with index = op_index which are
+    // eligible to receive streamed input.
+    query_dag_->getNodePayloadMutable(consumer_index)->feedInputBlock(block, rel_id);
+    // Because of the streamed input just fed, check if there are any new
+    // WorkOrders available and if so, fetch them.
+    fetchNormalWorkOrders(consumer_index);
+  }
+}
+
+bool QueryManager::fetchNormalWorkOrders(const dag_node_index index) {
+  bool generated_new_workorders = false;
+  if (!query_exec_state_->hasDoneGenerationWorkOrders(index)) {
+    // Do not fetch any work units until all blocking dependencies are met.
+    // The releational operator is not aware of blocking dependencies for
+    // uncorrelated scalar queries.
+    if (!checkAllBlockingDependenciesMet(index)) {
+      return false;
+    }
+    const size_t num_pending_workorders_before =
+        workorders_container_->getNumNormalWorkOrders(index);
+    const bool done_generation =
+        query_dag_->getNodePayloadMutable(index)->getAllWorkOrders(workorders_container_.get(),
+                                                                   query_context_.get(),
+                                                                   storage_manager_,
+                                                                   foreman_client_id_,
+                                                                   bus_);
+    if (done_generation) {
+      query_exec_state_->setDoneGenerationWorkOrders(index);
+    }
+
+    // TODO(shoban): It would be a good check to see if operator is making
+    // useful progress, i.e., the operator either generates work orders to
+    // execute or still has pending work orders executing. However, this will not
+    // work if Foreman polls operators without feeding data. This check can be
+    // enabled, if Foreman is refactored to call getAllWorkOrders() only when
+    // pending work orders are completed or new input blocks feed.
+
+    generated_new_workorders =
+        (num_pending_workorders_before <
+         workorders_container_->getNumNormalWorkOrders(index));
+  }
+  return generated_new_workorders;
+}
+
+void QueryManager::markOperatorFinished(const dag_node_index index) {
+  query_exec_state_->setExecutionFinished(index);
+
+  RelationalOperator *op = query_dag_->getNodePayloadMutable(index);
+  op->updateCatalogOnCompletion();
+
+  const relation_id output_rel = op->getOutputRelationID();
+  for (const pair<dag_node_index, bool> &dependent_link : query_dag_->getDependents(index)) {
+    const dag_node_index dependent_op_index = dependent_link.first;
+    RelationalOperator *dependent_op = query_dag_->getNodePayloadMutable(dependent_op_index);
+    // Signal dependent operator that current operator is done feeding input blocks.
+    if (output_rel >= 0) {
+      dependent_op->doneFeedingInputBlocks(output_rel);
+    }
+    if (checkAllBlockingDependenciesMet(dependent_op_index)) {
+      dependent_op->informAllBlockingDependenciesMet();
+    }
+  }
+}
+
+bool QueryManager::initiateRebuild(const dag_node_index index) {
+  DCHECK(!workorders_container_->hasRebuildWorkOrder(index));
+  DCHECK(checkRebuildRequired(index));
+  DCHECK(!checkRebuildInitiated(index));
+
+  getRebuildWorkOrders(index, workorders_container_.get());
+
+  query_exec_state_->setRebuildStatus(
+      index, workorders_container_->getNumRebuildWorkOrders(index), true);
+
+  return (query_exec_state_->getNumRebuildWorkOrders(index) == 0);
+}
+
+void QueryManager::getRebuildWorkOrders(const dag_node_index index,
+                          WorkOrdersContainer *container) {
+  const RelationalOperator &op = query_dag_->getNodePayload(index);
+  const QueryContext::insert_destination_id insert_destination_index = op.getInsertDestinationID();
+
+  if (insert_destination_index == QueryContext::kInvalidInsertDestinationId) {
+    return;
+  }
+
+  std::vector<MutableBlockReference> partially_filled_block_refs;
+
+  DCHECK(query_context_ != nullptr);
+  InsertDestination *insert_destination = query_context_->getInsertDestination(insert_destination_index);
+  DCHECK(insert_destination != nullptr);
+
+  insert_destination->getPartiallyFilledBlocks(&partially_filled_block_refs);
+
+  for (std::vector<MutableBlockReference>::size_type i = 0;
+       i < partially_filled_block_refs.size();
+       ++i) {
+    container->addRebuildWorkOrder(
+        new RebuildWorkOrder(std::move(partially_filled_block_refs[i]),
+                            index,
+                            op.getOutputRelationID(),
+                            foreman_client_id_,
+                            bus_),
+        index);
+  }
+}
+
+}  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d3725840/query_execution/QueryManager.hpp
----------------------------------------------------------------------
diff --git a/query_execution/QueryManager.hpp b/query_execution/QueryManager.hpp
new file mode 100644
index 0000000..47f54c5
--- /dev/null
+++ b/query_execution/QueryManager.hpp
@@ -0,0 +1,371 @@
+/**
+ *   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_QUERY_EXECUTION_QUERY_MANAGER_HPP_
+#define QUICKSTEP_QUERY_EXECUTION_QUERY_MANAGER_HPP_
+
+#include <cstddef>
+#include <memory>
+#include <vector>
+
+#include "catalog/CatalogTypedefs.hpp"
+#include "query_execution/QueryContext.hpp"
+#include "query_execution/QueryExecutionState.hpp"
+#include "query_execution/WorkOrdersContainer.hpp"
+#include "relational_operators/RelationalOperator.hpp"
+#include "utility/DAG.hpp"
+#include "utility/Macros.hpp"
+
+#include "tmb/message_bus.h"
+#include "tmb/tagged_message.h"
+
+namespace quickstep {
+
+class CatalogDatabaseLite;
+class ForemanMessage;
+class QueryHandle;
+class StorageManager;
+class WorkerMessage;
+
+/** \addtogroup QueryExecution
+ *  @{
+ */
+
+/**
+ * @brief A class that manages the execution of a query including generation
+ *        of new work orders, keeping track of the query exection state.
+ **/
+class QueryManager {
+ public:
+  typedef DAG<RelationalOperator, bool>::size_type_nodes dag_node_index;
+
+  /**
+   * @brief Return codes for processMessage() function.
+   *
+   * @note When both operator and query get executed, kQueryExecuted takes
+   *       precedence over kOperatorExecuted.
+   **/
+  enum class QueryStatusCode {
+    kOperatorExecuted = 0,  // An operator in the query finished execution.
+    kQueryExecuted,         // The query got executed.
+    kNone                   // None of the above.
+  };
+
+  /**
+   * @brief Constructor.
+   *
+   * @param foreman_client_id The TMB client ID of the foreman thread.
+   * @param num_numa_nodes The number of NUMA nodes used by the system.
+   * @param query_handle The QueryHandle object for this query.
+   * @param catalog_database The CatalogDatabse used by the query.
+   * @param storage_manager The StorageManager used by the query.
+   * @param bus The TMB used for communication.
+   **/
+  QueryManager(const tmb::client_id foreman_client_id,
+               const std::size_t num_numa_nodes,
+               QueryHandle *query_handle,
+               CatalogDatabaseLite *catalog_database,
+               StorageManager *storage_manager,
+               tmb::MessageBus *bus);
+
+ /**
+   * @brief Get the next workorder to be excuted, wrapped in a WorkerMessage.
+   *
+   * @param start_operator_index Begin the search for the schedulable WorkOrder
+   *        with the operator at this index.
+   * @param numa_node The next WorkOrder should preferably have its input(s)
+   *        from this numa_node. This is a hint and not a binding requirement.
+   *
+   * @return A pointer to the WorkerMessage. If there's no WorkOrder to be
+   *         executed, return NULL.
+   **/
+  WorkerMessage *getNextWorkerMessage(
+      const dag_node_index start_operator_index,
+      const numa_node_id node_id = -1);
+
+  /**
+   * @brief Process a message sent to the QueryManager.
+   *
+   * @param tagged_message TaggedMessage sent to the QueryManager.
+   *
+   * @return QueryStatusCode as determined after the message is processed.
+   **/
+  QueryStatusCode processMessage(const TaggedMessage &tagged_message);
+
+  /**
+   * @brief Get the QueryExecutionState for this query.
+   **/
+  inline const QueryExecutionState& getQueryExecutionState() const {
+    return *query_exec_state_;
+  }
+
+  /**
+   * @brief Get a pointer to the QueryContext.
+   **/
+  inline QueryContext* getQueryContextMutable() {
+    return query_context_.get();
+  }
+
+ private:
+  /**
+   * @brief Process the received WorkOrder complete message.
+   *
+   * @param node_index The index of the specified operator node in the query DAG
+   *        for the completed WorkOrder.
+   **/
+  void processWorkOrderCompleteMessage(const dag_node_index op_index);
+
+  /**
+   * @brief Process the received RebuildWorkOrder complete message.
+   *
+   * @param node_index The index of the specified operator node in the query DAG
+   *        for the completed RebuildWorkOrder.
+   **/
+  void processRebuildWorkOrderCompleteMessage(const dag_node_index op_index);
+
+  /**
+   * @brief Process a current relational operator: Get its workorders and store
+   *        them in the WorkOrdersContainer for this query. If the operator can
+   *        be marked as done, do so.
+   *
+   * @param index The index of the relational operator to be processed in the
+   *        query plan DAG.
+   * @param recursively_check_dependents If an operator is done, should we
+   *        call processOperator on its dependents recursively.
+   **/
+  void processOperator(const dag_node_index index,
+                       const bool recursively_check_dependents);
+
+  /**
+   * @brief Process the received data pipeline message.
+   *
+   * @param node_index The index of the specified operator node in the query DAG
+   *        for the pipelining block.
+   * @param block The block id.
+   * @param rel_id The ID of the relation that produced 'block'.
+   **/
+  void processDataPipelineMessage(const dag_node_index op_index,
+                                  const block_id block,
+                                  const relation_id rel_id);
+
+  /**
+   * @brief Process the received work order feedback message and notify
+   *        relational operator.
+   *
+   * @param message Feedback message from work order.
+   **/
+  void processFeedbackMessage(const WorkOrder::FeedbackMessage &message);
+
+  /**
+   * @brief Fetch all work orders currently available in relational operator and
+   *        store them internally.
+   *
+   * @param index The index of the relational operator to be processed in the
+   *        query plan DAG.
+   *
+   * @return Whether any work order was generated by op.
+   **/
+  bool fetchNormalWorkOrders(const dag_node_index index);
+
+  /**
+   * @brief This function does the following things:
+   *        1. Mark the given relational operator as "done".
+   *        2. For all the dependents of this operator, check if all of their
+   *        blocking dependencies are met. If so inform them that the blocking
+   *        dependencies are met.
+   *        3. Check if the given operator is done producing output. If it's
+   *        done, inform the dependents that they won't receive input anymore
+   *        from the given operator.
+   *
+   * @param index The index of the given relational operator in the DAG.
+   **/
+  void markOperatorFinished(const dag_node_index index);
+
+  /**
+   * @brief Check if all the dependencies of the node at specified index have
+   *        finished their execution.
+   *
+   * @note This function's true return value is a pre-requisite for calling
+   *       getRebuildWorkOrders()
+   *
+   * @param node_index The index of the specified node in the query DAG.
+   *
+   * @return True if all the dependencies have finished their execution. False
+   *         otherwise.
+   **/
+  inline bool checkAllDependenciesMet(const dag_node_index node_index) const {
+    for (const dag_node_index dependency_index :
+         query_dag_->getDependencies(node_index)) {
+      // If at least one of the dependencies is not met, return false.
+      if (!query_exec_state_->hasExecutionFinished(dependency_index)) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  /**
+   * @brief Check if all the blocking dependencies of the node at specified
+   *        index have finished their execution.
+   *
+   * @note A blocking dependency is the one which is pipeline breaker. Output of
+   *       a dependency can't be streamed to its dependent if the link between
+   *       them is pipeline breaker.
+   *
+   * @param node_index The index of the specified node in the query DAG.
+   *
+   * @return True if all the blocking dependencies have finished their
+   *         execution. False otherwise.
+   **/
+  inline bool checkAllBlockingDependenciesMet(
+      const dag_node_index node_index) const {
+    for (const dag_node_index blocking_dependency_index :
+         blocking_dependencies_[node_index]) {
+      if (!query_exec_state_->hasExecutionFinished(
+              blocking_dependency_index)) {
+        return false;
+      }
+    }
+    return true;
+  }
+
+  /**
+   * @brief Check if the execution of the given operator is over.
+   *
+   * @param index The index of the given operator in the DAG.
+   *
+   * @return True if the execution of the given operator is over, false
+   *         otherwise.
+   **/
+  inline bool checkOperatorExecutionOver(const dag_node_index index) const {
+    if (checkRebuildRequired(index)) {
+      return (checkNormalExecutionOver(index) && checkRebuildOver(index));
+    } else {
+      return checkNormalExecutionOver(index);
+    }
+  }
+
+  /**
+   * @brief Check if the given operator's normal execution is over.
+   *
+   * @note The conditions for a given operator's normal execution to get over:
+   *       1. All of its  normal (i.e. non rebuild) WorkOrders have finished
+   *       execution.
+   *       2. The operator is done generating work orders.
+   *       3. All of the dependencies of the given operator have been met.
+   *
+   * @param index The index of the given operator in the DAG.
+   *
+   * @return True if the normal execution of the given operator is over, false
+   *         otherwise.
+   **/
+  inline bool checkNormalExecutionOver(const dag_node_index index) const {
+    return (checkAllDependenciesMet(index) &&
+            !workorders_container_->hasNormalWorkOrder(index) &&
+            query_exec_state_->getNumQueuedWorkOrders(index) == 0 &&
+            query_exec_state_->hasDoneGenerationWorkOrders(index));
+  }
+
+  /**
+   * @brief Check if the rebuild operation is required for a given operator.
+   *
+   * @param index The index of the given operator in the DAG.
+   *
+   * @return True if the rebuild operation is required, false otherwise.
+   **/
+  inline bool checkRebuildRequired(const dag_node_index index) const {
+    return query_exec_state_->isRebuildRequired(index);
+  }
+
+  /**
+   * @brief Check if the rebuild operation for a given operator is over.
+   *
+   * @param index The index of the given operator in the DAG.
+   *
+   * @return True if the rebuild operation is over, false otherwise.
+   **/
+  inline bool checkRebuildOver(const dag_node_index index) const {
+    return query_exec_state_->hasRebuildInitiated(index) &&
+           !workorders_container_->hasRebuildWorkOrder(index) &&
+           (query_exec_state_->getNumRebuildWorkOrders(index) == 0);
+  }
+
+  /**
+   * @brief Check if the rebuild operation for a given operator has been
+   *        initiated.
+   *
+   * @param index The index of the given operator in the DAG.
+   *
+   * @return True if the rebuild operation has been initiated, false otherwise.
+   **/
+  inline bool checkRebuildInitiated(const dag_node_index index) const {
+    return query_exec_state_->hasRebuildInitiated(index);
+  }
+
+  /**
+   * @brief Initiate the rebuild process for partially filled blocks generated
+   *        during the execution of the given operator.
+   *
+   * @param index The index of the given operator in the DAG.
+   *
+   * @return True if the rebuild is over immediately, i.e. the operator didn't
+   *         generate any rebuild WorkOrders, false otherwise.
+   **/
+  bool initiateRebuild(const dag_node_index index);
+
+  /**
+   * @brief Get the rebuild WorkOrders for an operator.
+   *
+   * @note This function should be called only once, when all the normal
+   *       WorkOrders generated by an operator finish their execution.
+   *
+   * @param index The index of the operator in the query plan DAG.
+   * @param container A pointer to a WorkOrdersContainer to be used to store the
+   *        generated WorkOrders.
+   **/
+  void getRebuildWorkOrders(const dag_node_index index,
+                            WorkOrdersContainer *container);
+
+  const tmb::client_id foreman_client_id_;
+  const std::size_t query_id_;
+
+  CatalogDatabaseLite *catalog_database_;
+  StorageManager *storage_manager_;
+  tmb::MessageBus *bus_;
+
+  DAG<RelationalOperator, bool> *query_dag_;
+
+  std::unique_ptr<QueryContext> query_context_;
+
+  // For all nodes, store their receiving dependents.
+  std::vector<std::vector<dag_node_index>> output_consumers_;
+
+  // For all nodes, store their pipeline breaking dependencies (if any).
+  std::vector<std::vector<dag_node_index>> blocking_dependencies_;
+
+  std::unique_ptr<QueryExecutionState> query_exec_state_;
+
+  std::unique_ptr<WorkOrdersContainer> workorders_container_;
+
+  DISALLOW_COPY_AND_ASSIGN(QueryManager);
+};
+
+/** @} */
+
+}  // namespace quickstep
+
+#endif  // QUICKSTEP_QUERY_EXECUTION_QUERY_MANAGER_HPP_

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d3725840/query_execution/WorkOrdersContainer.hpp
----------------------------------------------------------------------
diff --git a/query_execution/WorkOrdersContainer.hpp b/query_execution/WorkOrdersContainer.hpp
index b4a0a03..eb9aedd 100644
--- a/query_execution/WorkOrdersContainer.hpp
+++ b/query_execution/WorkOrdersContainer.hpp
@@ -48,8 +48,8 @@ class WorkOrdersContainer {
    * @param num_numa_nodes Number of NUMA nodes in the system.
    **/
   WorkOrdersContainer(const std::size_t num_operators,
-                     const std::size_t num_numa_nodes)
-    : num_operators_(num_operators), num_numa_nodes_(num_numa_nodes) {
+                      const std::size_t num_numa_nodes)
+      : num_operators_(num_operators), num_numa_nodes_(num_numa_nodes) {
     DEBUG_ASSERT(num_operators != 0);
     for (std::size_t op = 0; op < num_operators; ++op) {
       normal_workorders_.push_back(

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d3725840/query_execution/WorkerMessage.hpp
----------------------------------------------------------------------
diff --git a/query_execution/WorkerMessage.hpp b/query_execution/WorkerMessage.hpp
index 875fa5a..ec63af9 100644
--- a/query_execution/WorkerMessage.hpp
+++ b/query_execution/WorkerMessage.hpp
@@ -30,7 +30,7 @@ class WorkOrder;
  **/
 class WorkerMessage {
  public:
-  enum WorkerMessageType {
+  enum class WorkerMessageType {
     kRebuildWorkOrder = 0,
     kWorkOrder,
     kPoison
@@ -46,7 +46,9 @@ class WorkerMessage {
    * @return The constructed RebuildWorkOrderMessage.
    **/
   static WorkerMessage* RebuildWorkOrderMessage(WorkOrder *rebuild_workorder, const std::size_t relational_op_index) {
-    return new WorkerMessage(rebuild_workorder, relational_op_index, kRebuildWorkOrder);
+    return new WorkerMessage(rebuild_workorder,
+                             relational_op_index,
+                             WorkerMessageType::kRebuildWorkOrder);
   }
 
   /**
@@ -60,7 +62,9 @@ class WorkerMessage {
    * @return The constructed WorkOrderMessage.
    **/
   static WorkerMessage* WorkOrderMessage(WorkOrder *workorder, const std::size_t relational_op_index) {
-    return new WorkerMessage(workorder, relational_op_index, kWorkOrder);
+    return new WorkerMessage(workorder,
+                             relational_op_index,
+                             WorkerMessageType::kWorkOrder);
   }
 
   /**
@@ -69,7 +73,7 @@ class WorkerMessage {
    * @return The constructed PoisonMessage.
    **/
   static WorkerMessage* PoisonMessage() {
-    return new WorkerMessage(nullptr, 0, kPoison);
+    return new WorkerMessage(nullptr, 0, WorkerMessageType::kPoison);
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d3725840/query_execution/tests/QueryManager_unittest.cpp
----------------------------------------------------------------------
diff --git a/query_execution/tests/QueryManager_unittest.cpp b/query_execution/tests/QueryManager_unittest.cpp
new file mode 100644
index 0000000..1b9be48
--- /dev/null
+++ b/query_execution/tests/QueryManager_unittest.cpp
@@ -0,0 +1,933 @@
+/**
+ *   Copyright 2011-2015 Quickstep Technologies LLC.
+ *   Copyright 2015-2016 Pivotal Software, Inc.
+ *
+ *   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.
+ **/
+
+#include <climits>
+#include <memory>
+#include <utility>
+#include <vector>
+
+#include "catalog/CatalogDatabase.hpp"
+#include "catalog/CatalogRelation.hpp"
+#include "catalog/CatalogTypedefs.hpp"
+#include "query_execution/QueryContext.hpp"
+#include "query_execution/QueryContext.pb.h"
+#include "query_execution/QueryExecutionMessages.pb.h"
+#include "query_execution/QueryExecutionState.hpp"
+#include "query_execution/QueryExecutionTypedefs.hpp"
+#include "query_execution/QueryManager.hpp"
+#include "query_execution/WorkOrdersContainer.hpp"
+#include "query_execution/WorkerDirectory.hpp"
+#include "query_execution/WorkerMessage.hpp"
+#include "query_optimizer/QueryHandle.hpp"
+#include "query_optimizer/QueryPlan.hpp"
+#include "relational_operators/RelationalOperator.hpp"
+#include "relational_operators/WorkOrder.hpp"
+#include "storage/InsertDestination.hpp"
+#include "storage/InsertDestination.pb.h"
+#include "storage/StorageBlock.hpp"
+#include "storage/StorageBlockInfo.hpp"
+#include "storage/StorageManager.hpp"
+#include "utility/DAG.hpp"
+#include "utility/Macros.hpp"
+
+#include "glog/logging.h"
+#include "gtest/gtest.h"
+
+#include "tmb/id_typedefs.h"
+#include "tmb/message_bus.h"
+#include "tmb/tagged_message.h"
+
+using std::move;
+using std::unique_ptr;
+using std::vector;
+
+using tmb::client_id;
+
+namespace quickstep {
+
+class MockWorkOrder : public WorkOrder {
+ public:
+  explicit MockWorkOrder(const int op_index)
+      : op_index_(op_index) {}
+
+  void execute() override {
+    VLOG(3) << "WorkOrder[" << op_index_ << "] executing.";
+  }
+
+  inline QueryPlan::DAGNodeIndex getOpIndex() const {
+    return op_index_;
+  }
+
+ private:
+  const QueryPlan::DAGNodeIndex op_index_;
+
+  DISALLOW_COPY_AND_ASSIGN(MockWorkOrder);
+};
+
+class MockOperator: public RelationalOperator {
+ public:
+  enum function_name {
+    kFeedInputBlock = 0,
+    kFeedInputBlocks,
+    kDoneFeedingInputBlocks,
+    kGetAllWorkOrders
+  };
+
+  MockOperator(const bool produce_workorders,
+               const bool has_streaming_input,
+               const int max_getworkorder_iters = 1,
+               const int max_workorders = INT_MAX)
+      : produce_workorders_(produce_workorders),
+        has_streaming_input_(has_streaming_input),
+        max_workorders_(max_workorders),
+        max_getworkorder_iters_(max_getworkorder_iters),
+        num_calls_get_workorders_(0),
+        num_workorders_generated_(0),
+        num_calls_feedblock_(0),
+        num_calls_feedblocks_(0),
+        num_calls_donefeedingblocks_(0) {
+  }
+
+#define MOCK_OP_LOG(x) VLOG(x) << "Op[" << op_index_ << "]: " << __func__ << ": "
+
+  // The methods below are used to check whether QueryManager calls the Relational
+  // operator, how many times it calls a particular method etc.
+  inline int getNumWorkOrders() const {
+    return num_workorders_generated_;
+  }
+
+  inline int getNumCalls(const function_name fname) const {
+    switch (fname) {
+      case kFeedInputBlock:
+        return num_calls_feedblock_;
+      case kFeedInputBlocks:
+        return num_calls_feedblocks_;
+      case kDoneFeedingInputBlocks:
+        return num_calls_donefeedingblocks_;
+      case kGetAllWorkOrders:
+        return num_calls_get_workorders_;
+      default:
+        return -1;
+    }
+  }
+
+  inline bool getBlockingDependenciesMet() const {
+    MOCK_OP_LOG(3) << "met.";
+    return blocking_dependencies_met_;
+  }
+
+  void setInsertDestinationID(const QueryContext::insert_destination_id insert_destination_index) {
+    insert_destination_index_ = insert_destination_index;
+  }
+
+  // Mock to trigger doneFeedingInputBlocks for the dependent operators
+  // in QueryManager::markOperatorFinished.
+  void setOutputRelationID(const relation_id rel_id) {
+    output_relation_id_ = rel_id;
+  }
+
+  // Override methods from the base class.
+  bool getAllWorkOrders(
+      WorkOrdersContainer *container,
+      QueryContext *query_context,
+      StorageManager *storage_manager,
+      const tmb::client_id foreman_client_id,
+      tmb::MessageBus *bus) override {
+    ++num_calls_get_workorders_;
+    if (produce_workorders_) {
+      if (has_streaming_input_) {
+        if ((num_calls_feedblock_ > 0 || num_calls_feedblocks_ > 0) && (num_workorders_generated_ < max_workorders_)) {
+          MOCK_OP_LOG(3) << "[stream] generate WorkOrder";
+          container->addNormalWorkOrder(new MockWorkOrder(op_index_), op_index_);
+          ++num_workorders_generated_;
+        }
+      } else {
+        if (blocking_dependencies_met_ && (num_workorders_generated_ < max_workorders_)) {
+          MOCK_OP_LOG(3) << "[static] generate WorkOrder";
+          container->addNormalWorkOrder(new MockWorkOrder(op_index_), op_index_);
+          ++num_workorders_generated_;
+        }
+      }
+    }
+    MOCK_OP_LOG(3) << "count(" << num_calls_get_workorders_ << ") "
+                   << "return(" << (num_calls_get_workorders_ == max_getworkorder_iters_) << ")";
+    return num_calls_get_workorders_ == max_getworkorder_iters_;
+  }
+
+  void feedInputBlock(const block_id input_block_id,
+                      const relation_id input_relation_id) override {
+    ++num_calls_feedblock_;
+    MOCK_OP_LOG(3) << "count(" << num_calls_feedblock_ << ")";
+  }
+
+  void feedInputBlocks(const relation_id rel_id,
+                       std::vector<block_id> *partially_filled_blocks) override {
+    ++num_calls_feedblocks_;
+    MOCK_OP_LOG(3) << "count(" << num_calls_feedblocks_ << ")";
+  }
+
+  void doneFeedingInputBlocks(const relation_id rel_id) override {
+    ++num_calls_donefeedingblocks_;
+    MOCK_OP_LOG(3) << "count(" << num_calls_donefeedingblocks_ << ")";
+  }
+
+  QueryContext::insert_destination_id getInsertDestinationID() const override {
+    return insert_destination_index_;
+  }
+
+  const relation_id getOutputRelationID() const override {
+    return output_relation_id_;
+  }
+
+ private:
+  const bool produce_workorders_;
+  const bool has_streaming_input_;
+  const int max_workorders_;
+  const int max_getworkorder_iters_;
+
+  int num_calls_get_workorders_;
+  int num_workorders_generated_;
+  int num_calls_feedblock_;
+  int num_calls_feedblocks_;
+  int num_calls_donefeedingblocks_;
+
+  QueryContext::insert_destination_id insert_destination_index_ = QueryContext::kInvalidInsertDestinationId;
+
+  relation_id output_relation_id_ = -1;
+
+#undef MOCK_OP_LOG
+
+  DISALLOW_COPY_AND_ASSIGN(MockOperator);
+};
+
+
+class QueryManagerTest : public ::testing::Test {
+ protected:
+  virtual void SetUp() {
+    db_.reset(new CatalogDatabase(nullptr /* catalog */, "database"));
+    storage_manager_.reset(new StorageManager("./"));
+    bus_.Initialize();
+    query_handle_.reset(new QueryHandle(0));
+    query_plan_ = query_handle_->getQueryPlanMutable();
+  }
+
+  inline void constructQueryManager() {
+    query_manager_.reset(new QueryManager(
+        0, 1, query_handle_.get(), db_.get(), storage_manager_.get(), &bus_));
+  }
+
+  inline const int getNumWorkOrdersInExecution(const QueryPlan::DAGNodeIndex index) const {
+    return query_manager_->getQueryExecutionState().getNumQueuedWorkOrders(index);
+  }
+
+  inline const int getNumOperatorsFinished() const {
+    return query_manager_->getQueryExecutionState().getNumOperatorsFinished();
+  }
+
+  inline bool getOperatorFinishedStatus(const QueryPlan::DAGNodeIndex index) const {
+    return query_manager_->getQueryExecutionState().hasExecutionFinished(index);
+  }
+
+  inline bool placeDataPipelineMessage(const QueryPlan::DAGNodeIndex source_operator_index) {
+    VLOG(3) << "Place DataPipeline message for Op[" << source_operator_index << "]";
+    serialization::DataPipelineMessage proto;
+    proto.set_operator_index(source_operator_index);
+
+    proto.set_block_id(0);  // dummy block ID
+    proto.set_relation_id(0);  // dummy relation ID.
+
+    // NOTE(zuyu): Using the heap memory to serialize proto as a c-like string.
+    const std::size_t proto_length = proto.ByteSize();
+    char *proto_bytes = static_cast<char*>(std::malloc(proto_length));
+    CHECK(proto.SerializeToArray(proto_bytes, proto_length));
+
+    tmb::TaggedMessage tagged_message(static_cast<const void *>(proto_bytes),
+                                      proto_length,
+                                      kDataPipelineMessage);
+    std::free(proto_bytes);
+    query_manager_->processMessage(tagged_message);
+    return query_manager_->getQueryExecutionState().hasQueryExecutionFinished();
+  }
+
+  inline bool placeWorkOrderCompleteMessage(const QueryPlan::DAGNodeIndex index) {
+    VLOG(3) << "Place WorkOrderComplete message for Op[" << index << "]";
+    TaggedMessage tagged_message;
+    serialization::WorkOrderCompletionMessage proto;
+    proto.set_operator_index(index);
+    proto.set_worker_thread_index(1);  // dummy worker ID.
+
+    // NOTE(zuyu): Using the heap memory to serialize proto as a c-like string.
+    const size_t proto_length = proto.ByteSize();
+    char *proto_bytes = static_cast<char*>(std::malloc(proto_length));
+    CHECK(proto.SerializeToArray(proto_bytes, proto_length));
+
+    TaggedMessage message(static_cast<const void*>(proto_bytes),
+                          proto_length,
+                          kWorkOrderCompleteMessage);
+    std::free(proto_bytes);
+    query_manager_->processMessage(message);
+
+    return query_manager_->getQueryExecutionState().hasQueryExecutionFinished();
+  }
+
+  inline bool placeRebuildWorkOrderCompleteMessage(const QueryPlan::DAGNodeIndex index) {
+    VLOG(3) << "Place RebuildWorkOrderComplete message for Op[" << index << "]";
+    // foreman_->processRebuildWorkOrderCompleteMessage(index, 0 /* worker id */);
+    serialization::WorkOrderCompletionMessage proto;
+    proto.set_operator_index(index);
+    proto.set_worker_thread_index(1);  // dummy worker thread ID.
+
+    // NOTE(zuyu): Using the heap memory to serialize proto as a c-like string.
+    const size_t proto_length = proto.ByteSize();
+    char *proto_bytes = static_cast<char*>(std::malloc(proto_length));
+    CHECK(proto.SerializeToArray(proto_bytes, proto_length));
+
+    TaggedMessage message(static_cast<const void*>(proto_bytes),
+                          proto_length,
+                          kRebuildWorkOrderCompleteMessage);
+
+    std::free(proto_bytes);
+    query_manager_->processMessage(message);
+
+    return query_manager_->getQueryExecutionState().hasQueryExecutionFinished();
+  }
+
+  inline bool placeOutputBlockMessage(const QueryPlan::DAGNodeIndex index) {
+    VLOG(3) << "Place OutputBlock message for Op[" << index << "]";
+    serialization::DataPipelineMessage proto;
+    proto.set_operator_index(index);
+
+    proto.set_block_id(0);  // dummy block ID
+    proto.set_relation_id(0);  // dummy relation ID.
+
+    // NOTE(zuyu): Using the heap memory to serialize proto as a c-like string.
+    const std::size_t proto_length = proto.ByteSize();
+    char *proto_bytes = static_cast<char*>(std::malloc(proto_length));
+    CHECK(proto.SerializeToArray(proto_bytes, proto_length));
+
+    tmb::TaggedMessage tagged_message(static_cast<const void *>(proto_bytes),
+                                      proto_length,
+                                      kDataPipelineMessage);
+    std::free(proto_bytes);
+    query_manager_->processMessage(tagged_message);
+    return query_manager_->getQueryExecutionState().hasQueryExecutionFinished();
+  }
+
+  unique_ptr<CatalogDatabase> db_;
+  unique_ptr<StorageManager> storage_manager_;
+
+  QueryPlan *query_plan_;
+  unique_ptr<QueryHandle> query_handle_;
+  unique_ptr<QueryManager> query_manager_;
+
+  // unique_ptr<Foreman> foreman_;
+  MessageBusImpl bus_;
+
+  client_id worker_client_id_;
+
+  unique_ptr<WorkerDirectory> workers_;
+};
+
+TEST_F(QueryManagerTest, SingleNodeDAGNoWorkOrdersTest) {
+  // This test creates a DAG of a single node. No workorders are generated.
+  query_plan_->addRelationalOperator(new MockOperator(false, false));
+  // foreman_->setQueryPlan(query_plan_->getQueryPlanDAGMutable());
+
+  const MockOperator &op = static_cast<const MockOperator &>(
+      query_plan_->getQueryPlanDAG().getNodePayload(0));
+
+  constructQueryManager();
+
+  // op doesn't have any dependencies.
+  EXPECT_TRUE(op.getBlockingDependenciesMet());
+
+  // We expect one call for op's getAllWorkOrders().
+  EXPECT_EQ(1, op.getNumCalls(MockOperator::kGetAllWorkOrders));
+  EXPECT_EQ(0, op.getNumCalls(MockOperator::kFeedInputBlock));
+  EXPECT_EQ(0, op.getNumCalls(MockOperator::kFeedInputBlocks));
+}
+
+TEST_F(QueryManagerTest, SingleNodeDAGStaticWorkOrdersTest) {
+  // This test creates a DAG of a single node. Static workorders are generated.
+  const QueryPlan::DAGNodeIndex id =
+      query_plan_->addRelationalOperator(new MockOperator(true, false, 1));
+  // foreman_->setQueryPlan(query_plan_->getQueryPlanDAGMutable());
+
+  const MockOperator &op = static_cast<const MockOperator &>(
+      query_plan_->getQueryPlanDAG().getNodePayload(id));
+
+  constructQueryManager();
+
+  // op doesn't have any dependencies.
+  EXPECT_TRUE(op.getBlockingDependenciesMet());
+
+  // We expect one call for op's getAllWorkOrders().
+  EXPECT_EQ(1, op.getNumCalls(MockOperator::kGetAllWorkOrders));
+  EXPECT_EQ(0, op.getNumCalls(MockOperator::kFeedInputBlock));
+  EXPECT_EQ(0, op.getNumCalls(MockOperator::kFeedInputBlocks));
+
+  // One workorder is generated.
+  EXPECT_EQ(1, op.getNumWorkOrders());
+
+  unique_ptr<WorkerMessage> worker_message;
+  worker_message.reset(query_manager_->getNextWorkerMessage(0, -1));
+  EXPECT_TRUE(worker_message != nullptr);
+
+  EXPECT_EQ(WorkerMessage::WorkerMessageType::kWorkOrder,
+            worker_message->getType());
+  EXPECT_EQ(0u, worker_message->getRelationalOpIndex());
+
+  delete worker_message->getWorkOrder();
+
+  EXPECT_EQ(1, getNumWorkOrdersInExecution(id));
+  EXPECT_EQ(0, getNumOperatorsFinished());
+
+  // Send a message to QueryManager upon workorder completion.
+  // Last event processed by QueryManager.
+  EXPECT_TRUE(placeWorkOrderCompleteMessage(id));
+
+  EXPECT_EQ(0, getNumWorkOrdersInExecution(id));
+  EXPECT_EQ(1, getNumOperatorsFinished());
+  EXPECT_TRUE(getOperatorFinishedStatus(id));
+}
+
+TEST_F(QueryManagerTest, SingleNodeDAGDynamicWorkOrdersTest) {
+  // This test creates a DAG of a single node. WorkOrders are generated
+  // dynamically as pending work orders complete execution, i.e.,
+  // getAllWorkOrders() is called multiple times.  getAllWorkOrders() will be
+  // called 5 times and 3 work orders will be returned, i.e., 1st 3 calls to
+  // getAllWorkOrders() insert 1 WorkOrder and return false, and the next will
+  // insert no WorkOrder and return true.
+
+  // TODO(shoban): This test can not be more robust than this because of fixed
+  // scaffolding of mocking. If we use gMock, we can do much better.
+  const QueryPlan::DAGNodeIndex id =
+      query_plan_->addRelationalOperator(new MockOperator(true, false, 4, 3));
+  // foreman_->setQueryPlan(query_plan_->getQueryPlanDAGMutable());
+
+  const MockOperator &op = static_cast<const MockOperator &>(
+      query_plan_->getQueryPlanDAG().getNodePayload(id));
+
+  constructQueryManager();
+
+  // op doesn't have any dependencies.
+  EXPECT_TRUE(op.getBlockingDependenciesMet());
+
+  for (int i = 0; i < 3; ++i) {
+    // We expect one call for op's getAllWorkOrders().
+    EXPECT_EQ(i + 1, op.getNumCalls(MockOperator::kGetAllWorkOrders));
+
+    // One workorder is generated.
+    // EXPECT_EQ(1, getWorkerInputQueueSize());
+    EXPECT_EQ(i + 1, op.getNumWorkOrders());
+
+    unique_ptr<WorkerMessage> worker_message;
+    worker_message.reset(query_manager_->getNextWorkerMessage(id, -1));
+
+    EXPECT_TRUE(worker_message != nullptr);
+    EXPECT_EQ(WorkerMessage::WorkerMessageType::kWorkOrder,
+              worker_message->getType());
+    EXPECT_EQ(id, worker_message->getRelationalOpIndex());
+
+    delete worker_message->getWorkOrder();
+
+    EXPECT_EQ(1, getNumWorkOrdersInExecution(id));
+    EXPECT_EQ(0, getNumOperatorsFinished());
+
+    if (i < 2) {
+      // Send a message to QueryManager upon workorder completion.
+      EXPECT_FALSE(placeWorkOrderCompleteMessage(id));
+    } else {
+      // Send a message to QueryManager upon workorder completion.
+      // Last event.
+      EXPECT_TRUE(placeWorkOrderCompleteMessage(id));
+    }
+  }
+
+  EXPECT_EQ(0, getNumWorkOrdersInExecution(id));
+
+  EXPECT_EQ(1, getNumOperatorsFinished());
+  EXPECT_TRUE(getOperatorFinishedStatus(id));
+
+  // We place this check in the end, since it's true throughout the test.
+  EXPECT_EQ(0, op.getNumCalls(MockOperator::kFeedInputBlock));
+  EXPECT_EQ(0, op.getNumCalls(MockOperator::kFeedInputBlocks));
+}
+
+TEST_F(QueryManagerTest, TwoNodesDAGBlockingLinkTest) {
+  // We use two nodes in the DAG with a blocking link between them.
+  // There is no streaming of data involved in this test.
+  const QueryPlan::DAGNodeIndex id1 =
+      query_plan_->addRelationalOperator(new MockOperator(true, false));
+  const QueryPlan::DAGNodeIndex id2 =
+      query_plan_->addRelationalOperator(new MockOperator(true, false));
+
+  // Create a blocking link.
+  query_plan_->addDirectDependency(id2, id1, true);
+
+  static_cast<MockOperator *>(
+      query_plan_->getQueryPlanDAGMutable()->getNodePayloadMutable(id1))
+          ->setOutputRelationID(0xdead);
+
+  const MockOperator &op1 = static_cast<const MockOperator &>(
+      query_plan_->getQueryPlanDAG().getNodePayload(id1));
+  const MockOperator &op2 = static_cast<const MockOperator &>(
+      query_plan_->getQueryPlanDAG().getNodePayload(id2));
+
+  constructQueryManager();
+
+  // op1 doesn't have any dependencies
+  EXPECT_TRUE(op1.getBlockingDependenciesMet());
+
+  // Only op1 should receive a call to getAllWorkOrders initially.
+  EXPECT_EQ(1, op1.getNumCalls(MockOperator::kGetAllWorkOrders));
+  EXPECT_EQ(0, op1.getNumCalls(MockOperator::kFeedInputBlock));
+  EXPECT_EQ(0, op1.getNumCalls(MockOperator::kFeedInputBlocks));
+
+  EXPECT_EQ(0, op2.getNumCalls(MockOperator::kGetAllWorkOrders));
+  EXPECT_EQ(0, op2.getNumCalls(MockOperator::kFeedInputBlock));
+  EXPECT_EQ(0, op2.getNumCalls(MockOperator::kFeedInputBlocks));
+
+  // Only op1 should produce a workorder.
+  EXPECT_EQ(1, op1.getNumWorkOrders());
+  EXPECT_EQ(0, op2.getNumWorkOrders());
+
+  // Foreman hasn't yet got workorder completion response for the workorder.
+  unique_ptr<WorkerMessage> worker_message;
+  worker_message.reset(query_manager_->getNextWorkerMessage(id1, -1));
+
+  EXPECT_TRUE(worker_message != nullptr);
+  EXPECT_EQ(WorkerMessage::WorkerMessageType::kWorkOrder,
+            worker_message->getType());
+  EXPECT_EQ(id1, worker_message->getRelationalOpIndex());
+
+  delete worker_message->getWorkOrder();
+
+  EXPECT_EQ(1, getNumWorkOrdersInExecution(id1));
+  EXPECT_EQ(0, getNumWorkOrdersInExecution(id2));
+  EXPECT_EQ(0, getNumOperatorsFinished());
+
+  // Send a message to Foreman upon workorder (generated by op1) completion.
+  EXPECT_FALSE(placeWorkOrderCompleteMessage(id1));
+
+  EXPECT_EQ(0, getNumWorkOrdersInExecution(id1));
+  // op1 is over now, op2 still to go.
+  EXPECT_EQ(1, op2.getNumCalls(MockOperator::kDoneFeedingInputBlocks));
+  EXPECT_EQ(1, getNumOperatorsFinished());
+
+  EXPECT_TRUE(getOperatorFinishedStatus(id1));
+  EXPECT_EQ(1, op2.getNumCalls(MockOperator::kDoneFeedingInputBlocks));
+  EXPECT_FALSE(getOperatorFinishedStatus(id2));
+
+  worker_message.reset(query_manager_->getNextWorkerMessage(id2, -1));
+  EXPECT_TRUE(worker_message != nullptr);
+  EXPECT_EQ(WorkerMessage::WorkerMessageType::kWorkOrder,
+            worker_message->getType());
+  EXPECT_EQ(id2, worker_message->getRelationalOpIndex());
+
+  delete worker_message->getWorkOrder();
+
+  EXPECT_EQ(1, getNumWorkOrdersInExecution(id2));
+
+  // op1 is op2's blocking dependency.
+  EXPECT_TRUE(op2.getBlockingDependenciesMet());
+
+  EXPECT_EQ(1, op1.getNumCalls(MockOperator::kGetAllWorkOrders));
+  // op2 should get first call of getAllWorkOrders() when op1 is over.
+  EXPECT_EQ(1, op2.getNumCalls(MockOperator::kGetAllWorkOrders));
+
+  EXPECT_EQ(1, op2.getNumWorkOrders());
+
+  // Send a message to QueryManager upon workorder (generated by op2) completion.
+  // Note that the worker hasn't yet popped the workorder. Usually this won't
+  // happen as workers pop workorders first, execute and then send the response.
+  EXPECT_TRUE(placeWorkOrderCompleteMessage(id2));
+
+  EXPECT_EQ(1, op2.getNumCalls(MockOperator::kGetAllWorkOrders));
+
+  EXPECT_EQ(0, getNumWorkOrdersInExecution(id1));
+  EXPECT_EQ(0, getNumWorkOrdersInExecution(id2));
+
+  EXPECT_EQ(2, getNumOperatorsFinished());
+  EXPECT_TRUE(getOperatorFinishedStatus(id1));
+  EXPECT_TRUE(getOperatorFinishedStatus(id2));
+
+  // Expect no additional calls to getAllWorkOrders.
+  EXPECT_EQ(1, op1.getNumCalls(MockOperator::kGetAllWorkOrders));
+  EXPECT_EQ(1, op2.getNumCalls(MockOperator::kGetAllWorkOrders));
+}
+
+TEST_F(QueryManagerTest, TwoNodesDAGPipeLinkTest) {
+  // We use two nodes in the DAG with a non-blocking link between them.
+  // We stream output of op1 to op2. Sequeuce of events is as follows:
+  // 1. op1 creates a workorder.
+  // 2. We send a "block full" (from op1) to QueryManager.
+  // 3. op2 creates a workorder because of step 2.
+  const QueryPlan::DAGNodeIndex id1 =
+      query_plan_->addRelationalOperator(new MockOperator(true, false, 1));
+  const QueryPlan::DAGNodeIndex id2 =
+      query_plan_->addRelationalOperator(new MockOperator(true, true, 3));
+
+  // Create a non-blocking link.
+  query_plan_->addDirectDependency(id2, id1, false);
+
+  static_cast<MockOperator *>(
+      query_plan_->getQueryPlanDAGMutable()->getNodePayloadMutable(id1))
+      ->setOutputRelationID(0xdead);
+
+  const MockOperator &op1 = static_cast<const MockOperator &>(
+      query_plan_->getQueryPlanDAG().getNodePayload(id1));
+  const MockOperator &op2 = static_cast<const MockOperator &>(
+      query_plan_->getQueryPlanDAG().getNodePayload(id2));
+
+  constructQueryManager();
+
+  // As none of the operators have a blocking link, blocking dependencies should
+  // be met.
+  EXPECT_TRUE(op1.getBlockingDependenciesMet());
+  EXPECT_TRUE(op2.getBlockingDependenciesMet());
+
+  EXPECT_EQ(1, op1.getNumCalls(MockOperator::kGetAllWorkOrders));
+  EXPECT_EQ(1, op1.getNumWorkOrders());
+  EXPECT_EQ(0, op1.getNumCalls(MockOperator::kFeedInputBlock));
+  EXPECT_EQ(0, op1.getNumCalls(MockOperator::kFeedInputBlocks));
+
+  EXPECT_EQ(1, op2.getNumCalls(MockOperator::kGetAllWorkOrders));
+  // op2 will generate workorder only after receiving a streaming input.
+  EXPECT_EQ(0, op2.getNumWorkOrders());
+  EXPECT_EQ(0, op2.getNumCalls(MockOperator::kFeedInputBlock));
+  EXPECT_EQ(0, op2.getNumCalls(MockOperator::kFeedInputBlocks));
+
+  unique_ptr<WorkerMessage> worker_message;
+  worker_message.reset(query_manager_->getNextWorkerMessage(id1, -1));
+
+  EXPECT_TRUE(worker_message != nullptr);
+  EXPECT_EQ(WorkerMessage::WorkerMessageType::kWorkOrder,
+            worker_message->getType());
+  EXPECT_EQ(id1, worker_message->getRelationalOpIndex());
+
+  delete worker_message->getWorkOrder();
+
+  // Send a message to QueryManager upon block getting full (output of op1).
+  EXPECT_FALSE(placeOutputBlockMessage(id1));
+
+  // op1 is not finished yet because the response of workorder completion hasn't
+  // been received yet by the QueryManager.
+  EXPECT_FALSE(getOperatorFinishedStatus(id1));
+  EXPECT_FALSE(getOperatorFinishedStatus(id2));
+
+  // No additional call to op1's getAllWorkOrders.
+  EXPECT_EQ(1, op1.getNumCalls(MockOperator::kGetAllWorkOrders));
+  EXPECT_EQ(0, op1.getNumCalls(MockOperator::kFeedInputBlock));
+  EXPECT_EQ(0, op1.getNumCalls(MockOperator::kFeedInputBlocks));
+
+  // Output from op1 should be fed to op2.
+  EXPECT_EQ(1, op2.getNumCalls(MockOperator::kFeedInputBlock));
+  EXPECT_EQ(0, op2.getNumCalls(MockOperator::kFeedInputBlocks));
+
+  // A call to op2's getAllWorkOrders because of the streamed input.
+  EXPECT_EQ(2, op2.getNumCalls(MockOperator::kGetAllWorkOrders));
+  EXPECT_EQ(1, op2.getNumWorkOrders());
+
+  // Place a message of a workorder completion of op1 on Foreman's input queue.
+  EXPECT_FALSE(placeWorkOrderCompleteMessage(id1));
+
+  EXPECT_EQ(0, getNumWorkOrdersInExecution(id1));
+  EXPECT_TRUE(getOperatorFinishedStatus(id1));
+  EXPECT_EQ(1, op2.getNumCalls(MockOperator::kDoneFeedingInputBlocks));
+
+  // An additional call to op2's getAllWorkOrders because of completion of op1.
+  EXPECT_EQ(3, op2.getNumCalls(MockOperator::kGetAllWorkOrders));
+  EXPECT_EQ(2, op2.getNumWorkOrders());
+
+  worker_message.reset(query_manager_->getNextWorkerMessage(id2, -1));
+
+  EXPECT_TRUE(worker_message != nullptr);
+  EXPECT_EQ(WorkerMessage::WorkerMessageType::kWorkOrder,
+            worker_message->getType());
+  EXPECT_EQ(id2, worker_message->getRelationalOpIndex());
+
+  delete worker_message->getWorkOrder();
+
+  // Place a message of a workorder completion of op2 on Foreman's input queue.
+  EXPECT_FALSE(placeWorkOrderCompleteMessage(id2));
+
+  EXPECT_TRUE(getOperatorFinishedStatus(id1));
+
+  worker_message.reset(query_manager_->getNextWorkerMessage(id2, -1));
+
+  EXPECT_TRUE(worker_message != nullptr);
+  EXPECT_EQ(WorkerMessage::WorkerMessageType::kWorkOrder,
+            worker_message->getType());
+  EXPECT_EQ(id2, worker_message->getRelationalOpIndex());
+
+  delete worker_message->getWorkOrder();
+
+  EXPECT_EQ(1, getNumWorkOrdersInExecution(id2));
+  EXPECT_FALSE(getOperatorFinishedStatus(id2));
+
+  // Send a message to Foreman upon workorder (generated by op2) completion.
+  EXPECT_TRUE(placeWorkOrderCompleteMessage(id2));
+
+  EXPECT_TRUE(getOperatorFinishedStatus(id1));
+  EXPECT_EQ(1, op2.getNumCalls(MockOperator::kDoneFeedingInputBlocks));
+
+  EXPECT_EQ(0, getNumWorkOrdersInExecution(id2));
+  EXPECT_TRUE(getOperatorFinishedStatus(id2));
+}
+
+TEST_F(QueryManagerTest, TwoNodesDAGPartiallyFilledBlocksTest) {
+  // In this test, we create a 2-node DAG with a non-blocking link between them.
+  // There is no streaming of data from op1 to op2 during the execution of op1.
+  // op1 produces a partially filled block at the end of its execution which is
+  // rebuilt and then fed to op2.
+  const QueryPlan::DAGNodeIndex id1 =
+      query_plan_->addRelationalOperator(new MockOperator(true, false, 1));
+  const QueryPlan::DAGNodeIndex id2 =
+      query_plan_->addRelationalOperator(new MockOperator(true, true, 3, 1));
+
+  // Create a non-blocking link.
+  query_plan_->addDirectDependency(id2, id1, false);
+
+  // Create a relation, owned by db_.*/
+  CatalogRelation *relation =
+      new CatalogRelation(nullptr /* catalog_database */, "test_relation");
+  const relation_id output_relation_id = db_->addRelation(relation);
+
+  // Setup the InsertDestination proto in the query context proto.
+  serialization::QueryContext *query_context_proto =
+      query_handle_->getQueryContextProtoMutable();
+
+  const QueryContext::insert_destination_id insert_destination_index =
+      query_context_proto->insert_destinations_size();
+  serialization::InsertDestination *insert_destination_proto =
+      query_context_proto->add_insert_destinations();
+
+  insert_destination_proto->set_insert_destination_type(
+      serialization::InsertDestinationType::BLOCK_POOL);
+  insert_destination_proto->set_relation_id(output_relation_id);
+  insert_destination_proto->set_relational_op_index(id1);
+
+  MockOperator *op1_mutable = static_cast<MockOperator *>(
+      query_plan_->getQueryPlanDAGMutable()->getNodePayloadMutable(id1));
+  op1_mutable->setInsertDestinationID(insert_destination_index);
+  op1_mutable->setOutputRelationID(output_relation_id);
+
+  const MockOperator &op1 = static_cast<const MockOperator &>(
+      query_plan_->getQueryPlanDAG().getNodePayload(id1));
+  const MockOperator &op2 = static_cast<const MockOperator &>(
+      query_plan_->getQueryPlanDAG().getNodePayload(id2));
+
+  constructQueryManager();
+
+  // NOTE(zuyu): An operator generally has no ideas about partially filled
+  // blocks, but InsertDestination in QueryContext does.
+  // Mock to add partially filled blocks in the InsertDestination.
+  InsertDestination *insert_destination =
+      query_manager_->getQueryContextMutable()->getInsertDestination(
+          insert_destination_index);
+  DCHECK(insert_destination != nullptr);
+  MutableBlockReference block_ref;
+  static_cast<BlockPoolInsertDestination *>(insert_destination)
+      ->available_block_refs_.push_back(move(block_ref));
+
+  // There's no blocking dependency in the DAG.
+  EXPECT_TRUE(op1.getBlockingDependenciesMet());
+  EXPECT_TRUE(op2.getBlockingDependenciesMet());
+
+  EXPECT_EQ(1, op1.getNumCalls(MockOperator::kGetAllWorkOrders));
+  EXPECT_EQ(1, op1.getNumWorkOrders());
+
+  EXPECT_EQ(1, op2.getNumCalls(MockOperator::kGetAllWorkOrders));
+  EXPECT_EQ(0, op2.getNumWorkOrders());
+
+  unique_ptr<WorkerMessage> worker_message;
+  worker_message.reset(query_manager_->getNextWorkerMessage(id1, -1));
+
+  EXPECT_TRUE(worker_message != nullptr);
+  EXPECT_EQ(WorkerMessage::WorkerMessageType::kWorkOrder,
+            worker_message->getType());
+  EXPECT_EQ(id1, worker_message->getRelationalOpIndex());
+
+  delete worker_message->getWorkOrder();
+
+  // Send a message to QueryManager upon workorder (generated by op1) completion.
+  EXPECT_FALSE(placeWorkOrderCompleteMessage(id1));
+
+  EXPECT_EQ(0, getNumWorkOrdersInExecution(id1));
+
+  worker_message.reset(query_manager_->getNextWorkerMessage(id1, -1));
+  EXPECT_TRUE(worker_message != nullptr);
+  EXPECT_EQ(WorkerMessage::WorkerMessageType::kRebuildWorkOrder,
+            worker_message->getType());
+
+  EXPECT_EQ(id1, worker_message->getRelationalOpIndex());
+
+  delete worker_message->getWorkOrder();
+
+  // op1 generates a rebuild workorder. The block is rebuilt and streamed
+  // to Foreman.
+  EXPECT_FALSE(placeDataPipelineMessage(id1));
+
+  EXPECT_FALSE(placeRebuildWorkOrderCompleteMessage(id1));
+  // Based on the streamed input, op2's getAllWorkOrders should produce a
+  // workorder.
+  EXPECT_EQ(3, op2.getNumCalls(MockOperator::kGetAllWorkOrders));
+  EXPECT_EQ(1, op2.getNumWorkOrders());
+
+  worker_message.reset(query_manager_->getNextWorkerMessage(id2, -1));
+
+  EXPECT_TRUE(worker_message != nullptr);
+  EXPECT_EQ(WorkerMessage::WorkerMessageType::kWorkOrder,
+            worker_message->getType());
+
+  EXPECT_EQ(id2, worker_message->getRelationalOpIndex());
+
+  delete worker_message->getWorkOrder();
+
+  EXPECT_TRUE(getOperatorFinishedStatus(id1));
+  EXPECT_EQ(1, op2.getNumCalls(MockOperator::kDoneFeedingInputBlocks));
+  EXPECT_FALSE(getOperatorFinishedStatus(id2));
+  EXPECT_EQ(1, getNumWorkOrdersInExecution(id2));
+
+  // Send a message to QueryManager upon workorder (generated by op2) completion.
+  EXPECT_TRUE(placeWorkOrderCompleteMessage(id2));
+
+  EXPECT_EQ(0, getNumWorkOrdersInExecution(id2));
+
+  EXPECT_TRUE(getOperatorFinishedStatus(id2));
+}
+
+TEST_F(QueryManagerTest, MultipleNodesNoOutputTest) {
+  // When an operator produces workorders but no output, the QueryManager should
+  // check the dependents of this operator to make progress.
+  const QueryPlan::DAGNodeIndex kNumNodes = 5;
+  std::vector<QueryPlan::DAGNodeIndex> ids;
+  ids.reserve(kNumNodes);
+
+  for (QueryPlan::DAGNodeIndex i = 0; i < kNumNodes; ++i) {
+    if (i == 0) {
+      ids[i] = query_plan_->addRelationalOperator(new MockOperator(true, false));
+    } else {
+      ids[i] = query_plan_->addRelationalOperator(new MockOperator(true, true));
+    }
+    VLOG(3) << ids[i];
+  }
+
+  /**
+   * The DAG looks like this:
+   *
+   * op1 -> op2 -> op3 -> op4 -> op5
+   *
+   **/
+  for (QueryPlan::DAGNodeIndex i = 0; i < kNumNodes - 1; ++i) {
+    query_plan_->addDirectDependency(ids[i + 1], ids[i], false);
+    static_cast<MockOperator*>(query_plan_->getQueryPlanDAGMutable()->getNodePayloadMutable(ids[i]))
+        ->setOutputRelationID(0xdead);
+  }
+
+  std::vector<const MockOperator*> operators;
+  for (QueryPlan::DAGNodeIndex i = 0; i < kNumNodes; ++i) {
+    operators.push_back(static_cast<const MockOperator*>(&query_plan_->getQueryPlanDAG().getNodePayload(ids[i])));
+  }
+
+  constructQueryManager();
+
+  // operators[0] should have produced a workorder by now.
+  EXPECT_EQ(1, operators[0]->getNumWorkOrders());
+
+  unique_ptr<WorkerMessage> worker_message;
+  worker_message.reset(query_manager_->getNextWorkerMessage(ids[0], -1));
+
+  EXPECT_TRUE(worker_message != nullptr);
+  EXPECT_EQ(WorkerMessage::WorkerMessageType::kWorkOrder,
+            worker_message->getType());
+
+  EXPECT_EQ(ids[0], worker_message->getRelationalOpIndex());
+
+  delete worker_message->getWorkOrder();
+
+  EXPECT_EQ(1, getNumWorkOrdersInExecution(ids[0]));
+  EXPECT_FALSE(getOperatorFinishedStatus(ids[0]));
+
+  for (QueryPlan::DAGNodeIndex i = 0; i < kNumNodes; ++i) {
+    EXPECT_EQ(1, operators[ids[i]]->getNumCalls(MockOperator::kGetAllWorkOrders));
+  }
+
+  // Send a message to QueryManager upon workorder (generated by operators[0])
+  // completion.
+  EXPECT_TRUE(placeWorkOrderCompleteMessage(ids[0]));
+
+  for (QueryPlan::DAGNodeIndex i = 0; i < kNumNodes; ++i) {
+    EXPECT_EQ(0, getNumWorkOrdersInExecution(ids[i]));
+    EXPECT_TRUE(getOperatorFinishedStatus(ids[i]));
+    if (i < kNumNodes - 1) {
+      EXPECT_EQ(1, operators[i + 1]->getNumCalls(MockOperator::kDoneFeedingInputBlocks));
+    }
+  }
+}
+
+TEST_F(QueryManagerTest, OutOfOrderWorkOrderCompletionTest) {
+  // Consider two operators, both generate one workorder each. The dependent's
+  // workorder finishes before dependency's workorder.
+  const QueryPlan::DAGNodeIndex id1 = query_plan_->addRelationalOperator(new MockOperator(true, false, 1));
+  const QueryPlan::DAGNodeIndex id2 = query_plan_->addRelationalOperator(new MockOperator(true, true, 2, 1));
+
+  // Create a non-blocking link.
+  query_plan_->addDirectDependency(id2, id1, false);
+
+  constructQueryManager();
+
+  unique_ptr<WorkerMessage> worker_message;
+  worker_message.reset(query_manager_->getNextWorkerMessage(id1, -1));
+
+  EXPECT_TRUE(worker_message != nullptr);
+  EXPECT_EQ(WorkerMessage::WorkerMessageType::kWorkOrder,
+            worker_message->getType());
+
+  EXPECT_EQ(id1, worker_message->getRelationalOpIndex());
+
+  delete worker_message->getWorkOrder();
+
+  // Send a message to QueryManager upon a block (output of op1) getting full.
+  EXPECT_FALSE(placeOutputBlockMessage(id1));
+
+  // op1 is not finished yet because the response of workorder completion hasn't
+  // been received yet.
+  EXPECT_FALSE(getOperatorFinishedStatus(id1));
+  EXPECT_FALSE(getOperatorFinishedStatus(id2));
+
+  worker_message.reset(query_manager_->getNextWorkerMessage(id2, -1));
+  EXPECT_TRUE(worker_message != nullptr);
+  EXPECT_EQ(WorkerMessage::WorkerMessageType::kWorkOrder,
+            worker_message->getType());
+
+  EXPECT_EQ(id2, worker_message->getRelationalOpIndex());
+
+  delete worker_message->getWorkOrder();
+
+  // As mentioned earlier, op2 finishes before op1.
+  EXPECT_FALSE(placeWorkOrderCompleteMessage(id2));
+
+  // op1's workorder execution is over.
+  EXPECT_TRUE(placeWorkOrderCompleteMessage(id1));
+
+  EXPECT_TRUE(getOperatorFinishedStatus(id1));
+  EXPECT_TRUE(getOperatorFinishedStatus(id2));
+}
+
+}  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/d3725840/storage/InsertDestination.hpp
----------------------------------------------------------------------
diff --git a/storage/InsertDestination.hpp b/storage/InsertDestination.hpp
index a2ed029..670cd6c 100644
--- a/storage/InsertDestination.hpp
+++ b/storage/InsertDestination.hpp
@@ -387,6 +387,7 @@ class BlockPoolInsertDestination : public InsertDestination {
 
  private:
   FRIEND_TEST(ForemanTest, TwoNodesDAGPartiallyFilledBlocksTest);
+  FRIEND_TEST(QueryManagerTest, TwoNodesDAGPartiallyFilledBlocksTest);
 
   // A vector of references to blocks which are loaded in memory.
   std::vector<MutableBlockReference> available_block_refs_;


[04/24] incubator-quickstep git commit: Style fix for EXISTS subquery related changes (#165)

Posted by zu...@apache.org.
Style fix for EXISTS subquery related changes (#165)

Project: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/commit/914f2d80
Tree: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/tree/914f2d80
Diff: http://git-wip-us.apache.org/repos/asf/incubator-quickstep/diff/914f2d80

Branch: refs/heads/master
Commit: 914f2d8082e65b61bfe5be413fc1bf20fd1c7329
Parents: 57e12d5
Author: Jianqiao Zhu <ji...@cs.wisc.edu>
Authored: Thu Apr 14 11:52:09 2016 -0500
Committer: Zuyu ZHANG <zu...@users.noreply.github.com>
Committed: Thu Apr 14 09:52:09 2016 -0700

----------------------------------------------------------------------
 query_optimizer/expressions/CMakeLists.txt         |  2 ++
 query_optimizer/expressions/Exists.cpp             |  7 +++++--
 query_optimizer/expressions/Exists.hpp             | 10 +++++++++-
 query_optimizer/expressions/ExpressionUtil.cpp     |  2 +-
 query_optimizer/expressions/PatternMatcher.hpp     |  5 +++++
 query_optimizer/expressions/SubqueryExpression.cpp |  9 ++++++---
 query_optimizer/expressions/SubqueryExpression.hpp | 10 +++++++---
 query_optimizer/resolver/NameResolver.hpp          |  2 +-
 8 files changed, 36 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/914f2d80/query_optimizer/expressions/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/CMakeLists.txt b/query_optimizer/expressions/CMakeLists.txt
index 470bfb9..ca064dc 100644
--- a/query_optimizer/expressions/CMakeLists.txt
+++ b/query_optimizer/expressions/CMakeLists.txt
@@ -120,6 +120,7 @@ target_link_libraries(quickstep_queryoptimizer_expressions_ComparisonExpression
 target_link_libraries(quickstep_queryoptimizer_expressions_Exists
                       quickstep_queryoptimizer_OptimizerTree
                       quickstep_queryoptimizer_expressions_AttributeReference
+                      quickstep_queryoptimizer_expressions_ExprId
                       quickstep_queryoptimizer_expressions_Expression
                       quickstep_queryoptimizer_expressions_ExpressionType
                       quickstep_queryoptimizer_expressions_Predicate
@@ -254,6 +255,7 @@ target_link_libraries(quickstep_queryoptimizer_expressions_SubqueryExpression
                       glog
                       quickstep_queryoptimizer_OptimizerTree
                       quickstep_queryoptimizer_expressions_AttributeReference
+                      quickstep_queryoptimizer_expressions_ExprId
                       quickstep_queryoptimizer_expressions_Expression
                       quickstep_queryoptimizer_expressions_ExpressionType
                       quickstep_queryoptimizer_expressions_Scalar

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/914f2d80/query_optimizer/expressions/Exists.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/Exists.cpp b/query_optimizer/expressions/Exists.cpp
index 12d3a8b..2bb5a6b 100644
--- a/query_optimizer/expressions/Exists.cpp
+++ b/query_optimizer/expressions/Exists.cpp
@@ -21,10 +21,15 @@
 #include <string>
 
 #include "query_optimizer/OptimizerTree.hpp"
+#include "query_optimizer/expressions/ExprId.hpp"
 
 #include "glog/logging.h"
 
 namespace quickstep {
+
+class CatalogAttribute;
+class Predicate;
+
 namespace optimizer {
 namespace expressions {
 
@@ -34,7 +39,6 @@ namespace expressions {
   return nullptr;
 }
 
-
 void Exists::getFieldStringItems(
     std::vector<std::string> *inline_field_names,
     std::vector<std::string> *inline_field_values,
@@ -46,7 +50,6 @@ void Exists::getFieldStringItems(
   non_container_child_fields->push_back(exists_subquery_);
 }
 
-
 }  // namespace expressions
 }  // namespace optimizer
 }  // namespace quickstep

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/914f2d80/query_optimizer/expressions/Exists.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/Exists.hpp b/query_optimizer/expressions/Exists.hpp
index dd951c5..6293020 100644
--- a/query_optimizer/expressions/Exists.hpp
+++ b/query_optimizer/expressions/Exists.hpp
@@ -20,17 +20,25 @@
 
 #include <memory>
 #include <string>
+#include <unordered_map>
 #include <vector>
 
 #include "query_optimizer/OptimizerTree.hpp"
 #include "query_optimizer/expressions/AttributeReference.hpp"
+#include "query_optimizer/expressions/ExprId.hpp"
 #include "query_optimizer/expressions/Expression.hpp"
 #include "query_optimizer/expressions/ExpressionType.hpp"
 #include "query_optimizer/expressions/Predicate.hpp"
 #include "query_optimizer/expressions/SubqueryExpression.hpp"
 #include "utility/Macros.hpp"
 
+#include "glog/logging.h"
+
 namespace quickstep {
+
+class CatalogAttribute;
+class Predicate;
+
 namespace optimizer {
 namespace expressions {
 
@@ -67,7 +75,7 @@ class Exists : public Predicate {
 
   ExpressionPtr copyWithNewChildren(
       const std::vector<ExpressionPtr> &new_children) const override {
-    DCHECK_EQ(new_children.size(), 1u);
+    DCHECK_EQ(1u, new_children.size());
     return Create(std::static_pointer_cast<const SubqueryExpression>(new_children[0]));
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/914f2d80/query_optimizer/expressions/ExpressionUtil.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/ExpressionUtil.cpp b/query_optimizer/expressions/ExpressionUtil.cpp
index 3481d6c..5cf7759 100644
--- a/query_optimizer/expressions/ExpressionUtil.cpp
+++ b/query_optimizer/expressions/ExpressionUtil.cpp
@@ -41,7 +41,7 @@ std::vector<AttributeReferencePtr> GetAttributeReferencesWithinScope(
     const std::vector<AttributeReferencePtr> &attributes,
     const AttributeReferenceScope scope) {
   std::vector<AttributeReferencePtr> filtered_attributes;
-  for (const auto& attr_it : attributes) {
+  for (const auto &attr_it : attributes) {
     if (attr_it->scope() == scope) {
       filtered_attributes.emplace_back(attr_it);
     }

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/914f2d80/query_optimizer/expressions/PatternMatcher.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/PatternMatcher.hpp b/query_optimizer/expressions/PatternMatcher.hpp
index 4c5432d..528b1e6 100644
--- a/query_optimizer/expressions/PatternMatcher.hpp
+++ b/query_optimizer/expressions/PatternMatcher.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.
@@ -35,6 +37,7 @@ class BinaryExpression;
 class Cast;
 class ComparisonExpression;
 class Count;
+class Exists;
 class LogicalAnd;
 class LogicalNot;
 class LogicalOr;
@@ -115,6 +118,7 @@ using SomeAttributeReference = SomeExpressionNode<AttributeReference, Expression
 using SomeBinaryExpression = SomeExpressionNode<BinaryExpression, ExpressionType::kBinaryExpression>;
 using SomeCast = SomeExpressionNode<Cast, ExpressionType::kCast>;
 using SomeComparisonExpression = SomeExpressionNode<ComparisonExpression, ExpressionType::kComparisonExpression>;
+using SomeExists = SomeExpressionNode<Exists, ExpressionType::kExists>;
 using SomeLogicalAnd = SomeExpressionNode<LogicalAnd, ExpressionType::kLogicalAnd>;
 using SomeLogicalNot = SomeExpressionNode<LogicalNot, ExpressionType::kLogicalNot>;
 using SomeLogicalOr = SomeExpressionNode<LogicalOr, ExpressionType::kLogicalOr>;
@@ -123,6 +127,7 @@ using SomeNamedExpression = SomeExpressionNode<NamedExpression,
                                                ExpressionType::kAlias>;
 using SomePredicate = SomeExpressionNode<Predicate,
                                          ExpressionType::kComparisonExpression,
+                                         ExpressionType::kExists,
                                          ExpressionType::kLogicalAnd,
                                          ExpressionType::kLogicalNot,
                                          ExpressionType::kLogicalOr,

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/914f2d80/query_optimizer/expressions/SubqueryExpression.cpp
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/SubqueryExpression.cpp b/query_optimizer/expressions/SubqueryExpression.cpp
index f1a97ca..0459212 100644
--- a/query_optimizer/expressions/SubqueryExpression.cpp
+++ b/query_optimizer/expressions/SubqueryExpression.cpp
@@ -22,24 +22,27 @@
 
 #include "query_optimizer/OptimizerTree.hpp"
 #include "query_optimizer/expressions/AttributeReference.hpp"
+#include "query_optimizer/expressions/ExprId.hpp"
 
 #include "glog/logging.h"
 
 namespace quickstep {
+
+class CatalogAttribute;
+class Scalar;
+
 namespace optimizer {
 namespace expressions {
 
 ::quickstep::Scalar* SubqueryExpression::concretize(
-    const std::unordered_map<ExprId, const CatalogAttribute*>& substitution_map) const {
+    const std::unordered_map<ExprId, const CatalogAttribute*> &substitution_map) const {
   LOG(FATAL) << "SubqueryExpression should not be concretized";
-  return nullptr;
 }
 
 std::vector<AttributeReferencePtr> SubqueryExpression::getReferencedAttributes() const {
   // SubqueryExpression should be eliminated before any place that needs
   // a call of getReferencedAttributes.
   LOG(FATAL) << "SubqueryExpression::getReferencedAttributes() is not implemented";
-  return {};
 }
 
 void SubqueryExpression::getFieldStringItems(

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/914f2d80/query_optimizer/expressions/SubqueryExpression.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/expressions/SubqueryExpression.hpp b/query_optimizer/expressions/SubqueryExpression.hpp
index e0e2733..58fb6e8 100644
--- a/query_optimizer/expressions/SubqueryExpression.hpp
+++ b/query_optimizer/expressions/SubqueryExpression.hpp
@@ -20,9 +20,11 @@
 
 #include <memory>
 #include <string>
+#include <unordered_map>
 #include <vector>
 
 #include "query_optimizer/expressions/AttributeReference.hpp"
+#include "query_optimizer/expressions/ExprId.hpp"
 #include "query_optimizer/expressions/Expression.hpp"
 #include "query_optimizer/expressions/ExpressionType.hpp"
 #include "query_optimizer/expressions/Scalar.hpp"
@@ -34,6 +36,8 @@
 
 namespace quickstep {
 
+class CatalogAttribute;
+class Scalar;
 class Type;
 
 namespace optimizer {
@@ -81,7 +85,7 @@ class SubqueryExpression : public Scalar {
   }
 
   ::quickstep::Scalar* concretize(
-      const std::unordered_map<ExprId, const CatalogAttribute*>& substitution_map) const override;
+      const std::unordered_map<ExprId, const CatalogAttribute*> &substitution_map) const override;
 
   /**
    * @brief Creates a subquery expression.
@@ -90,7 +94,7 @@ class SubqueryExpression : public Scalar {
    * @param subquery The logical subquery node.
    * @return An immutable SubqueryExpression.
    */
-  static SubqueryExpressionPtr Create(const logical::LogicalPtr& subquery) {
+  static SubqueryExpressionPtr Create(const logical::LogicalPtr &subquery) {
     return SubqueryExpressionPtr(new SubqueryExpression(subquery));
   }
 
@@ -104,7 +108,7 @@ class SubqueryExpression : public Scalar {
       std::vector<std::vector<OptimizerTreeBaseNodePtr>> *container_child_fields) const override;
 
  private:
-  explicit SubqueryExpression(const logical::LogicalPtr& subquery)
+  explicit SubqueryExpression(const logical::LogicalPtr &subquery)
       : subquery_(subquery),
         output_attribute_(subquery->getOutputAttributes()[0]) {
     DCHECK(!subquery->getOutputAttributes().empty());

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/914f2d80/query_optimizer/resolver/NameResolver.hpp
----------------------------------------------------------------------
diff --git a/query_optimizer/resolver/NameResolver.hpp b/query_optimizer/resolver/NameResolver.hpp
index 4809fe8..6aed904 100644
--- a/query_optimizer/resolver/NameResolver.hpp
+++ b/query_optimizer/resolver/NameResolver.hpp
@@ -51,7 +51,7 @@ class NameResolver {
    * @brief Constructor.
    *
    * @param parent_resolver The NameResolver inherited from the outer query.
-   *                        NULL if there is no outer query.
+   *        NULL if there is no outer query.
    */
   explicit NameResolver(const NameResolver *parent_resolver = nullptr)
       : parent_resolver_(parent_resolver) {}