目录1、行转列函数2、判空函数3、时间函数4、建表语句1、行转列函数 odps 中行转列函数 wm_concat,将列信息转成行显示,可指定分隔符。 语法格式 wm_concat(separator, stri
odps 中行转列函数 wm_concat,将列信息转成行显示,可指定分隔符。
语法格式
wm_concat(separator, string) ,其中separator为分隔符,支持字符串去重,即distinct.
select wm_concat('|',sku_id)
from t_business_order_odps
where
create_time >= '2022-09-30 00:00:00';
ads 中行转列函数 group_concat,即将列信息转成行显示,默认逗号分隔。如在Mysql中查询表的所有列名。
select group_concat(COLUMN_NAME)
from infORMation_schema.COLUMNS
where
TABLE_NAME = 't_business_order';
odps 中判空函数 coalesce ,如若无运费,则显示为0。
select coalesce(freight_amount,0)
from t_business_order_odps
where
create_time >= '2022-09-30 00:00:00';
odps 中判断函数 decode ,如若无运费,则显示为0。
语法格式
decode(expression, search, result[, search, result]…[, default])
表示:三元运算符,即实现IF-THEN-ELSE分支选择的功能
select decode(order_amount,freight_amount,0)
from t_business_order_odps
where
create_time >= '2022-09-30 00:00:00';
ads 中判空函数 ifnull,如若无运费,则显示为0。
select ifnull(freight_amount,0)
from t_business_order
where
create_time >= '2022-09-30 00:00:00';
odps 中 时间字段类型为 datetime,获取当前时间函数为 getdate()。
select coalesce(freight_amount,0),getdate() as etl_time
from t_business_order_odps
where
create_time >= '2022-09-30 00:00:00';
ads 中时间字段类型为 timestamp,获取当前时间函数为 now()。
select ifnull(freight_amount,0),now() as etl_time
from t_business_order
where
create_time >= '2022-09-30 00:00:00';
odps 中 字符串字段类型为 string,时间字段类型为 datetime。
CREATE TABLE t_business_order_odps (
prov_name string COMMENT '省名称',
city_name string COMMENT '地市名',
cty_name string COMMENT '区县名称',
order_no string COMMENT '订单号',
order_amount bigint COMMENT '运费',
freight bigint COMMENT '运费',
insert_month bigint COMMENT '插入月份',
created_time datetime COMMENT '创建时间'
)
COMMENT '业务订单主表;
ads 中字符串字段类型为 varchar,时间字段类型为 timestamp。
CREATE TABLE t_business_orde (
prov_name varchar COMMENT '省名称',
city_name varchar COMMENT '地市名',
cty_name varchar COMMENT '区县名称',
order_no varchar COMMENT '订单号',
order_amount bigint COMMENT '运费',
freight bigint COMMENT '运费',
insert_month bigint COMMENT '插入月份',
created_time timestamp COMMENT '创建时间'
)
PARTITION BY HASH KEY (order_no) PARTITION NUM 128
TABLEGROUP ads_sc_rpt
OPTIONS (UPDATETYPE='BATch')
COMMENT '业务订单主表';
知识梳理
OPTIONS 类型有两种
1)batch 批量表,即数据批量入库,适用于从odps同步到ads;
2)realtime 实时表,即数据单条入库,适用于日志等信息单条入库。
到此这篇关于mysql MaxCompute与AnalyticDB实现数据处理与转换过程详解的文章就介绍到这了,更多相关Mysql MaxCompute与AnalyticDB内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!
--结束END--
本文标题: MySQL MaxCompute与AnalyticDB实现数据处理与转换过程详解
本文链接: https://www.lsjlt.com/news/175860.html(转载时请注明来源链接)
有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341
下载Word文档到电脑,方便收藏和打印~
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-29
2024-04-28
回答
回答
回答
回答
回答
回答
回答
回答
回答
回答
0