首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何将Postgres代码转换为雪花?

如何将Postgres代码转换为雪花?
EN

Stack Overflow用户
提问于 2022-07-27 20:46:13
回答 1查看 73关注 0票数 0

我很难将ff Postgres代码转换为雪花码。有人能帮忙吗?

代码语言:javascript
复制
WITH sitel_users as (
          select
            user_id
          from validation_rep vr
          where true
            and (vr.feature_flags ->> 'is_bogota')::bool is true
        ), call_grade as (
          select
              aoc.user_id
            , (aocg.created_at at time zone 'z' at time zone 'us/central')::date as call_grade_date
            , avg(aocg.score) call_grade_avg
          from asterisk_outbound_call_grade aocg
            join asterisk_outbound_call aoc on aocg.asterisk_outbound_call_id = aoc.id
          where true
            and aocg.deleted_at is null
            and aocg.created_at >= current_date::timestamp at time zone 'us/central' - interval '7 days'
            and exists(select 1 from sitel_users su where aoc.user_id = su.user_id)
          group by 1,2
EN

回答 1

Stack Overflow用户

发布于 2022-07-27 21:15:51

我认为重写此SQL不需要检查/触摸数据,因为不兼容的SQL与数据和TZ转换有关。不管怎么说,这对你来说可能是个好开始:

代码语言:javascript
复制
WITH sitel_users as (
          select
            user_id
          from validation_rep vr
          where true
           and vr.feature_flags:VARCHAR = 'is_bogota'
           /* and (vr.feature_flags ->> 'is_bogota')::bool is true */
        ), call_grade as (
          select
              aoc.user_id
            , convert_timezone( 'America/Chicago', convert_timezone( 'UTC', d )  )::DATE  as  call_grade_date
             /* (aocg.created_at at time zone 'z' at time zone 'us/central' )::date   as  call_grade_date */
            , avg(aocg.score) call_grade_avg
          from asterisk_outbound_call_grade aocg
            join asterisk_outbound_call aoc on aocg.asterisk_outbound_call_id = aoc.id
          where true
            and aocg.deleted_at is null
            and aocg.created_at >= convert_timezone('America/Chicago', current_date ) - interval '7 days' 
            /*  and aocg.created_at >= current_date::timestamp at time zone 'us/central' - interval '7 days' */
            and exists(select 1 from sitel_users su where aoc.user_id = su.user_id)
          group by 1,2
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73144424

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档