sql - redshift 无法识别的节点类型 407

标签 sql amazon-redshift

我正在开发一种同步机制,将数据从 aws redshift 移动到 aurora。为了降低网络 I/O 的负载,我正在转换 redshift 上的查询并为它们添加一个校验和查询,这样我将只导出已更改的记录。我用另一个 Select * 查询包装基本查询并添加校验和函数。

我尝试删除一些内部子查询,之后新查询开始运行,但我无法更改查询,因为它是由其他平台提供的。

基本查询:

select x.player_id as playerid,
                                    p.player_nickname, 
                                    r.region_code,
                                    s.title as season_name,

                                    x.rating as ranking_score,
                                    x.rank_no as rank_no,
                                    x.rank_no_change as rank_no_change,

                                    x.game_mode, 

                                    to_char(ga.total_score, 'FM9D00') as gyo_perf_total_score,
                                    to_char(agressive_score*100/aggresive_weight, 'FM9D000') as gyo_perf_aggressive_score, 
                                    to_char(defensive_score*100/defensive_weight, 'FM9D000') as gyo_perf_defensive_score, 
                                    to_char(survival_score*100/survival_weight, 'FM9D000') as gyo_perf_survival_score,

                                    ga.match_place_avg,

                                    rounds_played, 

                                    kills, 
                                    (kills*1.0)/rounds_played as avg_kills_per_round,
                                    assists, 
                                    (assists*1.0)/rounds_played as avg_assists_per_round,
                                    headshot_kills, 
                                    top10s, 
                                    (top10s*1.0)/rounds_played as top10s_ratio,
                                    wins, 
                                    (wins*1.0)/rounds_played as win_ratio,
                                    case when top10s = 0 then 0 else (wins*1.0)/(top10s*1.0) end as win_to_top10_ratio,
                                    losses,
                                    ga.match_group as ___matchgroup,
                                    ga.last_update_id as ___lastupdateid_ga,
                                    ___lastupdateid_st,
                                   x.last_update_id as ___lastupdateid_rn

                 from hd_stats.calc_player_ranking x
                       inner join hd_core.core_player p on x.player_id = p.player_id 
                                                           and p.player_game_id =
                                                           (select g.game_id 
                                                                                    from hd_core.core_game g 
                                                                                    where lower(g.game_short_title) = 'xxxx')

                       left join hd_core.core_region r on x.region_id = r.region_id
                       left join hd_core.core_season s on x.season_id = s.season_id

                       --gyo perf
                       left join hd_stats.calc_pubg_gyo_average ga on 
                                             ga.player_id = x.player_id 
                                             and nvl(x.season_id,0) = nvl(ga.season_id,0)
                                             and nvl(x.region_id,0) = nvl(ga.region_id,0)
                                             and nvl(x.game_mode,'') = nvl(ga.match_mode,'')

                       left join (select player_id, region_id, 
                                         season_id, match_mode,
                                         rounds_played as rounds_played, 
                                         kills as kills, 
                                         assists as assists, 
                                         headshot_kills as headshot_kills, 
                                         top10s as top10s, 
                                         wins as wins,
                                         losses as losses,
                                         lastupdate as ___lastupdateid_st

                                     from hd_stats.calc_pubg_player_season_stats s
                         ) as y 
                         on x.player_id = y.player_id
                         and nvl(x.season_id,0) = nvl(y.season_id,0)
                         and nvl(x.region_id,0) = nvl(y.region_id,0)
                         and nvl(x.game_mode,'') = nvl(y.match_mode,'')
                      order by ___lastupdateid_rn

失败的转换查询:

Select top 100 *
,func_sha1(
''
)
as synch_checksum
 from 
(
select x.player_id as playerid,
                                    p.player_nickname, 
                                    r.region_code,
                                    s.title as season_name,

                                    x.rating as ranking_score,
                                    x.rank_no as rank_no,
                                    x.rank_no_change as rank_no_change,

                                    x.game_mode, 

                                    to_char(ga.total_score, 'FM9D00') as gyo_perf_total_score,
                                    to_char(agressive_score*100/aggresive_weight, 'FM9D000') as gyo_perf_aggressive_score, 
                                    to_char(defensive_score*100/defensive_weight, 'FM9D000') as gyo_perf_defensive_score, 
                                    to_char(survival_score*100/survival_weight, 'FM9D000') as gyo_perf_survival_score,

                                    ga.match_place_avg,

                                    rounds_played, 

                                    kills, 
                                    (kills*1.0)/rounds_played as avg_kills_per_round,
                                    assists, 
                                    (assists*1.0)/rounds_played as avg_assists_per_round,
                                    headshot_kills, 
                                    top10s, 
                                    (top10s*1.0)/rounds_played as top10s_ratio,
                                    wins, 
                                    (wins*1.0)/rounds_played as win_ratio,
                                    case when top10s = 0 then 0 else (wins*1.0)/(top10s*1.0) end as win_to_top10_ratio,
                                    losses,
                                    ga.match_group as ___matchgroup,
                                    ga.last_update_id as ___lastupdateid_ga,
                                    ___lastupdateid_st,
                                   x.last_update_id as ___lastupdateid_rn

                 from hd_stats.calc_player_ranking x
                       inner join hd_core.core_player p on x.player_id = p.player_id 
                                                           and p.player_game_id =
                                                           (select g.game_id 
                                                                                    from hd_core.core_game g 
                                                                                    where lower(g.game_short_title) = 'xxxx')

                       left join hd_core.core_region r on x.region_id = r.region_id
                       left join hd_core.core_season s on x.season_id = s.season_id

                       --gyo perf
                       left join hd_stats.calc_pubg_gyo_average ga on 
                                             ga.player_id = x.player_id 
                                             and nvl(x.season_id,0) = nvl(ga.season_id,0)
                                             and nvl(x.region_id,0) = nvl(ga.region_id,0)
                                             and nvl(x.game_mode,'') = nvl(ga.match_mode,'')

                       left join (select player_id, region_id, 
                                         season_id, match_mode,
                                         rounds_played as rounds_played, 
                                         kills as kills, 
                                         assists as assists, 
                                         headshot_kills as headshot_kills, 
                                         top10s as top10s, 
                                         wins as wins,
                                         losses as losses,
                                         lastupdate as ___lastupdateid_st

                                     from hd_stats.calc_pubg_player_season_stats s
                         ) as y 
                         on x.player_id = y.player_id
                         and nvl(x.season_id,0) = nvl(y.season_id,0)
                         and nvl(x.region_id,0) = nvl(y.region_id,0)
                         and nvl(x.game_mode,'') = nvl(y.match_mode,'')
                      order by ___lastupdateid_rn
 )

有效的转换查询:

Select top 100 *
,func_sha1(
''
)
as synch_checksum
 from 
(
select x.player_id as playerid,
                                    p.player_nickname, 
                                    r.region_code,
                                    s.title as season_name,

                                    x.rating as ranking_score,
                                    x.rank_no as rank_no,
                                    x.rank_no_change as rank_no_change,

                                    x.game_mode, 

                                    to_char(ga.total_score, 'FM9D00') as gyo_perf_total_score,
                                    to_char(agressive_score*100/aggresive_weight, 'FM9D000') as gyo_perf_aggressive_score, 
                                    to_char(defensive_score*100/defensive_weight, 'FM9D000') as gyo_perf_defensive_score, 
                                    to_char(survival_score*100/survival_weight, 'FM9D000') as gyo_perf_survival_score,

                                    ga.match_place_avg,

                                    rounds_played, 

                                    kills, 
                                    (kills*1.0)/rounds_played as avg_kills_per_round,
                                    assists, 
                                    (assists*1.0)/rounds_played as avg_assists_per_round,
                                    headshot_kills, 
                                    top10s, 
                                    (top10s*1.0)/rounds_played as top10s_ratio,
                                    wins, 
                                    (wins*1.0)/rounds_played as win_ratio,
                                    case when top10s = 0 then 0 else (wins*1.0)/(top10s*1.0) end as win_to_top10_ratio,
                                    losses,
                                    ga.match_group as ___matchgroup,
                                    ga.last_update_id as ___lastupdateid_ga,
                                    ___lastupdateid_st,
                                   x.last_update_id as ___lastupdateid_rn

                 from hd_stats.calc_player_ranking x
                       inner join hd_core.core_player p on x.player_id = p.player_id 
                                                           and p.player_game_id = 2
                                                           --(select g.game_id 
                                                           --                         from hd_core.core_game g 
                                                           --                         where lower(g.game_short_title) = 'xxxx')

                       left join hd_core.core_region r on x.region_id = r.region_id
                       left join hd_core.core_season s on x.season_id = s.season_id

                       --gyo perf
                       left join hd_stats.calc_pubg_gyo_average ga on 
                                             ga.player_id = x.player_id 
                                             and nvl(x.season_id,0) = nvl(ga.season_id,0)
                                             and nvl(x.region_id,0) = nvl(ga.region_id,0)
                                             and nvl(x.game_mode,'') = nvl(ga.match_mode,'')

                       left join (select player_id, region_id, 
                                         season_id, match_mode,
                                         rounds_played as rounds_played, 
                                         kills as kills, 
                                         assists as assists, 
                                         headshot_kills as headshot_kills, 
                                         top10s as top10s, 
                                         wins as wins,
                                         losses as losses,
                                         lastupdate as ___lastupdateid_st

                                     from hd_stats.calc_pubg_player_season_stats s
                         ) as y 
                         on x.player_id = y.player_id
                         and nvl(x.season_id,0) = nvl(y.season_id,0)
                         and nvl(x.region_id,0) = nvl(y.region_id,0)
                         and nvl(x.game_mode,'') = nvl(y.match_mode,'')
                      order by ___lastupdateid_rn
 )


预期获取基本查询中的所有记录和列以及校验和的另一列。

相反,我得到一个错误:

亚马逊无效操作:无法识别的节点类型:407; [SQL 状态=XX000,数据库错误代码=500310]

最佳答案

省略 ORDER BY 子句。这减轻了我的错误。

关于sql - redshift 无法识别的节点类型 407,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57856121/

相关文章:

sql - SSMS 智能感知不一致

sql - SQL Server 中的哈希集等效项

python - 优化 : Amazon Redshift funcitons to check if daylight savings is in effect

sql - 通过查看所有列删除重复的 SQL 行

amazon-web-services - AWS Datapipeline RedShiftCopyActivity-如何指定 "columns"

ssl - Redshift JDBC 连接 : Using SSL certificate file without putting it into truststore?

sql - 使用 SQL 查询裁剪二进制列

sql - 在 SQL Server 中查找日期的简单选择查询问题

来自另一个 CASE 的 MySQL CASE 结果导致 SQL 查询

mysql - 如何在没有数据的情况下在 Redshift 中创建表的副本,但包含所有表架构(如压缩和排序键等)