You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@beam.apache.org by me...@apache.org on 2018/08/09 22:09:35 UTC

[beam-site] 01/02: Update SQL walkthrough for 2.6.0

This is an automated email from the ASF dual-hosted git repository.

mergebot-role pushed a commit to branch mergebot
in repository https://gitbox.apache.org/repos/asf/beam-site.git

commit 8b158779271a92295c29270f1e3f8968a3b3cc40
Author: Anton Kedin <ke...@google.com>
AuthorDate: Tue Aug 7 15:21:52 2018 -0700

    Update SQL walkthrough for 2.6.0
---
 src/documentation/dsls/sql/overview.md    |  2 +-
 src/documentation/dsls/sql/walkthrough.md | 23 ++++++++++-------------
 2 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/src/documentation/dsls/sql/overview.md b/src/documentation/dsls/sql/overview.md
index 8a7ac29..7063b16 100644
--- a/src/documentation/dsls/sql/overview.md
+++ b/src/documentation/dsls/sql/overview.md
@@ -32,7 +32,7 @@ There are three main things you will need to know to use SQL in your pipeline:
    basic dialect underlying Beam SQL. We have added additional extensions to
    make it easy to leverage Beam's unified batch/streaming model and support
    for complex data types.
- - [BeamSql]({{ site.baseurl }}/documentation/sdks/javadoc/{{ site.release_latest }}/index.html?org/apache/beam/sdk/extensions/sql/BeamSql.html): 
+ - [SqlTransform]({{ site.baseurl }}/documentation/sdks/javadoc/{{ site.release_latest }}/index.html?org/apache/beam/sdk/extensions/sql/SqlTransform.html): 
    the interface for creating `PTransforms` from SQL queries.
  - [Row]({{ site.baseurl }}/documentation/sdks/javadoc/{{ site.release_latest }}/index.html?org/apache/beam/sdk/values/Row.html):
    the type of elements that Beam SQL operates on. A `PCollection<Row>` plays the role of a table.
diff --git a/src/documentation/dsls/sql/walkthrough.md b/src/documentation/dsls/sql/walkthrough.md
index 26f1ac1..57fa8fb 100644
--- a/src/documentation/dsls/sql/walkthrough.md
+++ b/src/documentation/dsls/sql/walkthrough.md
@@ -40,10 +40,10 @@ A `PCollection<Row>` can be obtained multiple ways, for example:
 
   - **From in-memory data** (typically for unit testing).
 
-    **Note:** you have to explicitly specify the `Row` coder. In this example we're doing it by calling `Create.of(..).withCoder()`:
+    **Note:** you have to explicitly specify the `Row` coder. In this example we're doing it by calling `Create.of(..)`:
 
     ```java
-    // Define the record type (i.e., schema).
+    // Define the schema for the records.
     Schema appSchema = 
         Schema
           .builder()
@@ -67,9 +67,7 @@ A `PCollection<Row>` can be obtained multiple ways, for example:
                     .of(row)
                     .withCoder(appSchema.getRowCoder()));
     ```
-  - **From a `PCollection<T>` of records of some other type**  (i.e.  `T` is not already a `Row`), by applying a `ParDo` that converts input records to `Row` format.
-
-    **Note:** you have to manually set the coder of the result by calling `setCoder(appSchema.getRowCoder())`:
+  - **From a `PCollection<T>` of records of some other type**  (i.e.  `T` is not already a `Row`), by applying a `ParDo` that converts input records to `Row` format:
     ```java
     // An example POJO class.
     class AppPojo {
@@ -104,17 +102,16 @@ A `PCollection<Row>` can be obtained multiple ways, for example:
               // Output the Row representing the current POJO
               c.output(appRow);
             }
-          }))
-      .setCoder(appSchema.getRowCoder());
+          }));
     ```
 
-  - **As an output of another `BeamSql` query**. Details in the next section.
+  - **As an output of another `SqlTransform`**. Details in the next section.
 
-Once you have a `PCollection<Row>` in hand, you may use the `BeamSql` APIs to apply SQL queries to it.
+Once you have a `PCollection<Row>` in hand, you may use `SqlTransform` to apply SQL queries to it.
 
-## BeamSql transform
+## SqlTransform
 
-`BeamSql.query(queryString)` method is the only API to create a `PTransform`
+[`SqlTransform.query(queryString)`]({{ site.baseurl }}/documentation/sdks/javadoc/{{ site.release_latest }}/index.html?org/apache/beam/sdk/extensions/sql/SqlTransform.html) method is the only API to create a `PTransform`
 from a string representation of the SQL query. You can apply this `PTransform`
 to either a single `PCollection` or a `PCollectionTuple` which holds multiple
 `PCollections`:
@@ -122,7 +119,7 @@ to either a single `PCollection` or a `PCollectionTuple` which holds multiple
   - when applying to a single `PCollection` it can be referenced via the table name `PCOLLECTION` in the query:
     ```java
     PCollection<Row> filteredNames = testApps.apply(
-        BeamSql.query(
+        SqlTransform.query(
           "SELECT appId, description, rowtime "
             + "FROM PCOLLECTION "
             + "WHERE id=1"));
@@ -154,7 +151,7 @@ to either a single `PCollection` or a `PCollectionTuple` which holds multiple
     // and average rating per app 
     // by joining two PCollections
     PCollection<Row> output = namesAndFoods.apply(
-        BeamSql.query(
+        SqlTransform.query(
             "SELECT Names.appId, COUNT(Reviews.rating), AVG(Reviews.rating)"
                 + "FROM Apps INNER JOIN Reviews ON Apps.appId == Reviews.appId"));
     ```