presto中不一样类型的字段关联问题

今天在使用presto查数据时,遇到一个诡异的问题,相同的sql,每次查询的结果确不同,sql以下sql

select
t1.orderid,t1.ext,t2.id
from (
    select
    distinct orderid,ext
    from odl_order_detail_cps
    where billdate>='2019-05-06' and order_type=1 and isbill=1
) t1
left join dim_short_link_cps t2 on cast(t1.ext as int)=t2.id;

执行不少次,每次的结果数都不同,查了不少资料都无济于事,后来猜想是否是ext转int时报错了,在有些节点上执行失败,调整sql以下segmentfault

select
t1.orderid,t1.ext,t2.id
from (
    select
    distinct orderid,ext
    from odl_order_detail_cps
    where billdate>='2019-05-06' and order_type=1 and isbill=1
) t1
left join dim_short_link_cps t2 on  t1.ext=cast(t2.id as varchar);

结果居然正常了,证明了上面的猜想。学习

这种错误是由于ext参数有null的状况,在cast转换时,出错了,而后形成节点的任务失败,因此结果是执行正常的节点返回的数据。
在hive中就不存在这样的问题区块链



欢迎订阅「K叔区块链」 - 专一于区块链技术学习

博客地址: http://www.jouypub.com
简书主页: https://www.jianshu.com/u/756c9c8ae984
segmentfault主页: https://segmentfault.com/blog/jouypub
腾讯云主页: https://cloud.tencent.com/developer/column/72548
相关文章
相关标签/搜索