beam-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Work logged] (BEAM-4044) Take advantage of Calcite DDL
Date Wed, 11 Apr 2018 06:49:00 GMT

     [ https://issues.apache.org/jira/browse/BEAM-4044?focusedWorklogId=89806&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-89806
]

ASF GitHub Bot logged work on BEAM-4044:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 11/Apr/18 06:48
            Start Date: 11/Apr/18 06:48
    Worklog Time Spent: 10m 
      Work Description: XuMingmin commented on a change in pull request #5040: [BEAM-4044]
[SQL] Refresh DDL from 1.16
URL: https://github.com/apache/beam/pull/5040#discussion_r180647797
 
 

 ##########
 File path: sdks/java/extensions/sql/src/main/codegen/includes/parserImpls.ftl
 ##########
 @@ -1,106 +1,154 @@
-<#-- Licensed to the Apache Software Foundation (ASF) under one or more contributor
-  license agreements. See the NOTICE file distributed with this work for additional
-  information regarding copyright ownership. The ASF licenses this file to
-  You under the Apache License, Version 2.0 (the "License"); you may not use
-  this file except in compliance with the License. You may obtain a copy of
-  the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required
-  by applicable law or agreed to in writing, software distributed under the
-  License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS
-  OF ANY KIND, either express or implied. See the License for the specific
-  language governing permissions and limitations under the License. -->
+<#--
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements.  See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to you under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License.  You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+-->
 
+boolean IfNotExistsOpt() :
+{
+}
+{
+    <IF> <NOT> <EXISTS> { return true; }
+|
+    { return false; }
+}
 
-private void ColumnDef(List<ColumnDefinition> list) :
+boolean IfExistsOpt() :
 {
-    SqlParserPos pos;
-    SqlIdentifier name;
-    SqlDataTypeSpec type;
-    ColumnConstraint constraint = null;
-    SqlNode comment = null;
 }
 {
-    name = SimpleIdentifier() { pos = getPos(); }
-    type = DataType()
-    [
-      <PRIMARY> <KEY>
-      { constraint = new ColumnConstraint.PrimaryKey(getPos()); }
-    ]
+    <IF> <EXISTS> { return true; }
+|
+    { return false; }
+}
+
+SqlNodeList Options() :
+{
+    final Span s;
+    final List<SqlNode> list = Lists.newArrayList();
+}
+{
+    <OPTIONS> { s = span(); } <LPAREN>
     [
-      <COMMENT> comment = StringLiteral()
+        Option(list)
+        (
+            <COMMA>
+            Option(list)
+        )*
     ]
-    {
-        list.add(new ColumnDefinition(name, type, constraint, comment, pos));
+    <RPAREN> {
+        return new SqlNodeList(list, s.end(this));
     }
 }
 
-SqlNodeList ColumnDefinitionList() :
+void Option(List<SqlNode> list) :
 {
-    SqlParserPos pos;
-    List<ColumnDefinition> list = Lists.newArrayList();
+    final SqlIdentifier id;
+    final SqlNode value;
 }
 {
-    <LPAREN> { pos = getPos(); }
-    ColumnDef(list)
-    ( <COMMA> ColumnDef(list) )*
+    id = SimpleIdentifier()
+    value = Literal() {
+        list.add(id);
+        list.add(value);
+    }
+}
+
+SqlNodeList TableElementList() :
+{
+    final Span s;
+    final List<SqlNode> list = Lists.newArrayList();
+}
+{
+    <LPAREN> { s = span(); }
+    TableElement(list)
+    (
+        <COMMA> TableElement(list)
+    )*
     <RPAREN> {
-        return new SqlNodeList(list, pos.plus(getPos()));
+        return new SqlNodeList(list, s.end(this));
+    }
+}
+
+void TableElement(List<SqlNode> list) :
+{
+    final SqlIdentifier id;
+    final SqlDataTypeSpec type;
+    final boolean nullable;
+    SqlNode comment = null;
+    final Span s = Span.of();
+}
+{
+    id = SimpleIdentifier()
+    (
+        type = DataType()
+        (
+            <NULL> { nullable = true; }
+        |
+            <NOT> <NULL> { nullable = false; }
+        |
+            { nullable = true; }
+        )
+        [ <COMMENT> comment = StringLiteral() ]
+        {
+            list.add(
+                SqlDdlNodes.column(s.add(id).end(this), id,
+                    type.withNullable(nullable), comment));
+        }
+    |
+        { list.add(id); }
+    )
+|
+    id = SimpleIdentifier() {
+        list.add(id);
     }
 }
 
-/**
- * CREATE TABLE ( IF NOT EXISTS )?
- *   ( database_name '.' )? table_name ( '(' column_def ( ',' column_def )* ')'
- *   ( STORED AS INPUTFORMAT input_format_classname OUTPUTFORMAT output_format_classname
)?
- *   LOCATION location_uri
- *   ( TBLPROPERTIES tbl_properties )?
- *   ( AS select_stmt )
- */
-SqlNode SqlCreateTable() :
-{
-    SqlParserPos pos;
-    SqlIdentifier tblName;
-    SqlNodeList fieldList;
+SqlCreate SqlCreateTable(Span s, boolean replace) :
+{
+    final boolean ifNotExists;
+    final SqlIdentifier id;
+    SqlNodeList tableElementList = null;
     SqlNode type = null;
     SqlNode comment = null;
     SqlNode location = null;
-    SqlNode tbl_properties = null;
-    SqlNode select = null;
+    SqlNode tblProperties = null;
+    SqlNode query = null;
 }
 {
-    <CREATE> { pos = getPos(); }
-    <TABLE>
-    tblName = CompoundIdentifier()
-    fieldList = ColumnDefinitionList()
-    <TYPE>
-    type = StringLiteral()
-    [
-    <COMMENT>
-    comment = StringLiteral()
-    ]
-    [
-    <LOCATION>
-    location = StringLiteral()
-    ]
-    [ <TBLPROPERTIES> tbl_properties = StringLiteral() ]
-    [ <AS> select = OrderedQueryOrExpr(ExprContext.ACCEPT_QUERY) ] {
-        return new SqlCreateTable(pos, tblName, fieldList, type, comment,
-        location, tbl_properties, select);
+    <TABLE> ifNotExists = IfNotExistsOpt() id = CompoundIdentifier()
+    [ tableElementList = TableElementList() ]
+    <TYPE> type = StringLiteral()
+    [ <COMMENT> comment = StringLiteral() ]
+    [ <LOCATION> location = StringLiteral() ]
+    [ <TBLPROPERTIES> tblProperties = StringLiteral() ]
+    [ <AS> query = OrderedQueryOrExpr(ExprContext.ACCEPT_QUERY) ]
 
 Review comment:
   How about remove the `query` statement here as it's not implemented actually? IMO we should
separate `CREATE TABLE XX AS SELECT ...` from standard CREATE DDL. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Issue Time Tracking
-------------------

    Worklog Id:     (was: 89806)
    Time Spent: 1h 50m  (was: 1h 40m)

> Take advantage of Calcite DDL
> -----------------------------
>
>                 Key: BEAM-4044
>                 URL: https://issues.apache.org/jira/browse/BEAM-4044
>             Project: Beam
>          Issue Type: New Feature
>          Components: dsl-sql
>            Reporter: Andrew Pilloud
>            Assignee: Andrew Pilloud
>            Priority: Major
>          Time Spent: 1h 50m
>  Remaining Estimate: 0h
>
> In Calcite 1.15 support for abstract DDL moved into calcite core. We should take advantage
of that.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message