quickstep-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jianq...@apache.org
Subject [3/3] incubator-quickstep git commit: Support Multiple Tuple Inserts
Date Wed, 25 Oct 2017 20:02:21 GMT
Support Multiple Tuple Inserts

Update Fetch


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

Branch: refs/heads/master
Commit: 0fe838dfeac901ff03b8334da46b7b9f364447e3
Parents: 79bfcf9
Author: Robert Claus <robertclaus@gmail.com>
Authored: Tue Oct 24 18:08:57 2017 -0500
Committer: Robert Claus <robertclaus@gmail.com>
Committed: Wed Oct 25 13:24:02 2017 -0500

----------------------------------------------------------------------
 parser/ParseStatement.hpp                |   22 +-
 parser/SqlParser.ypp                     |   18 +-
 parser/preprocessed/SqlParser_gen.cpp    | 2646 +++++++++++++------------
 parser/preprocessed/SqlParser_gen.hpp    |    3 +-
 query_optimizer/ExecutionGenerator.cpp   |  110 +-
 query_optimizer/logical/InsertTuple.cpp  |    6 +-
 query_optimizer/logical/InsertTuple.hpp  |   10 +-
 query_optimizer/physical/InsertTuple.cpp |    6 +-
 query_optimizer/physical/InsertTuple.hpp |    8 +-
 query_optimizer/resolver/Resolver.cpp    |  122 +-
 10 files changed, 1503 insertions(+), 1448 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fe838df/parser/ParseStatement.hpp
----------------------------------------------------------------------
diff --git a/parser/ParseStatement.hpp b/parser/ParseStatement.hpp
index cee7221..456bdc2 100644
--- a/parser/ParseStatement.hpp
+++ b/parser/ParseStatement.hpp
@@ -653,9 +653,9 @@ class ParseStatementInsertTuple : public ParseStatementInsert {
   ParseStatementInsertTuple(const int line_number,
                             const int column_number,
                             const ParseString *relation_name,
-                            PtrList<ParseScalarLiteral> *literal_values)
+                            PtrList<PtrList<ParseScalarLiteral>> *literal_values_list)
       : ParseStatementInsert(line_number, column_number, relation_name),
-        literal_values_(literal_values) {
+        literal_values_(literal_values_list) {
   }
 
   ~ParseStatementInsertTuple() override {
@@ -666,11 +666,11 @@ class ParseStatementInsertTuple : public ParseStatementInsert {
   }
 
   /**
-   * @brief Get the parsed literal attribute values to insert.
+   * @brief Get the list of list of parsed literal attribute values to insert.
    *
-   * @return The list of literal values to insert.
+   * @return The list of lists of literal values to insert.
    **/
-  const PtrList<ParseScalarLiteral>& getLiteralValues() const {
+  const PtrList<PtrList<ParseScalarLiteral>>& getLiteralValues() const {
     return *literal_values_;
   }
 
@@ -685,15 +685,17 @@ class ParseStatementInsertTuple : public ParseStatementInsert {
     inline_field_names->push_back("relation_name");
     inline_field_values->push_back(relation_name()->value());
 
-    container_child_field_names->push_back("tuple");
-    container_child_fields->emplace_back();
-    for (const ParseScalarLiteral& literal_value : *literal_values_) {
-      container_child_fields->back().push_back(&literal_value);
+    for (const PtrList<ParseScalarLiteral>& literal_values_single_tuple : *literal_values_)
{
+      container_child_field_names->push_back("tuple");
+      container_child_fields->emplace_back();
+      for (const ParseScalarLiteral& literal_value : literal_values_single_tuple) {
+        container_child_fields->back().push_back(&literal_value);
+      }
     }
   }
 
  private:
-  std::unique_ptr<PtrList<ParseScalarLiteral> > literal_values_;
+  std::unique_ptr<PtrList<PtrList<ParseScalarLiteral>>> literal_values_;
 
   DISALLOW_COPY_AND_ASSIGN(ParseStatementInsertTuple);
 };

http://git-wip-us.apache.org/repos/asf/incubator-quickstep/blob/0fe838df/parser/SqlParser.ypp
----------------------------------------------------------------------
diff --git a/parser/SqlParser.ypp b/parser/SqlParser.ypp
index 8fbcdd7..ba69b3d 100644
--- a/parser/SqlParser.ypp
+++ b/parser/SqlParser.ypp
@@ -128,6 +128,7 @@ typedef void* yyscan_t;
   quickstep::NumericParseLiteralValue *numeric_literal_value_;
   quickstep::ParseLiteralValue *literal_value_;
   quickstep::PtrList<quickstep::ParseScalarLiteral> *literal_value_list_;
+  quickstep::PtrList<quickstep::PtrList<quickstep::ParseScalarLiteral>> *literal_value_list_multiple_;
 
   quickstep::ParseExpression *expression_;
 
@@ -387,6 +388,9 @@ void NotSupported(const YYLTYPE *location, yyscan_t yyscanner, const std::string
 %type <literal_value_list_>
   literal_value_commalist
 
+%type <literal_value_list_multiple_>
+  literal_value_commalist_multiple
+
 %type <expression_>
   expression_base
   unary_expression
@@ -1101,8 +1105,8 @@ insert_statement:
     NotSupported(&@4, yyscanner, "list of column names in INSERT statement");
     YYERROR;
   }
-  | TOKEN_INSERT TOKEN_INTO any_name TOKEN_VALUES '(' literal_value_commalist ')' {
-    $$ = new quickstep::ParseStatementInsertTuple(@1.first_line, @1.first_column, $3, $6);
+  | TOKEN_INSERT TOKEN_INTO any_name TOKEN_VALUES literal_value_commalist_multiple {
+    $$ = new quickstep::ParseStatementInsertTuple(@1.first_line, @1.first_column, $3, $5);
   }
   | TOKEN_INSERT TOKEN_INTO any_name select_query {
     $$ = new quickstep::ParseStatementInsertSelection(@1.first_line, @2.first_column, $3,
$4, nullptr);
@@ -1921,6 +1925,16 @@ literal_value_commalist:
     $$->push_back(new quickstep::ParseScalarLiteral($3));
   };
 
+literal_value_commalist_multiple:
+  '(' literal_value_commalist ')' {
+    $$ = new quickstep::PtrList<quickstep::PtrList<quickstep::ParseScalarLiteral>>();
+    $$->push_back($2);
+  }
+  | literal_value_commalist_multiple ',' '(' literal_value_commalist ')' {
+    $$ = $1;
+    $$->push_back($4);
+  };
+
 attribute_ref:
   any_name {
     $$ = new quickstep::ParseAttribute(@1.first_line, @1.first_column, $1);


Mime
View raw message