日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > 数据库 >内容正文

数据库

Flink SQL Client讀取csv中的數據(轉載+總結)

發布時間:2023/12/31 数据库 32 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Flink SQL Client讀取csv中的數據(轉載+總結) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

根據官方文檔[2]

Flink SQL啓動方式啓動命令

(1)starting an embedded standalone process

?

$FLINK_HOME/bin/sql-client.sh embedded
(2)connecting to a remote SQL Client Gateway

官方暫時不支持

"At the moment only the?embedded?mode is supported"

默認配置文件是:

$FLINK_HOME/conf/sql-client-defaults.yaml

[3]中提到了所謂的 "environment file"的概念其實就是yaml文件

--------------------------------------------------------------------下面是實驗----------------------------------------------------------------------------------------------------???????------------???????---------

準備工作:

①~/桌面/book-store.csv

②$FLINK_HOME/conf/book-store.yaml

文件每行解釋:

book-store.yaml的每行解釋
tables.type等于source-table,表明這是數據源的配置信息
tables.connector描述了詳細的數據源信息,path是book-store.csv文件的完整路徑
tables.format描述了文件內容;
tables.schema描述了數據源表的表結構;
type為view表示MyBookView是個視圖(參考數據庫的視圖概念);

啓動命令:
$FLINK_HOME/bin/sql-client.sh embedded -d $FLINK_HOME/conf/book-store.yaml

執行命令:

命令功能
SELECT * FROM BookStore;查詢全表
SELECT BookCatalog, COUNT(*) AS BookCount FROM BookStore GROUP BY BookCatalog;按照BookCatalog分組統計記錄數
select * from MyBookView;select * from MyBookView

https://github.com/ververica/flink-sql-gateway

運行結果示范:

----------------------------------------------------------------------------------------------------------------------------------------------------------------

CLI支持三種可視化查詢結果的模式[5],可在命令行中進行設置 ,三種模式的區別和使用參考官網

運行模式FLINK SQL設置命令
table mode?SET execution.result-mode=table;
changelog modeSET execution.result-mode=changelog;
tableau modeSET execution.result-mode=tableau;

上述執行的select查詢結果,會緩存到java heap中。具體示範如下:

----------------------------------------------------------------------------------------------------------------------------------------------------------------

啓動時總是會出現的No session environment specified

咋回事呢?

根據我查詢了資料[4]

To configure the SQL Client for the session mode, you need to create an environment YAML file (sql-env.yaml), and add the following configuration:

configuration:execution.target: yarn-session

This overrides the Flink configuration of the execution target to?yarn-session?mode.

?

Reference:

[1]Flink SQL Client初探

[2]SQL Client

[3]https://github.com/ververica/flink-sql-gateway

[4]Configuring SQL Client for session mode

[5]Flink v1.11.1 官網Flink SQL Client 的使用


?

?

?

?

總結

以上是生活随笔為你收集整理的Flink SQL Client讀取csv中的數據(轉載+總結)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。