创建按日期范围分区的临时表

jbose2ul  于 2021-06-27  发布在  Hive
关注(0)|答案(1)|浏览(382)

我正在尝试使用下面的查询创建一个临时表,我正在尝试修改它以创建带有按日期分区的表

create table scratch.myTable
        as (
        select 
            concat(eid,'_',group) as eid_group,
            name,
            test
        from 
            test_logs 
        where 
            regexp_like(eid, '[A-Z0-9]{22}') and 
            (regexp_like(group, '[a-z0-9]{8}') OR group = '') and
            line_type = 'test' and
            date between '2018-09-27' and '2018-09-30' and
            eid NOT IN ('123456789','ABCDEFF')
        ) WITH (partitioned_by sequence('2018-09-27','2018-09-30'))

这个查询在s3上创建一个临时表,并将所有内容作为orc文件转储。我正在努力 partition 此表按日期范围
有人能帮我问一下吗?

lskq00tm

lskq00tm1#

你试过用“结束”来代替“with”吗?

create table scratch.myTable
        as (
        select 
            concat(eid,'_',group) as eid_group,
            name,
            test
        from 
            test_logs 
        where 
            regexp_like(eid, '[A-Z0-9]{22}') and 
            (regexp_like(group, '[a-z0-9]{8}') OR group = '') and
            line_type = 'test' and
            date between '2018-09-27' and '2018-09-30' and
            eid NOT IN ('123456789','ABCDEFF')
        ) over(partition by date)

相关问题