【问题标题】:Creating scratch table with partition by date range按日期范围创建带有分区的临时表
【发布时间】:2019-03-09 06:05:01
【问题描述】:

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

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

有人可以帮我查询吗?

【问题讨论】:

    标签: python python-2.7 hive presto pyhive


    【解决方案1】:

    你试过用“over”代替“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)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-09-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多