您的位置:首页 > 文旅 > 美景 > 巴彦淖尔seo_郴州最大的网络科技公司_sem是什么意思呢_软文写作网站

巴彦淖尔seo_郴州最大的网络科技公司_sem是什么意思呢_软文写作网站

2024/12/23 9:37:36 来源:https://blog.csdn.net/itnerd/article/details/143237585  浏览:    关键词:巴彦淖尔seo_郴州最大的网络科技公司_sem是什么意思呢_软文写作网站
巴彦淖尔seo_郴州最大的网络科技公司_sem是什么意思呢_软文写作网站
CREATE CATALOG mypg WITH('type' = 'jdbc','default-database' = 'postgres','username' = 'postgres','password' = '','base-url' = 'jdbc:postgresql://10.50.108.42:5432'
);create table soc_all (
WATERMARK FOR collectorreceipttime AS collectorreceipttime - INTERVAL '5' SECOND
)
WITH('connector' = 'jdbc','url' = 'jdbc:postgresql://10.50.108.42:5432/postgres','username' = 'postgres','password' = '','driver' = 'org.postgresql.Driver'
)
LIKE `mypg`.`postgres`.`public.soc_local`;CREATE TABLE sink_pg(srcUserName STRING,eventTime TIMESTAMP(3),ip STRING,baseline STRING,alert BOOLEAN
)
WITH ('connector' = 'jdbc','url' = 'jdbc:postgresql://10.50.108.42:5432/postgres','table-name' = 'alert','username' = 'postgres','password' = '','driver' = 'org.postgresql.Driver'
);-- 改成全部小写
insert into sink_pg
select'' as srcusername,ceil(collectorreceipttime  to hour) as eventtime,srcaddress as ip,'' as baseline,false
from soc_all
where collectorreceipttime  >= '2024-10-16'
and collectorreceipttime  < '2024-10-27'
and srcaddress <> ''
limit 100;

踩坑

flink 水印字段要求 timestamp(0-3)

postgres字段类型 timestamp 默认 timestamp(6),需要转换后才能作为水印字段

ALTER TABLE public.soc_local
ALTER COLUMN collectorReceiptTime TYPE TIMESTAMP(3);

postgresql 大小写不敏感

pg 中查询大写字段需要加双引号,但是flink sql 不支持引号,所以用flinksql查询pg大写字段会报错,见参考链接。

Caused by: java.lang.IllegalArgumentException: open() failed.ERROR: column "collectorreceipttime" does not existHint: Perhaps you meant to reference the column "soc_local.collectorReceiptTime".

解决方案,把pg中字段改成全小写

参考

  • https://issues.apache.org/jira/browse/FLINK-23324
  • https://stackoverflow.com/questions/77383157/flink-postgres-jdbc-source-connector-read-uppercase-field-failed

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com