首页 > 其他分享 >hive数据分析、1

hive数据分析、1

时间:2022-10-06 16:47:21浏览次数:42  
标签:数据分析 comment string nbr sales hive day id

一、 测试题目:

1、数据导入:

要求将样表文件中的sales_sample_20170310数据导入HIVE数据仓库中。

先建表:

drop table if exists db_msg.sales;
--建表
create table db_msg.sales(
  day_id             string  comment "日期编号"
  , sale_nbr        string  comment "卖出方代码"
  , buy_nbr     string  comment "买入方代码"
  , cnt         string  comment "数量"
  , round          string  comment "金额"
)
--指定分隔符为制表符
row format delimited fields terminated by ',';

 

2、数据清洗:

要求将day_id一列中的数值清洗为真实的日期格式,可用字符串表示。

数据1对应日期2022-10-01,依次类推,15对应日期2022-10-15

insert overwrite table sales
    select date_add('2022-10-00',cast(day_id as int)) as day_id,
    sale_nbr as sale_nbr,
    buy_nbr as buy_nbr,
    cnt as cnt,
    round as round
from sales;

 

标签:数据分析,comment,string,nbr,sales,hive,day,id
From: https://www.cnblogs.com/nian-nian/p/16757905.html

相关文章