Flink Table & SQL的API實現了通過SQL語言處理實時技術算業務,但還是要編寫部分Java代碼(或Scala),并且還要編譯構建才能提交到Flink運行環境,這對于不熟悉Java或Scala的開發者就略有些不友好了; SQL Client的目標就是解決上述問題(官方原話with a build tool before being submitted to a cluster.)
tables:- name: BookStoretype: source-tableupdate-mode: appendconnector:type: filesystempath: "/Users/zhaoqin/temp/202004/26/book-store.csv"format:type: csvfields:- name: BookNametype: VARCHAR- name: BookAmounttype: INT- name: BookCatalogtype: VARCHARline-delimiter: "\n"comment-prefix: ","schema:- name: BookNametype: VARCHAR- name: BookAmounttype: INT- name: BookCatalogtype: VARCHAR- name: MyBookViewtype: viewquery: "SELECT BookCatalog, SUM(BookAmount) AS Amount FROM BookStore GROUP BY BookCatalog"execution:planner: blink # optional: either 'blink' (default) or 'old'type: streaming # required: execution mode either 'batch' or 'streaming'result-mode: table # required: either 'table' or 'changelog'max-table-result-rows: 1000000 # optional: maximum number of maintained rows in# 'table' mode (1000000 by default, smaller 1 means unlimited)time-characteristic: event-time # optional: 'processing-time' or 'event-time' (default)parallelism: 1 # optional: Flink's parallelism (1 by default)periodic-watermarks-interval: 200 # optional: interval for periodic watermarks (200 ms by default)max-parallelism: 16 # optional: Flink's maximum parallelism (128 by default)min-idle-state-retention: 0 # optional: table program's minimum idle state timemax-idle-state-retention: 0 # optional: table program's maximum idle state time# (default database of the current catalog by default)restart-strategy: # optional: restart strategytype: fallback # "fallback" to global restart strategy by default# Configuration options for adjusting and tuning table programs.# A full list of options and their default values can be found# on the dedicated "Configuration" page.
configuration:table.optimizer.join-reorder-enabled: truetable.exec.spill-compression.enabled: truetable.exec.spill-compression.block-size: 128kb# Properties that describe the cluster to which table programs are submitted to.deployment:response-timeout: 5000
對于book-store.yaml文件,有以下幾處需要注意: a. tables.type等于source-table,表明這是數據源的配置信息; b. tables.connector描述了詳細的數據源信息,path是book-store.csv文件的完整路徑; c. tables.format描述了文件內容; d. tables.schema描述了數據源表的表結構; ed. type為view表示MyBookView是個視圖(參考數據庫的視圖概念);