Skip to content

Commit 7a135dd

Browse files
authored
[docs] Improve some docs in getting-started.md and lookups.md (#557)
1 parent 057dd75 commit 7a135dd

File tree

2 files changed

+43
-28
lines changed

2 files changed

+43
-28
lines changed

website/docs/engine-flink/getting-started.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ Fluss only supports Apache Flink's Table API.
2525
| [SQL drop database](ddl.md#drop-database) | ✔️ | |
2626
| [SQL create table](ddl.md#create-table) | ✔️ | |
2727
| [SQL create table like](ddl.md#create-table-like) | ✔️ | |
28-
| [SQL drop table](ddl.md#drop-table) | ✔️ | | |
28+
| [SQL drop table](ddl.md#drop-table) | ✔️ | |
29+
| [SQL show partitions](ddl.md#show-partitions) | ✔️ | |
30+
| [SQL add partiiton](ddl.md#add-partition) | ✔️ | |
31+
| [SQL drop partiiton](ddl.md#drop-partition) | ✔️ | |
2932
| [SQL select](reads.md) | ✔️ | Support both streaming and batch mode. |
3033
| [SQL insert into](writes.md) | ✔️ | Support both streaming and batch mode. |
3134
| [SQL lookup join](lookups.md) | ✔️ | |

website/docs/engine-flink/lookups.md

Lines changed: 39 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,19 @@ Flink lookup joins are important because they enable efficient, real-time enrich
1515

1616
### Examples
1717
1. Create two tables.
18+
19+
```sql title="Flink SQL"
20+
USE CATALOG fluss_catalog;
21+
```
22+
23+
```sql title="Flink SQL"
24+
CREATE DATABASE my_db;
25+
```
26+
27+
```sql title="Flink SQL"
28+
USE my_db;
29+
```
30+
1831
```sql title="Flink SQL"
1932
CREATE TABLE `fluss_catalog`.`my_db`.`orders` (
2033
`o_orderkey` INT NOT NULL,
@@ -46,13 +59,6 @@ CREATE TABLE `fluss_catalog`.`my_db`.`customer` (
4659
```
4760

4861
2. Perform lookup join.
49-
```sql title="Flink SQL"
50-
USE CATALOG fluss_catalog;
51-
```
52-
53-
```sql title="Flink SQL"
54-
USE my_db;
55-
```
5662

5763
```sql title="Flink SQL"
5864
CREATE TEMPORARY TABLE lookup_join_sink
@@ -135,8 +141,21 @@ For more details about Fluss partitioned table, see [Partitioned Tables](table-d
135141

136142
### Examples
137143
1. Create two tables.
144+
138145
```sql title="Flink SQL"
139-
CREATE TABLE `fluss_catalog`.`my_db`.`orders` (
146+
USE CATALOG fluss_catalog;
147+
```
148+
149+
```sql title="Flink SQL"
150+
CREATE DATABASE my_db;
151+
```
152+
153+
```sql title="Flink SQL"
154+
USE my_db;
155+
```
156+
157+
```sql title="Flink SQL"
158+
CREATE TABLE `fluss_catalog`.`my_db`.`orders_with_dt` (
140159
`o_orderkey` INT NOT NULL,
141160
`o_custkey` INT NOT NULL,
142161
`o_orderstatus` CHAR(1) NOT NULL,
@@ -154,7 +173,7 @@ CREATE TABLE `fluss_catalog`.`my_db`.`orders` (
154173
```sql title="Flink SQL"
155174
-- primary keys are (c_custkey, c_nationkey)
156175
-- bucket key is (c_custkey)
157-
CREATE TABLE `fluss_catalog`.`my_db`.`customer` (
176+
CREATE TABLE `fluss_catalog`.`my_db`.`customer_with_bucket_key` (
158177
`c_custkey` INT NOT NULL,
159178
`c_name` STRING NOT NULL,
160179
`c_address` STRING NOT NULL,
@@ -170,16 +189,9 @@ CREATE TABLE `fluss_catalog`.`my_db`.`customer` (
170189
```
171190

172191
2. Perform prefix lookup.
173-
```sql title="Flink SQL"
174-
USE CATALOG fluss_catalog;
175-
```
176192

177193
```sql title="Flink SQL"
178-
USE my_db;
179-
```
180-
181-
```sql title="Flink SQL"
182-
CREATE TEMPORARY TABLE lookup_join_sink
194+
CREATE TEMPORARY TABLE prefix_lookup_join_sink
183195
(
184196
order_key INT NOT NULL,
185197
order_totalprice DECIMAL(15, 2) NOT NULL,
@@ -190,11 +202,11 @@ CREATE TEMPORARY TABLE lookup_join_sink
190202

191203
```sql title="Flink SQL"
192204
-- prefix look up join in asynchronous mode.
193-
INSERT INTO lookup_join_sink
205+
INSERT INTO prefix_lookup_join_sink
194206
SELECT `o`.`o_orderkey`, `o`.`o_totalprice`, `c`.`c_name`, `c`.`c_address`
195207
FROM
196-
(SELECT `orders`.*, proctime() AS ptime FROM `orders`) AS `o`
197-
LEFT JOIN `customer`
208+
(SELECT `orders_with_dt`.*, proctime() AS ptime FROM `orders_with_dt`) AS `o`
209+
LEFT JOIN `customer_with_bucket_key`
198210
FOR SYSTEM_TIME AS OF `o`.`ptime` AS `c`
199211
ON `o`.`o_custkey` = `c`.`c_custkey`;
200212

@@ -203,11 +215,11 @@ ON `o`.`o_custkey` = `c`.`c_custkey`;
203215

204216
```sql title="Flink SQL"
205217
-- prefix look up join in synchronous mode.
206-
INSERT INTO lookup_join_sink
218+
INSERT INTO prefix_lookup_join_sink
207219
SELECT `o`.`o_orderkey`, `o`.`o_totalprice`, `c`.`c_name`, `c`.`c_address`
208220
FROM
209-
(SELECT `orders`.*, proctime() AS ptime FROM `orders`) AS `o`
210-
LEFT JOIN `customer` /*+ OPTIONS('lookup.async' = 'false') */
221+
(SELECT `orders_with_dt`.*, proctime() AS ptime FROM `orders_with_dt`) AS `o`
222+
LEFT JOIN `customer_with_bucket_key` /*+ OPTIONS('lookup.async' = 'false') */
211223
FOR SYSTEM_TIME AS OF `o`.`ptime` AS `c`
212224
ON `o`.`o_custkey` = `c`.`c_custkey`;
213225
```
@@ -219,7 +231,7 @@ Continuing from the previous prefix lookup example, if our dimension table is a
219231
```sql title="Flink SQL"
220232
-- primary keys are (c_custkey, c_nationkey, dt)
221233
-- bucket key is (c_custkey)
222-
CREATE TABLE `fluss_catalog`.`my_db`.`customer_partitioned` (
234+
CREATE TABLE `fluss_catalog`.`my_db`.`customer_partitioned_with_bukcet_key` (
223235
`c_custkey` INT NOT NULL,
224236
`c_name` STRING NOT NULL,
225237
`c_address` STRING NOT NULL,
@@ -242,11 +254,11 @@ WITH (
242254
To do a prefix lookup with the Fluss partitioned primary key table, the prefix lookup join key is in pattern of
243255
`a prefix subset of primary keys (excluding partition key)` + `partition key`.
244256
```sql title="Flink SQL"
245-
INSERT INTO lookup_join_sink
257+
INSERT INTO prefix_lookup_join_sink
246258
SELECT `o`.`o_orderkey`, `o`.`o_totalprice`, `c`.`c_name`, `c`.`c_address`
247259
FROM
248-
(SELECT `orders`.*, proctime() AS ptime FROM `orders`) AS `o`
249-
LEFT JOIN `customer_partitioned`
260+
(SELECT `orders_with_dt`.*, proctime() AS ptime FROM `orders_with_dt`) AS `o`
261+
LEFT JOIN `customer_partitioned_with_bukcet_key`
250262
FOR SYSTEM_TIME AS OF `o`.`ptime` AS `c`
251263
ON `o`.`o_custkey` = `c`.`c_custkey` AND `o`.`o_dt` = `c`.`dt`;
252264

0 commit comments

Comments
 (0)