Browse Source

[doc] Add doc for pre-sql and post-sql (#10685)

3.1.0-release
Stalary 2 years ago committed by GitHub
parent
commit
a45fc5b032
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      docs/docs/en/guide/task/sql.md
  2. 12
      docs/docs/zh/guide/task/sql.md
  3. BIN
      docs/img/tasks/demo/pre_post_sql.png

12
docs/docs/en/guide/task/sql.md

@ -31,18 +31,26 @@ Refer to [DataSource](../datasource/introduction.md)
## Task Example
### Create a Temporary Table in Hive and Write Data
### Hive Table Create Example
#### Create a Temporary Table in Hive and Write Data
This example creates a temporary table `tmp_hello_world` in Hive and writes a row of data. Before creating a temporary table, we need to ensure that the table does not exist. So we use custom parameters to obtain the time of the day as the suffix of the table name every time we run, this task can run every different day. The format of the created table name is: `tmp_hello_world_{yyyyMMdd}`.
![hive-sql](../../../../img/tasks/demo/hive-sql.png)
### After Running the Task Successfully, Query the Results in Hive
#### After Running the Task Successfully, Query the Results in Hive
Log in to the bigdata cluster and use 'hive' command or 'beeline' or 'JDBC' and other methods to connect to the 'Apache Hive' for the query. The query SQL is `select * from tmp_hello_world_{yyyyMMdd}`, please replace `{yyyyMMdd}` with the date of the running day. The following shows the query screenshot:
![hive-sql](../../../../img/tasks/demo/hive-result.png)
### Use Pre-SQL and Post-SQL Example
Table created in the Pre-SQL, after use in the SQL statement, cleaned in the Post-SQL
![pre_post_sql](../../../../img/tasks/demo/pre_post_sql.png)
## Notice
Pay attention to the selection of SQL type. If it is an insert operation, need to change to "Non-Query" type.

12
docs/docs/zh/guide/task/sql.md

@ -31,18 +31,26 @@ SQL任务类型,用于连接数据库并执行相应SQL。
## 任务样例
### 在hive中创建临时表并写入数据
### Hive表创建示例
#### 在hive中创建临时表并写入数据
该样例向hive中创建临时表`tmp_hello_world`并写入一行数据。选择SQL类型为非查询,在创建临时表之前需要确保该表不存在,所以我们使用自定义参数,在每次运行时获取当天时间作为表名后缀,这样这个任务就可以每天运行。创建的表名格式为:`tmp_hello_world_{yyyyMMdd}`。
![hive-sql](../../../../img/tasks/demo/hive-sql.png)
### 运行该任务成功之后在hive中查询结果
#### 运行该任务成功之后在hive中查询结果
登录集群使用`hive`命令或使用`beeline`、`JDBC`等方式连接`apache hive`进行查询,查询SQL为`select * from tmp_hello_world_{yyyyMMdd}`,请将`{yyyyMMdd}`替换为运行当天的日期,查询截图如下:
![hive-sql](../../../../img/tasks/demo/hive-result.png)
### 使用前置sql和后置sql示例
在前置sql中执行建表操作,在sql语句中执行操作,在后置sql中执行清理操作
![pre_post_sql](../../../../img/tasks/demo/pre_post_sql.png)
## 注意事项
* 注意SQL类型的选择,如果是INSERT等操作需要选择非查询类型。

BIN
docs/img/tasks/demo/pre_post_sql.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

Loading…
Cancel
Save