You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2020/01/13 08:31:04 UTC

[GitHub] [flink] wuchong opened a new pull request #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL

wuchong opened a new pull request #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL
URL: https://github.com/apache/flink/pull/10839
 
 
   
   <!--
   *Thank you very much for contributing to Apache Flink - we are happy that you want to help us improve Flink. To help the community review your contribution in the best possible way, please go through the checklist below, which will get the contribution into a shape in which it can be best reviewed.*
   
   *Please understand that we do not do this to make contributions to Flink a hassle. In order to uphold a high standard of quality for code contributions, while at the same time managing a large number of contributions, we need contributors to prepare the contributions well, and give reviewers enough contextual information for the review. Please also understand that contributions that do not follow this guide will take longer to review and thus typically be picked up with lower priority by the community.*
   
   ## Contribution Checklist
   
     - Make sure that the pull request corresponds to a [JIRA issue](https://issues.apache.org/jira/projects/FLINK/issues). Exceptions are made for typos in JavaDoc or documentation files, which need no JIRA issue.
     
     - Name the pull request in the form "[FLINK-XXXX] [component] Title of the pull request", where *FLINK-XXXX* should be replaced by the actual issue number. Skip *component* if you are unsure about which is the best component.
     Typo fixes that have no associated JIRA issue should be named following this pattern: `[hotfix] [docs] Fix typo in event time introduction` or `[hotfix] [javadocs] Expand JavaDoc for PuncuatedWatermarkGenerator`.
   
     - Fill out the template below to describe the changes contributed by the pull request. That will give reviewers the context they need to do the review.
     
     - Make sure that the change passes the automated tests, i.e., `mvn clean verify` passes. You can set up Travis CI to do that following [this guide](https://flink.apache.org/contributing/contribute-code.html#open-a-pull-request).
   
     - Each pull request should address only one issue, not mix up code from multiple issues.
     
     - Each commit in the pull request has a meaningful commit message (including the JIRA id)
   
     - Once all items of the checklist are addressed, remove the above text and this checklist, leaving only the filled out template below.
   
   
   **(The sections below can be removed for hotfixes of typos)**
   -->
   
   ## What is the purpose of the change
   
   We missed to add documentation for INSERT statements which should be added under "SQL" page.
   
   ## Brief change log
   
   Add `insert.md` and `insert.zh.md` under `sql` directory.
   
   ## Verifying this change
   
   No tests required. 
   
   ## Does this pull request potentially affect one of the following parts:
   
     - Dependencies (does it add or upgrade a dependency): (yes / **no**)
     - The public API, i.e., is any changed class annotated with `@Public(Evolving)`: (yes / **no**)
     - The serializers: (yes / **no** / don't know)
     - The runtime per-record code paths (performance sensitive): (yes / **no** / don't know)
     - Anything that affects deployment or recovery: JobManager (and its components), Checkpointing, Yarn/Mesos, ZooKeeper: (yes / **no** / don't know)
     - The S3 file system connector: (yes / **no** / don't know)
   
   ## Documentation
   
     - Does this pull request introduce a new feature? (yes / **no**)
     - If yes, how is the feature documented? (**not applicable** / docs / JavaDocs / not documented)
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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


With regards,
Apache Git Services

[GitHub] [flink] JingsongLi commented on issue #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on issue #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL
URL: https://github.com/apache/flink/pull/10839#issuecomment-573978938
 
 
   LGTM

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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


With regards,
Apache Git Services

[GitHub] [flink] flinkbot commented on issue #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL

Posted by GitBox <gi...@apache.org>.
flinkbot commented on issue #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL
URL: https://github.com/apache/flink/pull/10839#issuecomment-573556957
 
 
   Thanks a lot for your contribution to the Apache Flink project. I'm the @flinkbot. I help the community
   to review your pull request. We will use this comment to track the progress of the review.
   
   
   ## Automated Checks
   Last check on commit c5595ea0c994dcf664cb68ec45a6f500e705a3b7 (Mon Jan 13 08:33:21 UTC 2020)
   
    ✅no warnings
   
   <sub>Mention the bot in a comment to re-run the automated checks.</sub>
   ## Review Progress
   
   * ❓ 1. The [description] looks good.
   * ❓ 2. There is [consensus] that the contribution should go into to Flink.
   * ❓ 3. Needs [attention] from.
   * ❓ 4. The change fits into the overall [architecture].
   * ❓ 5. Overall code [quality] is good.
   
   Please see the [Pull Request Review Guide](https://flink.apache.org/contributing/reviewing-prs.html) for a full explanation of the review process.<details>
    The Bot is tracking the review progress through labels. Labels are applied according to the order of the review items. For consensus, approval by a Flink committer of PMC member is required <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot approve description` to approve one or more aspects (aspects: `description`, `consensus`, `architecture` and `quality`)
    - `@flinkbot approve all` to approve all aspects
    - `@flinkbot approve-until architecture` to approve everything until `architecture`
    - `@flinkbot attention @username1 [@username2 ..]` to require somebody's attention
    - `@flinkbot disapprove architecture` to remove an approval you gave earlier
   </details>

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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


With regards,
Apache Git Services

[GitHub] [flink] flinkbot edited a comment on issue #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on issue #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL
URL: https://github.com/apache/flink/pull/10839#issuecomment-573563076
 
 
   <!--
   Meta data
   Hash:c5595ea0c994dcf664cb68ec45a6f500e705a3b7 Status:SUCCESS URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4285 TriggerType:PUSH TriggerID:c5595ea0c994dcf664cb68ec45a6f500e705a3b7
   Hash:c5595ea0c994dcf664cb68ec45a6f500e705a3b7 Status:FAILURE URL:https://travis-ci.com/flink-ci/flink/builds/144113663 TriggerType:PUSH TriggerID:c5595ea0c994dcf664cb68ec45a6f500e705a3b7
   -->
   ## CI report:
   
   * c5595ea0c994dcf664cb68ec45a6f500e705a3b7 Travis: [FAILURE](https://travis-ci.com/flink-ci/flink/builds/144113663) Azure: [SUCCESS](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4285) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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


With regards,
Apache Git Services

[GitHub] [flink] wuchong merged pull request #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL

Posted by GitBox <gi...@apache.org>.
wuchong merged pull request #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL
URL: https://github.com/apache/flink/pull/10839
 
 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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


With regards,
Apache Git Services

[GitHub] [flink] JingsongLi commented on a change in pull request #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL
URL: https://github.com/apache/flink/pull/10839#discussion_r366131547
 
 

 ##########
 File path: docs/dev/table/sql/insert.md
 ##########
 @@ -125,20 +125,28 @@ part_spec:
 ### Examples
 
 {% highlight sql %}
-
 -- Creates a partitioned table
 CREATE TABLE country_page_view (user STRING, cnt INT, date STRING, country STRING)
 PARTITIONED BY (date, country)
 WITH (...)
 
--- Appends rows into the partition (date='2019-8-30', country='China')
+-- Appends rows into the static partition (date='2019-8-30', country='China')
 INSERT INTO country_page_view PARTITION (date='2019-8-30', country='China')
   SELECT user, cnt FROM page_view_source;
 
--- Overwrites the partition (date='2019-8-30', country='China') using rows in page_view_source
+-- Appends rows into partition (date, country), where date is static partition with value '2019-8-30',
+-- country is dynamic partition whose value is dynamic determined by each row.
 INSERT INTO country_page_view PARTITION (date='2019-8-30', country='China')
 
 Review comment:
   Remove `, country='China'`

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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


With regards,
Apache Git Services

[GitHub] [flink] flinkbot edited a comment on issue #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on issue #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL
URL: https://github.com/apache/flink/pull/10839#issuecomment-573563076
 
 
   <!--
   Meta data
   Hash:c5595ea0c994dcf664cb68ec45a6f500e705a3b7 Status:SUCCESS URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4285 TriggerType:PUSH TriggerID:c5595ea0c994dcf664cb68ec45a6f500e705a3b7
   Hash:c5595ea0c994dcf664cb68ec45a6f500e705a3b7 Status:PENDING URL:https://travis-ci.com/flink-ci/flink/builds/144113663 TriggerType:PUSH TriggerID:c5595ea0c994dcf664cb68ec45a6f500e705a3b7
   -->
   ## CI report:
   
   * c5595ea0c994dcf664cb68ec45a6f500e705a3b7 Travis: [PENDING](https://travis-ci.com/flink-ci/flink/builds/144113663) Azure: [SUCCESS](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4285) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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


With regards,
Apache Git Services

[GitHub] [flink] wuchong commented on a change in pull request #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL

Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL
URL: https://github.com/apache/flink/pull/10839#discussion_r366124925
 
 

 ##########
 File path: docs/dev/table/sql/insert.md
 ##########
 @@ -0,0 +1,173 @@
+---
+title: "INSERT Statement"
+nav-parent_id: sql
+nav-pos: 5
+---
+<!--
+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.
+-->
+
+* This will be replaced by the TOC
+{:toc}
+
+INSERT statements are used to add rows to a table.
+
+## Run an INSERT statement
+
+INSERT statements are specified with the `sqlUpdate()` method of the `TableEnvironment` or executed in [SQL CLI]({{ site.baseurl }}/dev/table/sqlClient.html). The method `sqlUpdate()` for INSERT statements is a lazy execution, they will be executed only when `TableEnvironment.execute(jobName)` is invoked.
+
+The following examples show how to run an INSERT statement in `TableEnvironment` and in SQL CLI.
+
+<div class="codetabs" markdown="1">
+<div data-lang="java" markdown="1">
+{% highlight java %}
+EnvironmentSettings settings = EnvironmentSettings.newInstance()...
+TableEnvironment tEnv = TableEnvironment.create(settings);
+
+// register a source table named "Orders" and a sink table named "RubberOrders"
+tEnv.sqlUpdate("CREATE TABLE Orders (`user` BIGINT, product VARCHAR, amount INT) WITH (...)");
+tEnv.sqlUpdate("CREATE TABLE RubberOrders(product VARCHAR, amount INT) WITH (...)");
+
+// run a SQL update query on the registered source table and emit the result to registered sink table
+tEnv.sqlUpdate(
+  "INSERT INTO RubberOrders SELECT product, amount FROM Orders WHERE product LIKE '%Rubber%'");
+{% endhighlight %}
+</div>
+
+<div data-lang="scala" markdown="1">
+{% highlight scala %}
+val settings = EnvironmentSettings.newInstance()...
+val tEnv = TableEnvironment.create(settings)
+
+// register a source table named "Orders" and a sink table named "RubberOrders"
+tEnv.sqlUpdate("CREATE TABLE Orders (`user` BIGINT, product STRING, amount INT) WITH (...)")
+tEnv.sqlUpdate("CREATE TABLE RubberOrders(product STRING, amount INT) WITH (...)")
+
+// run a SQL update query on the registered source table and emit the result to registered sink table
+tEnv.sqlUpdate(
+  "INSERT INTO RubberOrders SELECT product, amount FROM Orders WHERE product LIKE '%Rubber%'")
+{% endhighlight %}
+</div>
+
+<div data-lang="python" markdown="1">
+{% highlight python %}
+settings = EnvironmentSettings.newInstance()...
+table_env = TableEnvironment.create(settings)
+
+# register a source table named "Orders" and a sink table named "RubberOrders"
+table_env.sqlUpdate("CREATE TABLE Orders (`user` BIGINT, product STRING, amount INT) WITH (...)")
+table_env.sqlUpdate("CREATE TABLE RubberOrders(product STRING, amount INT) WITH (...)")
+
+# run a SQL update query on the registered source table and emit the result to registered sink table
+table_env \
+    .sqlUpdate("INSERT INTO RubberOrders SELECT product, amount FROM Orders WHERE product LIKE '%Rubber%'")
+{% endhighlight %}
+</div>
+
+<div data-lang="SQL CLI" markdown="1">
+{% highlight sql %}
+Flink SQL> CREATE TABLE Orders (`user` BIGINT, product STRING, amount INT) WITH (...);
+[INFO] Table has been created.
+
+Flink SQL> CREATE TABLE RubberOrders(product STRING, amount INT) WITH (...);
+
+Flink SQL> SHOW TABLES;
+Orders
+RubberOrders
+
+Flink SQL> INSERT INTO RubberOrders SELECT product, amount FROM Orders WHERE product LIKE '%Rubber%';
+[INFO] Submitting SQL update statement to the cluster...
+[INFO] Table update statement has been successfully submitted to the cluster:
+{% endhighlight %}
+</div>
+</div>
+
+{% top %}
+
+## Insert from select queries
+
+Query Results can be inserted into tables by using the insert clause.
+
+### Syntax
+
+{% highlight sql %}
+
+INSERT { INTO | OVERWRITE } [catalog_name.][db_name.]table_name [PARTITION part_spec] select_statement
+
+part_spec:
+  (part_col_name1=val1 [, part_col_name2=val2, ...])
+
+{% endhighlight %}
+
+**OVERWRITE**
+
+`INSERT OVERWRITE` will overwrite any existing data in the table or partition. Otherwise, new data is appended.
+
+**PARTITION**
+
+`PARTITION` clause should contain static partition columns of this inserting.
+
+### Examples
+
+{% highlight sql %}
+
+-- Creates a partitioned table
+CREATE TABLE country_page_view (user STRING, cnt INT, date STRING, country STRING)
+PARTITIONED BY (date, country)
+WITH (...)
+
+-- Appends rows into the partition (date='2019-8-30', country='China')
+INSERT INTO country_page_view PARTITION (date='2019-8-30', country='China')
+  SELECT user, cnt FROM page_view_source;
+
+-- Overwrites the partition (date='2019-8-30', country='China') using rows in page_view_source
+INSERT INTO country_page_view PARTITION (date='2019-8-30', country='China')
 
 Review comment:
   Sure. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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


With regards,
Apache Git Services

[GitHub] [flink] wuchong commented on issue #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL

Posted by GitBox <gi...@apache.org>.
wuchong commented on issue #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL
URL: https://github.com/apache/flink/pull/10839#issuecomment-573556252
 
 
   cc @JingsongLi 
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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


With regards,
Apache Git Services

[GitHub] [flink] wuchong commented on issue #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL

Posted by GitBox <gi...@apache.org>.
wuchong commented on issue #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL
URL: https://github.com/apache/flink/pull/10839#issuecomment-573980423
 
 
   Thanks @JingsongLi , Merging...

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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


With regards,
Apache Git Services

[GitHub] [flink] wuchong commented on a change in pull request #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL

Posted by GitBox <gi...@apache.org>.
wuchong commented on a change in pull request #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL
URL: https://github.com/apache/flink/pull/10839#discussion_r366124891
 
 

 ##########
 File path: docs/dev/table/sql/insert.md
 ##########
 @@ -0,0 +1,173 @@
+---
+title: "INSERT Statement"
+nav-parent_id: sql
+nav-pos: 5
+---
+<!--
+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.
+-->
+
+* This will be replaced by the TOC
+{:toc}
+
+INSERT statements are used to add rows to a table.
+
+## Run an INSERT statement
+
+INSERT statements are specified with the `sqlUpdate()` method of the `TableEnvironment` or executed in [SQL CLI]({{ site.baseurl }}/dev/table/sqlClient.html). The method `sqlUpdate()` for INSERT statements is a lazy execution, they will be executed only when `TableEnvironment.execute(jobName)` is invoked.
 
 Review comment:
   Why should we emphasize `detach` mode here? It is not related to the `sqlUpdate()` problem. 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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


With regards,
Apache Git Services

[GitHub] [flink] flinkbot edited a comment on issue #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on issue #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL
URL: https://github.com/apache/flink/pull/10839#issuecomment-573563076
 
 
   <!--
   Meta data
   Hash:c5595ea0c994dcf664cb68ec45a6f500e705a3b7 Status:PENDING URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4285 TriggerType:PUSH TriggerID:c5595ea0c994dcf664cb68ec45a6f500e705a3b7
   Hash:c5595ea0c994dcf664cb68ec45a6f500e705a3b7 Status:PENDING URL:https://travis-ci.com/flink-ci/flink/builds/144113663 TriggerType:PUSH TriggerID:c5595ea0c994dcf664cb68ec45a6f500e705a3b7
   -->
   ## CI report:
   
   * c5595ea0c994dcf664cb68ec45a6f500e705a3b7 Travis: [PENDING](https://travis-ci.com/flink-ci/flink/builds/144113663) Azure: [PENDING](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4285) 
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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


With regards,
Apache Git Services

[GitHub] [flink] JingsongLi commented on a change in pull request #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL
URL: https://github.com/apache/flink/pull/10839#discussion_r366120260
 
 

 ##########
 File path: docs/dev/table/sql/insert.md
 ##########
 @@ -0,0 +1,173 @@
+---
+title: "INSERT Statement"
+nav-parent_id: sql
+nav-pos: 5
+---
+<!--
+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.
+-->
+
+* This will be replaced by the TOC
+{:toc}
+
+INSERT statements are used to add rows to a table.
+
+## Run an INSERT statement
+
+INSERT statements are specified with the `sqlUpdate()` method of the `TableEnvironment` or executed in [SQL CLI]({{ site.baseurl }}/dev/table/sqlClient.html). The method `sqlUpdate()` for INSERT statements is a lazy execution, they will be executed only when `TableEnvironment.execute(jobName)` is invoked.
 
 Review comment:
   Maybe we can point to `https://ci.apache.org/projects/flink/flink-docs-master/dev/table/sqlClient.html#detached-sql-queries` to emphasize `detach`.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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


With regards,
Apache Git Services

[GitHub] [flink] JingsongLi commented on a change in pull request #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL
URL: https://github.com/apache/flink/pull/10839#discussion_r366125955
 
 

 ##########
 File path: docs/dev/table/sql/insert.md
 ##########
 @@ -0,0 +1,173 @@
+---
+title: "INSERT Statement"
+nav-parent_id: sql
+nav-pos: 5
+---
+<!--
+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.
+-->
+
+* This will be replaced by the TOC
+{:toc}
+
+INSERT statements are used to add rows to a table.
+
+## Run an INSERT statement
+
+INSERT statements are specified with the `sqlUpdate()` method of the `TableEnvironment` or executed in [SQL CLI]({{ site.baseurl }}/dev/table/sqlClient.html). The method `sqlUpdate()` for INSERT statements is a lazy execution, they will be executed only when `TableEnvironment.execute(jobName)` is invoked.
 
 Review comment:
   ok

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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


With regards,
Apache Git Services

[GitHub] [flink] flinkbot edited a comment on issue #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL

Posted by GitBox <gi...@apache.org>.
flinkbot edited a comment on issue #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL
URL: https://github.com/apache/flink/pull/10839#issuecomment-573563076
 
 
   <!--
   Meta data
   Hash:c5595ea0c994dcf664cb68ec45a6f500e705a3b7 Status:SUCCESS URL:https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4285 TriggerType:PUSH TriggerID:c5595ea0c994dcf664cb68ec45a6f500e705a3b7
   Hash:c5595ea0c994dcf664cb68ec45a6f500e705a3b7 Status:FAILURE URL:https://travis-ci.com/flink-ci/flink/builds/144113663 TriggerType:PUSH TriggerID:c5595ea0c994dcf664cb68ec45a6f500e705a3b7
   Hash:39d7478a9edb9ce3f592a02c6afa2aa69e49a5d5 Status:UNKNOWN URL:TBD TriggerType:PUSH TriggerID:39d7478a9edb9ce3f592a02c6afa2aa69e49a5d5
   -->
   ## CI report:
   
   * c5595ea0c994dcf664cb68ec45a6f500e705a3b7 Travis: [FAILURE](https://travis-ci.com/flink-ci/flink/builds/144113663) Azure: [SUCCESS](https://dev.azure.com/rmetzger/5bd3ef0a-4359-41af-abca-811b04098d2e/_build/results?buildId=4285) 
   * 39d7478a9edb9ce3f592a02c6afa2aa69e49a5d5 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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


With regards,
Apache Git Services

[GitHub] [flink] flinkbot commented on issue #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL

Posted by GitBox <gi...@apache.org>.
flinkbot commented on issue #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL
URL: https://github.com/apache/flink/pull/10839#issuecomment-573563076
 
 
   <!--
   Meta data
   Hash:c5595ea0c994dcf664cb68ec45a6f500e705a3b7 Status:UNKNOWN URL:TBD TriggerType:PUSH TriggerID:c5595ea0c994dcf664cb68ec45a6f500e705a3b7
   -->
   ## CI report:
   
   * c5595ea0c994dcf664cb68ec45a6f500e705a3b7 UNKNOWN
   
   <details>
   <summary>Bot commands</summary>
     The @flinkbot bot supports the following commands:
   
    - `@flinkbot run travis` re-run the last Travis build
    - `@flinkbot run azure` re-run the last Azure build
   </details>

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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


With regards,
Apache Git Services

[GitHub] [flink] JingsongLi commented on a change in pull request #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL

Posted by GitBox <gi...@apache.org>.
JingsongLi commented on a change in pull request #10839: [FLINK-15567][table][docs] Add documentation for INSERT statements for Flink SQL
URL: https://github.com/apache/flink/pull/10839#discussion_r366123543
 
 

 ##########
 File path: docs/dev/table/sql/insert.md
 ##########
 @@ -0,0 +1,173 @@
+---
+title: "INSERT Statement"
+nav-parent_id: sql
+nav-pos: 5
+---
+<!--
+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.
+-->
+
+* This will be replaced by the TOC
+{:toc}
+
+INSERT statements are used to add rows to a table.
+
+## Run an INSERT statement
+
+INSERT statements are specified with the `sqlUpdate()` method of the `TableEnvironment` or executed in [SQL CLI]({{ site.baseurl }}/dev/table/sqlClient.html). The method `sqlUpdate()` for INSERT statements is a lazy execution, they will be executed only when `TableEnvironment.execute(jobName)` is invoked.
+
+The following examples show how to run an INSERT statement in `TableEnvironment` and in SQL CLI.
+
+<div class="codetabs" markdown="1">
+<div data-lang="java" markdown="1">
+{% highlight java %}
+EnvironmentSettings settings = EnvironmentSettings.newInstance()...
+TableEnvironment tEnv = TableEnvironment.create(settings);
+
+// register a source table named "Orders" and a sink table named "RubberOrders"
+tEnv.sqlUpdate("CREATE TABLE Orders (`user` BIGINT, product VARCHAR, amount INT) WITH (...)");
+tEnv.sqlUpdate("CREATE TABLE RubberOrders(product VARCHAR, amount INT) WITH (...)");
+
+// run a SQL update query on the registered source table and emit the result to registered sink table
+tEnv.sqlUpdate(
+  "INSERT INTO RubberOrders SELECT product, amount FROM Orders WHERE product LIKE '%Rubber%'");
+{% endhighlight %}
+</div>
+
+<div data-lang="scala" markdown="1">
+{% highlight scala %}
+val settings = EnvironmentSettings.newInstance()...
+val tEnv = TableEnvironment.create(settings)
+
+// register a source table named "Orders" and a sink table named "RubberOrders"
+tEnv.sqlUpdate("CREATE TABLE Orders (`user` BIGINT, product STRING, amount INT) WITH (...)")
+tEnv.sqlUpdate("CREATE TABLE RubberOrders(product STRING, amount INT) WITH (...)")
+
+// run a SQL update query on the registered source table and emit the result to registered sink table
+tEnv.sqlUpdate(
+  "INSERT INTO RubberOrders SELECT product, amount FROM Orders WHERE product LIKE '%Rubber%'")
+{% endhighlight %}
+</div>
+
+<div data-lang="python" markdown="1">
+{% highlight python %}
+settings = EnvironmentSettings.newInstance()...
+table_env = TableEnvironment.create(settings)
+
+# register a source table named "Orders" and a sink table named "RubberOrders"
+table_env.sqlUpdate("CREATE TABLE Orders (`user` BIGINT, product STRING, amount INT) WITH (...)")
+table_env.sqlUpdate("CREATE TABLE RubberOrders(product STRING, amount INT) WITH (...)")
+
+# run a SQL update query on the registered source table and emit the result to registered sink table
+table_env \
+    .sqlUpdate("INSERT INTO RubberOrders SELECT product, amount FROM Orders WHERE product LIKE '%Rubber%'")
+{% endhighlight %}
+</div>
+
+<div data-lang="SQL CLI" markdown="1">
+{% highlight sql %}
+Flink SQL> CREATE TABLE Orders (`user` BIGINT, product STRING, amount INT) WITH (...);
+[INFO] Table has been created.
+
+Flink SQL> CREATE TABLE RubberOrders(product STRING, amount INT) WITH (...);
+
+Flink SQL> SHOW TABLES;
+Orders
+RubberOrders
+
+Flink SQL> INSERT INTO RubberOrders SELECT product, amount FROM Orders WHERE product LIKE '%Rubber%';
+[INFO] Submitting SQL update statement to the cluster...
+[INFO] Table update statement has been successfully submitted to the cluster:
+{% endhighlight %}
+</div>
+</div>
+
+{% top %}
+
+## Insert from select queries
+
+Query Results can be inserted into tables by using the insert clause.
+
+### Syntax
+
+{% highlight sql %}
+
+INSERT { INTO | OVERWRITE } [catalog_name.][db_name.]table_name [PARTITION part_spec] select_statement
+
+part_spec:
+  (part_col_name1=val1 [, part_col_name2=val2, ...])
+
+{% endhighlight %}
+
+**OVERWRITE**
+
+`INSERT OVERWRITE` will overwrite any existing data in the table or partition. Otherwise, new data is appended.
+
+**PARTITION**
+
+`PARTITION` clause should contain static partition columns of this inserting.
+
+### Examples
+
+{% highlight sql %}
+
+-- Creates a partitioned table
+CREATE TABLE country_page_view (user STRING, cnt INT, date STRING, country STRING)
+PARTITIONED BY (date, country)
+WITH (...)
+
+-- Appends rows into the partition (date='2019-8-30', country='China')
+INSERT INTO country_page_view PARTITION (date='2019-8-30', country='China')
+  SELECT user, cnt FROM page_view_source;
+
+-- Overwrites the partition (date='2019-8-30', country='China') using rows in page_view_source
+INSERT INTO country_page_view PARTITION (date='2019-8-30', country='China')
 
 Review comment:
   Can you add append/overwrite dynamic partition inserting?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to 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


With regards,
Apache Git Services