创建按日期范围划分的暂存表

时间:2018-10-03 22:46:17

标签: python python-2.7 hive presto pyhive

我正在尝试使用以下查询创建临时表,我正在尝试对其进行修改以创建按日期进行分区的表

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将此表

有人可以帮我查询吗?

1 个答案:

答案 0 :(得分:0)

您是否尝试过将“ with”替换为“ over”?

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)