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
相關文章
相關標籤/搜索