zoukankan      html  css  js  c++  java
  • 018.hive-hive两个表leftjoin,由于关联字段类型不同导致的数据错误(bigint、string)

    018.hive-hive两个表leftjoin,由于关联字段类型不同导致的数据错误(bigint、string)

    select 
    b1.member_id b1,b2.member_id b2
    from tmp1_ads_cstm_member_balance b1
    left join tmp2_ads_cstm_member_balance b2 on b1.member_id = b2.member_id
    where b1.member_id = '1257829907772824682'
    1257829907772824682  1257829907772824682
    1257829907772824682  1257829907772824680
    
    select 
    b1.member_id b1,b2.member_id b2
    from tmp1_ads_cstm_member_balance b1
    left join tmp2_ads_cstm_member_balance b2 on cast(b1.member_id as string) = b2.member_id
    where b1.member_id = '1257829907772824682'
    
    
    
    hive> show create table tmp1_ads_cstm_member_balance;
    OK
    CREATE TABLE `tmp1_ads_cstm_member_balance`(
      `member_id` bigint, 
      `member_card` string, 
      `member_phone` string, 
      `member_name` string, 
      `register_time` timestamp, 
      `shop_name` string, 
      `shop_code` string, 
      `shop_type` int, 
      `organization_id` bigint, 
      `organization_name` string, 
      `activate_time` timestamp, 
      `tenant_id` bigint)
    ROW FORMAT SERDE 
      'org.apache.hadoop.hive.ql.io.orc.OrcSerde' 
    STORED AS INPUTFORMAT 
      'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat' 
    OUTPUTFORMAT 
      'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat'
    LOCATION
      'hdfs://bi-stage/apps/hive/warehouse/saas.db/tmp1_ads_cstm_member_balance'
    TBLPROPERTIES (
      'COLUMN_STATS_ACCURATE'='{"BASIC_STATS":"true"}', 
      'numFiles'='10', 
      'numRows'='1491161', 
      'rawDataSize'='582180585', 
      'totalSize'='31368949', 
      'transient_lastDdlTime'='1634792580')
      
    
    hive> show create table tmp2_ads_cstm_member_balance;
    OK
    CREATE TABLE `tmp2_ads_cstm_member_balance`(
      `member_id` string COMMENT '????', 
      `balance` float COMMENT '????????', 
      `actual_balance` float COMMENT '??????', 
      `actual_recharge_amount` float COMMENT '????', 
      `actual_consume_amount` float COMMENT '??????', 
      `total_consume_amount` float COMMENT '???????', 
      `consume_total_count` int COMMENT '??????', 
      `give_total_amount` float COMMENT '????(??????????)', 
      `give_total_consume_amount` float COMMENT '??????(??????????)', 
      `total_amount` float COMMENT '?????', 
      `activity_give_total_amount` float COMMENT '??????(????/????)', 
      `event_give_total_amount` float COMMENT '??????(??????-????-????)', 
      `give_expired_amount` float COMMENT '??????', 
      `give_balance` float COMMENT '??????(??????????)', 
      `consume_total_pay_amount` double COMMENT '?????????)')
    COMMENT '???????-??'
    ROW FORMAT DELIMITED 
      FIELDS TERMINATED BY 'u0001' 
    STORED AS INPUTFORMAT 
      'org.apache.hadoop.hive.ql.io.orc.OrcInputFormat' 
    OUTPUTFORMAT 
      'org.apache.hadoop.hive.ql.io.orc.OrcOutputFormat'
    LOCATION
      'hdfs://bi-stage/apps/hive/warehouse/saas.db/tmp2_ads_cstm_member_balance'
    TBLPROPERTIES (
      'COLUMN_STATS_ACCURATE'='{"BASIC_STATS":"true"}', 
      'numFiles'='58', 
      'numRows'='23367', 
      'rawDataSize'='2696828', 
      'totalSize'='523061', 
      'transient_lastDdlTime'='1634792987')

  • 相关阅读:
    三级联动
    投票系统
    增删改查
    PHP基础
    查询练习
    高级查询
    高级查询练习题
    0510课堂02三元运算符,跳转语句,循环结构
    0510课堂
    050602课堂css3旋转、过渡、动画
  • 原文地址:https://www.cnblogs.com/star521/p/15433451.html
Copyright © 2011-2022 走看看