大数据全系列 教程
1869个小节阅读:467.2k
目录
408考研
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
SQL Client提供一种简单的方式来编写、调试和提交表程序(DDL、DQL、DML语句)到Flink 集群上,而无需写一行Scala 代码;能够在命令行中检索和可视化分布式应用中实时产生的结果。
SQL Client内嵌在常规 Flink 发行版中,因此可以直接运行,仅需要一个正在运行的 Flink 集群就可以在其中执行表程序。
xxxxxxxxxx
[root@node1 ~]# /opt/flink-salone/bin/start-cluster.sh
Starting cluster.
Starting standalonesession daemon on host node1.
Starting taskexecutor daemon on host node1.
Starting taskexecutor daemon on host node2.
Starting taskexecutor daemon on host node3.
xxxxxxxxxx
[root@node1 ~]# /opt/flink-salone/bin/sql-client.sh
Flink SQL> HELP; The following commands are available:
HELP Prints the available commands. QUIT/EXIT Quits the SQL CLI client. CLEAR Clears the current terminal. SET Sets a session configuration property. Syntax: "SET '
'=' ';". Use "SET;" for listing all properties. RESET Resets a session configuration property. Syntax: "RESET ' ';". Use "RESET;" for reset all session properties. INSERT INTO Inserts the results of a SQL SELECT query into a declared table sink. INSERT OVERWRITE Inserts the results of a SQL SELECT query into a declared table sink and overwrite existing data. SELECT Executes a SQL SELECT query on the Flink cluster. EXPLAIN Describes the execution plan of a query or table with the given name. ......
xxxxxxxxxx
Flink SQL> select 'GtJin' as src,lower('GtJin') as lower_type,upper('GtJin') as upper_type;
可视化的三种模式,通过命令:SET sql-client.execution.result-mode=xxx进行切换:
table:表格模式,也是默认模式
xxxxxxxxxx
Flink SQL>SET sql-client.execution.result-mode=table;
tableau:数据库表格模式
xxxxxxxxxx
Flink SQL>SET sql-client.execution.result-mode=tableau;
Flink SQL>select 'GtJin' as src,lower('GtJin') as lower_type,upper('GtJin') as upper_type;
changelog:变更日志模式
xxxxxxxxxx
Flink SQL>SET sql-client.execution.result-mode=changelog;
Flink SQL>select 'GtJin' as src,lower('GtJin') as lower_type,upper('GtJin') as upper_type;
案例:使用SQLClient完成指定单词的词频统计
xxxxxxxxxx
SET 'sql-client.execution.result-mode' = 'tableau';
SET 'execution.runtime-mode' = 'batch';
SET sql-client.execution.max-table-result.rows=2;
SELECT name,COUNT(*) AS cnt
FROM
(VALUES ('Bob'), ('Alice'), ('Greg'), ('Bob')) AS NameTable(name)
GROUP BY name;