绛县苗木网网站是由谁建设的,网站域名验证功能上线,平面设计的学校,装修工人ODPS 2.0 支持了很多新的集合命令(专有云升级到3版本后陆续支持)#xff0c;简化了日常工作中求集合操作的繁琐程度。增加的SQL语法包括#xff1a;UNOIN ALL、UNION DISTINCT并集#xff0c;INTERSECT ALL、INTERSECT DISTINCT交集#xff0c;EXCEPT ALL、EXCEPT DISTINCT…ODPS 2.0 支持了很多新的集合命令(专有云升级到3版本后陆续支持)简化了日常工作中求集合操作的繁琐程度。增加的SQL语法包括UNOIN ALL、UNION DISTINCT并集INTERSECT ALL、INTERSECT DISTINCT交集EXCEPT ALL、EXCEPT DISTINCT补集。 语法格式如下 select_statement UNION ALL select_statement;
select_statement UNION [DISTINCT] select_statement;
select_statement INTERSECT ALL select_statement;
select_statement INTERSECT [DISTINCT] select_statement;
select_statement EXCEPT ALL select_statement;
select_statement EXCEPT [DISTINCT] select_statement;
select_statement MINUS ALL select_statement;
select_statement MINUS [DISTINCT] select_statement; 用途分别求两个数据集的并集、交集以及求第二个数据集在第一个数据集中的补集。 参数说明 • UNION 求两个数据集的并集即将两个数据集合并成一个数据集。 • INTERSECT求两个数据集的交集。即输出两个数据集均包含的记录。 • EXCEPT 求第二个数据集在第一个数据集中的补集。即输出第一个数据集包含而第二个数据集不 包含的记录。 • MINUS 等同于EXCEPT。
具体语法参考https://help.aliyun.com/document_detail/73782.html?spm5176.11065259.1996646101.searchclickresult.718d3520fmmOJ0
实际项目中有一个利用两日全量数据比对出增量的需求推送全量数据速度很慢ADBDRDS等产品数据量超过1亿建议试用增量同步。我按照旧的JOIN方法和新的集合方法做了下比对验证试用了下新的集合命令EXCEPT ALL。测试
-- 方法一JOIN
-- other_columns 代表很多列
create table tmp_opcode1 as
select * from(
select uuid,other_columns,opcode2
from(
-- 今日新增今日变化
selectt1.uuid
,t1.other_columns
,case when t2.uuid is null then I else U end AS opcode2from prject1.table1 t1left outer join prject1.table1 t2on t1.uuidt2.uuidand t2.dt20200730where t1.dt20200731and(t2.uuid is nullor coalesce(t1.other_columns,)coalesce(t2.other_columns,))union all
-- 今日删除
selectt2.uuid
,t2.other_columns
,D as opcode2from prject1.table1 t2left outer join prject1.table1 t1on t1.uuidt2.uuidand t1.dt20200731where t2.dt20200730and t1.uuid is null)t3)t4
;
Summary:
resource cost: cpu 13.37 Core * Min, memory 30.48 GB * Min
inputs:
prject1.table1/dt20200730: 32530802 (946172216 bytes)
prject1.table1/dt20200731: 32533538 (947161664 bytes)
outputs:
prject1.tmp_opcode1: 4506 (271632 bytes)
Job run time: 26.000
-- 方法二集合
-- other_columns 代表很多列
create table tmp_opcode2 as
select * from(
select t3.*
from(
-- 今日新增今日变化
select uuid,other_columns,I as opcode2
from(
select uuid,other_columns
from prject1.table1
where dt 20200731except all
select uuid,other_columns
from prject1.table1
where dt 20200730)tunion all
-- 今日删除
selectt2.uuid
,t2.other_columns
,D as opcode2from prject1.table1 t2left outer join prject1.table1 t1on t1.uuidt2.uuidand t1.dt20200731where t2.dt20200730and t1.uuid is null)t3)t4
;
Summary:
resource cost: cpu 35.92 Core * Min, memory 74.26 GB * Min
inputs:
prject1.table1/rfq20200730: 32530802 (946172216 bytes)
prject1.table1/rfq20200731: 32533538 (947161664 bytes)
outputs:
prject1.tmp_opcode2: 4506 (259416 bytes)
Job run time: 66.000
性能 集合的方法比JOIN的方法在资源1倍使用和时间1倍上都有较多的劣势。建议实际使用JOIN方法。结果 通过多种方法比对验证两种方法的增量识别均正确可以向下游提供增量数据。 原文链接 本文为阿里云原创内容未经允许不得转载。