import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.table.api.EnvironmentSettings;
import org.apache.flink.table.api.Table;
import org.apache.flink.table.api.java.StreamTableEnvironment;
import org.apache.flink.types.Row;
/**
* @description 电商场景实战之实时PV和UV曲线
* @author: ZhiWen
* @create: 2020-06-01 15:23
**/
public class MainAppPvUv {
//todo 已实现 时间函数应用
/** 数据库RDS结果表
字段名 数据类型 详情
summary_date BIGINT 统计日期。
summary_min V ARCHAR 统计分钟。
pv BIGINT 单击量。
uv BIGINT 访客量。
currenttime TIMESTAMP 当前时间。*/
public static final String KAFKA_SOURCE_SQL = "CREATE TABLE source_ods_fact_log_track_action (\n" +
" account_id VARCHAR,\n" +
" --用户ID\n" +
" client_ip VARCHAR,\n" +
" --客户端IP\n" +
" client_info VARCHAR,\n" +
" --设备机型信息\n" +
" `action` VARCHAR,\n" +
" --页面跳转描述\n" +
" gpm VARCHAR,\n" +
" --埋点链路\n" +
" c_time BIGINT,\n" +
" --请求时间\n" +
" udata VARCHAR,\n" +
" --扩展信息,JSON格式\n" +
" `position` VARCHAR,\n" +
" --位置信息\n" +
" network VARCHAR,\n" +
" --网络使用情况\n" +
" p_dt VARCHAR\n" +
" --时间分区天\n" +
") WITH (\n" +
"\t'connector.type' = 'kafka',\n" +
"\t'connector.version' = 'universal',\n" +
"\t'connector.topic' = 'topic_uv',\n" +
"\t'update-mode' = 'append',\n" +
"\t'connector.properties.zookeeper.connect' = '172.24.103.8:2181',\n" +
"\t'connector.properties.bootstrap.servers' = '172.24.103.8:9092',\n" +
"\t'connector.startup-mode' = 'latest-offset',\n" +
"\t'format.type' = 'json'\n" +
")";
public static final String MYSQL_SINK_SQL = "CREATE TABLE result_cps_total_summary_pvuv_min (\n" +
" summary_date varchar,\n" +
" --统计日期\n" +
" summary_min varchar,\n" +
" --统计分钟\n" +
" pv bigint,\n" +
" --点击量\n" +
" uv bigint,\n" +
" --一天内同个访客多次访问仅计算一
Flink SQL实时计算案例三
最新推荐文章于 2025-07-20 00:05:47 发布