当前位置:网站首页>sparksql 与flinksql 建表 与 连表记录
sparksql 与flinksql 建表 与 连表记录
2022-07-28 06:30:00 【路新航】
启动flink sql:bin/sql-client.sh
建表
flink建立表
create table iceberg.xxx.xxx
(
id STRING comment 'id',
dt STRING comment '分区字段'
)
PARTITIONED BY (dt)
with (
'write.format.default' = 'parquet', --指定文件存储格式,默认parquet
'write.parquet.compression-codec' = 'gzip', --指定文件压缩格式,
'commit.manifest-merge.enabled' = 'true', --写入时自动合并manifest
'history.expire.max-snapshot-age-ms' = '43200000', --历史快照保留时间(ms),默认5天,此处12h
'engine.hive.enabled' = 'true', --支持hive查询
'write.metadata.delete-after-commit.enabled' = 'true', --在每个新元数据文件创建后删除最旧的元数据文件
'write.metadata.previous-versions-max' = '20', --提交后删除之前版本元数据文件的最大数量
'write.metadata.compression-codec' = 'gzip', --开启元数据压缩为gzip格式
'location' = 'hdfs://ns1/lakehouse/schema_name/table_name' --指定hdfs地址
);
spark建立表
create table iceberg.xxx.xxxx
(
id STRING comment 'id',
dt STRING comment '分区字段'
)
using iceberg
partitioned by (dt)
location 'hdfs://xxx/lakehouse/schema_name/table_name'
tblproperties (
'write.format.default' = 'parquet', --指定文件存储格式,默认parquet
'write.parquet.compression-codec' = 'gzip', --指定文件压缩格式,
'commit.manifest-merge.enabled' = 'true', --写入时自动合并manifest
'history.expire.max-snapshot-age-ms' = '43200000', --历史快照保留时间(ms),默认5天,此处12h
'engine.hive.enabled' = 'true', --支持hive查询
'write.metadata.delete-after-commit.enabled' = 'true', --在每个新元数据文件创建后删除最旧的元数据文件
'write.metadata.previous-versions-max' = '20', --提交后删除之前版本元数据文件的最大数量
'write.metadata.compression-codec' = 'gzip' --开启元数据压缩为gzip格式
);
根据源表创建目标表
CREATE TABLE iceberg.schema_name.table_name
using iceberg
partitioned by (dt)
location 'hdfs://ns1/lakehouse/schema_name/table_name'
tblproperties (
'write.format.default' = 'parquet',
'write.parquet.compression-codec' = 'gzip',
'commit.manifest-merge.enabled' = 'true',
'engine.hive.enabled' = 'true',
'write.metadata.delete-after-commit.enabled' = 'true',
'write.metadata.previous-versions-max' = '20',
'write.metadata.compression-codec' = 'gzip'
) AS SELECT * from iceberg.schema_name.original_table_name where 1=2;
连接mysql、 sql server
spark
-- mysql
CREATE
TEMPORARY
VIEW tb_order_group
USING org.apache.spark.sql.jdbc
OPTIONS (
url 'jdbc:mysql://xx.xxx.xx.xx:4909/db_name?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF-8&autoReconnect=true&zeroDateTimeBehavior=convertToNull',
dbtable 'xxx',
user 'xxx',
password 'xxx'
);
-- sqlserver
CREATE
TEMPORARY
VIEW gxywhz
USING org.apache.spark.sql.jdbc
OPTIONS (
url 'jdbc:sqlserver://192.168.1.xx:xxx;DatabaseName=xxx',
dbtable 'dbo.xxx',
user 'xxx',
password 'xxxx'
);
flink
-- Connector连接 创建映射表
CREATE TABLE mysql_source
(
id int comment 'id'
primary key (id) NOT ENFORCED
) WITH (
'connector' = 'jdbc',
'url' = 'jdbc:mysql://192.168.xx.xx:3306/xxx',
'table-name' = 'tableName',
'driver' = 'com.mysql.jdbc.Driver',
'username' = 'root',
'password' = 'xxx'
);
CREATE TABLE sqlserver_source
(
id STRING comment 'id'
) WITH (
'connector' = 'jdbc',
'url' = 'jdbc:jtds:sqlserver://192.168.xx.xxx:10009;databaseName=xxx;useLOBs=false',
'table-name' = 'schema.tableName',
'driver' = 'net.sourceforge.jtds.jdbc.Driver',
'username' = 'xx',
'password' = 'xxxxx'
);
边栏推荐
- h5机甲射击类小游戏源码下载
- 数字签名和CA证书
- CarSim simulation quick start (XIII) - steering system
- Basic dictionary of deep learning --- activation function, batch size, normalization
- c语言中函数的介绍(血书20000字!!!!)
- 【13】 Adder: how to build a circuit like Lego (Part 1)?
- After being accidentally dragged into QQ fraud group
- Qt使用信号量控制线程(QSemaphore)
- 业务数字化飞速奔跑,管理数字化亟待出发
- mysql:LIKE和REGEXP操作有什么区别?
猜你喜欢

使用FFmpeg来批量生成单图+单音频的一图流视频

Prescan quick start to master the road elements of lecture 15

The fourth phase (2021-2022) research on the implementation of cloud native technology in traditional industries - central state-owned enterprises was officially released

Discrimination coverage index / index coverage / Samsung index

See how Google uses pre training weights in target detection tasks | CVPR 2022

XSS knowledge points and 20 character short domain name bypass

No super high-rise buildings | new regulations: what information does it reveal that no new buildings above 500 meters should be built?

Puzzle (004.3) pattern puzzle
![Chapter 01 introduction of [notes of Huashu]](/img/11/cc405a730822305f02f05678f6a9d1.png)
Chapter 01 introduction of [notes of Huashu]

Prescan quick start to proficient in lecture 17, speed curve editor
随机推荐
解决EMC、EMI传导干扰的八大方法
Viewing vantage's self drive from the "three good" kitchen electricity standard and the value proposition of "serious life"
Pytorch的冻结以及解冻
What if the task manager is not fully displayed?
Mysql, how many columns can be used to create an index?
The core packages and middleware required for golang development cover all areas of the project and are worth collecting
One key switch circuit
CarSim simulation quick start (XI) - Driver Model (1)
Redis of non relational database [detailed setup of redis cluster]
Use ffmpeg to generate single image + single audio streaming video in batches
Yaml parameter configuration based on singleton mode
[chart component kit] Shanghai daoning provides developers with steema download, trial and tutorial
MCU IO port controls 12V voltage on and off, MOS and triode circuit
Deluxe H5 Tetris game source code
使用FFmpeg来批量生成单图+单音频的一图流视频
XSS knowledge points and 20 character short domain name bypass
Regular expression for mobile number verification
C#,入门教程——程序运行时的调试技巧与逻辑错误探针技术与源代码
A group of South University students rely on science and technology to go to sea, with an annual income of 1billion
Will ordinary browsers disclose information? How to protect privacy by using a secure browser?