You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by lz...@apache.org on 2020/06/16 04:17:11 UTC

[flink] branch master updated: [FLINK-18268][docs] Correct Table API in Temporal table docs

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

lzljs3620320 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/flink.git


The following commit(s) were added to refs/heads/master by this push:
     new fea20ad  [FLINK-18268][docs] Correct Table API in Temporal table docs
fea20ad is described below

commit fea20adef1ab5f722e418c1a89600e0786208469
Author: Leonard Xu <xb...@163.com>
AuthorDate: Tue Jun 16 12:16:21 2020 +0800

    [FLINK-18268][docs] Correct Table API in Temporal table docs
    
    This closes #12630
---
 docs/dev/table/connectors/hbase.md             |  4 +-
 docs/dev/table/connectors/hbase.zh.md          |  4 +-
 docs/dev/table/streaming/temporal_tables.md    | 51 +++++++++++++++----------
 docs/dev/table/streaming/temporal_tables.zh.md | 52 ++++++++++++++++----------
 4 files changed, 68 insertions(+), 43 deletions(-)

diff --git a/docs/dev/table/connectors/hbase.md b/docs/dev/table/connectors/hbase.md
index 17508d7..fd8530d 100644
--- a/docs/dev/table/connectors/hbase.md
+++ b/docs/dev/table/connectors/hbase.md
@@ -62,7 +62,7 @@ CREATE TABLE hTable (
 ) WITH (
  'connector' = 'hbase-1.4',
  'table-name' = 'mytable',
- 'zookeeper.quorum' = 'localhost:2121'
+ 'zookeeper.quorum' = 'localhost:2181'
 )
 {% endhighlight %}
 </div>
@@ -274,7 +274,7 @@ double toDouble(byte[] bytes)
       <td>Not supported</td>
     </tr>
     <tr>
-      <td><code>MAP / MULTISET<code></td>
+      <td><code>MAP / MULTISET</code></td>
       <td>Not supported</td>
     </tr>
     <tr>
diff --git a/docs/dev/table/connectors/hbase.zh.md b/docs/dev/table/connectors/hbase.zh.md
index 17508d7..fd8530d 100644
--- a/docs/dev/table/connectors/hbase.zh.md
+++ b/docs/dev/table/connectors/hbase.zh.md
@@ -62,7 +62,7 @@ CREATE TABLE hTable (
 ) WITH (
  'connector' = 'hbase-1.4',
  'table-name' = 'mytable',
- 'zookeeper.quorum' = 'localhost:2121'
+ 'zookeeper.quorum' = 'localhost:2181'
 )
 {% endhighlight %}
 </div>
@@ -274,7 +274,7 @@ double toDouble(byte[] bytes)
       <td>Not supported</td>
     </tr>
     <tr>
-      <td><code>MAP / MULTISET<code></td>
+      <td><code>MAP / MULTISET</code></td>
       <td>Not supported</td>
     </tr>
     <tr>
diff --git a/docs/dev/table/streaming/temporal_tables.md b/docs/dev/table/streaming/temporal_tables.md
index c2a20b7..62baf8e 100644
--- a/docs/dev/table/streaming/temporal_tables.md
+++ b/docs/dev/table/streaming/temporal_tables.md
@@ -260,32 +260,45 @@ See also the page about [joins for continuous queries](joins.html) for more info
 {% highlight java %}
 // Get the stream and table environments.
 StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
-StreamTableEnvironment tEnv = TableEnvironment.getTableEnvironment(env);
-
-// Create an HBaseTableSource as a temporal table which implements LookableTableSource
-// In the real setup, you should replace this with your own table.
-HBaseTableSource rates = new HBaseTableSource(conf, "Rates");
-rates.setRowKey("currency", String.class);   // currency as the primary key
-rates.addColumn("fam1", "rate", Double.class);
-
-// register the temporal table into environment, then we can query it in sql
-tEnv.registerTableSource("Rates", rates);
+EnvironmentSettings settings = EnvironmentSettings.newInstance().build();
+StreamTableEnvironment tEnv = StreamTableEnvironment.create(env, settings);
+// or TableEnvironment tEnv = TableEnvironment.create(settings);
+
+// Define an HBase table with DDL, then we can use it as a temporal table in sql
+// Column 'currency' is the rowKey in HBase table
+tEnv.executeSql(
+    "CREATE TABLE LatestRates (" +
+    "   currency STRING," +
+    "   fam1 ROW<rate DOUBLE>" +
+    ") WITH (" +
+    "   'connector' = 'hbase-1.4'," +
+    "   'table-name' = 'Rates'," +
+    "   'zookeeper.quorum' = 'localhost:2181'" +
+    ")");
 {% endhighlight %}
 </div>
 <div data-lang="scala" markdown="1">
 {% highlight scala %}
 // Get the stream and table environments.
 val env = StreamExecutionEnvironment.getExecutionEnvironment
-val tEnv = TableEnvironment.getTableEnvironment(env)
-
-// Create an HBaseTableSource as a temporal table which implements LookableTableSource
-// In the real setup, you should replace this with your own table.
-val rates = new HBaseTableSource(conf, "Rates")
-rates.setRowKey("currency", String.class)   // currency as the primary key
-rates.addColumn("fam1", "rate", Double.class)
+val settings = EnvironmentSettings.newInstance().build()
+val tEnv = StreamTableEnvironment.create(env, settings)
+// or val tEnv = TableEnvironment.create(settings)
+
+// Define an HBase table with DDL, then we can use it as a temporal table in sql
+// Column 'currency' is the rowKey in HBase table
+tEnv.executeSql(
+    s"""
+       |CREATE TABLE LatestRates (
+       |    currency STRING,
+       |    fam1 ROW<rate DOUBLE>
+       |) WITH (
+       |    'connector' = 'hbase-1.4',
+       |    'table-name' = 'Rates',
+       |    'zookeeper.quorum' = 'localhost:2181'
+       |)
+       |""".stripMargin)
 
-// register the temporal table into environment, then we can query it in sql
-tEnv.registerTableSource("Rates", rates)
 {% endhighlight %}
 </div>
 </div>
diff --git a/docs/dev/table/streaming/temporal_tables.zh.md b/docs/dev/table/streaming/temporal_tables.zh.md
index aeb54a1..df929d9 100644
--- a/docs/dev/table/streaming/temporal_tables.zh.md
+++ b/docs/dev/table/streaming/temporal_tables.zh.md
@@ -261,32 +261,44 @@ Yen           1
 {% highlight java %}
 // 获取 stream 和 table 环境
 StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
-StreamTableEnvironment tEnv = TableEnvironment.getTableEnvironment(env);
-
-// 创建一个实现 LookableTableSource 的 HBaseTableSource 作为时态表
-// 在实际设置中,应使用自己的表替换它
-HBaseTableSource rates = new HBaseTableSource(conf, "Rates");
-rates.setRowKey("currency", String.class);   // currency 作为主键
-rates.addColumn("fam1", "rate", Double.class);
-
-// 注册这个临时表到环境中,然后我们可以用 sql 查询它
-tEnv.registerTableSource("Rates", rates);
+EnvironmentSettings settings = EnvironmentSettings.newInstance().build();
+StreamTableEnvironment tEnv = StreamTableEnvironment.create(env, settings);
+// or TableEnvironment tEnv = TableEnvironment.create(settings);
+
+// 用 DDL 定义一张 HBase 表,然后我们可以在 SQL 中将其当作一张时态表使用
+// 'currency' 列是 HBase 表中的 rowKey
+tEnv.executeSql(
+    "CREATE TABLE LatestRates (" +
+    "   currency STRING," +
+    "   fam1 ROW<rate DOUBLE>" +
+    ") WITH (" +
+    "   'connector' = 'hbase-1.4'," +
+    "   'table-name' = 'Rates'," +
+    "   'zookeeper.quorum' = 'localhost:2181'" +
+    ")");
 {% endhighlight %}
 </div>
 <div data-lang="scala" markdown="1">
 {% highlight scala %}
 // 获取 stream 和 table 环境
 val env = StreamExecutionEnvironment.getExecutionEnvironment
-val tEnv = TableEnvironment.getTableEnvironment(env)
-
-// 创建一个实现 LookableTableSource 的 HBaseTableSource 作为时态表
-// 在实际设置中,应使用自己的表替换它
-val rates = new HBaseTableSource(conf, "Rates")
-rates.setRowKey("currency", String.class)   // currency 作为主键
-rates.addColumn("fam1", "rate", Double.class)
-
-// 注册这个临时表到环境中,然后我们可以用 sql 查询它
-tEnv.registerTableSource("Rates", rates)
+val settings = EnvironmentSettings.newInstance().build()
+val tEnv = StreamTableEnvironment.create(env, settings)
+// or val tEnv = TableEnvironment.create(settings)
+
+// 用 DDL 定义一张 HBase 表,然后我们可以在 SQL 中将其当作一张时态表使用
+// 'currency' 列是 HBase 表中的 rowKey
+tEnv.executeSql(
+    s"""
+       |CREATE TABLE LatestRates (
+       |    currency STRING,
+       |    fam1 ROW<rate DOUBLE>
+       |) WITH (
+       |    'connector' = 'hbase-1.4',
+       |    'table-name' = 'Rates',
+       |    'zookeeper.quorum' = 'localhost:2181'
+       |)
+       |""".stripMargin)
 {% endhighlight %}
 </div>
 </div>