将数据导入kudu表(建立临时hive表,从hive导入kudu)步骤

1 篇文章 0 订阅
1 篇文章 0 订阅

步骤一 hue中选择impala,建立kudu表(注意:hue中选择hive无法建立kudu表,因为hive不支持)

步骤二 hue中选择hive,建立hive临时表

drop table dim_bi_productspe_scd_hive;
CREATE TABLE if not exists dim_bi_productspe_scd_hive(
      BIProductSpeKey            bigint       
     ,BIProductSpeID             bigint       
     ,ProductSpecId              bigint       
     ,ownerType                     int       
     ,ownerid                    bigint       
     ,CityId                        int       
     ,RealWarehouseId               int       
     ,TotalCount_MinUnit         double       
     ,TotalCount_MaxUnit         double       
     ,CreateTime              timestamp       
     ,lastupdatetime          timestamp       


     ,ProductInfoID                bigint      
     ,SpeName                      string      
     ,SpeInfoMaxUnit               string      
     ,SpeInfoMinUnit               string      
     ,SpeInfoQuantity              double      

     ,BrandName                    string      
     ,StatisticsCategoryName       string      
     ,productInfoName              string      
     ,OriginalPlace                string      
     ,ProductInfoStatusID             int      
     ,ProductInfoStatus            string      
     ,BottleCode                   string      
     ,ProductCode                  string      
     ,packagingCode                string      
     ,ProductInfoTypeID               int      
     ,ProductInfoType              string      
     ,ProductStatisticsClass       bigint      
     ,SecondStatisticsClass        bigint      
     ,ShopId                       bigint      
     ,ShelfLifeLongTime           tinyint      
     ,PackageType                 tinyint      
     ,IsProcess                   tinyint      
     ,StorageType                 tinyint      

     ,ERPMinUnitCostPrice         double       
     ,ERPMaxUnitCostPrice         double       
     ,FirstDisPlayCategoryId         int       
     ,FirstDisPlayCategory        string       
     ,SecondDisPlayCategoryId        int       
     ,SecondDisPlayCategory       string       
     ,ThirdDisPlayCategoryId         int       
     ,ThirdDisPlayCategory        string       
     ,BrandID                       int      
     ,ProductBusinessClassID        int       
     ,ProductBusinessClass       string       
     ,UnitPriceClassID              int       
     ,UnitPriceClass             string       

    ,IsValid                     tinyint       
    ,ValidFrom                 timestamp       
    ,ValidTo                   timestamp       
    ,ETLCreateTime             timestamp       
    ,ETLLastUpdateTime         timestamp       
)
partitioned by(`day` string)
ROW FORMAT DELIMITED
-- FIELDS TERMINATED BY '\001'
FIELDS TERMINATED BY ',' -- 注意这里换成csv文件中列间隔符逗号','
TBLPROPERTIES('skip.header.line.count'='1');

步骤三 上传文件到服务器

SecureCRT 进入指定上传目录,ALT+P快捷键进入SFTP传输界面。

步骤四 将服务器中的上传文件加载进hive临时表(hue中选择hive进行)

注意:是追加写入

load data local inpath '/tmp/export_import/query-impala-93995.csv' overwrite into table dim_bi_productspe_scd_hive partition(day='20200922');

步骤五 将hive临时表中的数据upsert 到kudu表中(hue中选择impala进行)

建议使用upsert而非insert

upsert into table dim_bi_productspe_scd (
BIProductSpeKey        
,BIProductSpeID         
,ProductSpecId          
,ownerType              
,ownerid                
,CityId                 
,RealWarehouseId        
,TotalCount_MinUnit     
,TotalCount_MaxUnit     
,CreateTime             
,lastupdatetime         
,ProductInfoID             
,SpeName                   
,SpeInfoMaxUnit            
,SpeInfoMinUnit            
,SpeInfoQuantity           
,BrandName             
,StatisticsCategoryName
,productInfoName       
,OriginalPlace         
,ProductInfoStatusID   
,ProductInfoStatus     
,BottleCode            
,ProductCode           
,packagingCode         
,ProductInfoTypeID     
,ProductInfoType       
,ProductStatisticsClass
,SecondStatisticsClass 
,ShopId                
,ShelfLifeLongTime        
,PackageType              
,IsProcess                
,StorageType              
,ERPMinUnitCostPrice      
,ERPMaxUnitCostPrice      
,FirstDisPlayCategoryId 
,FirstDisPlayCategory   
,SecondDisPlayCategoryId
,SecondDisPlayCategory  
,ThirdDisPlayCategoryId 
,ThirdDisPlayCategory   
,BrandID                
,ProductBusinessClassID 
,ProductBusinessClass   
,UnitPriceClassID       
,UnitPriceClass         
,IsValid                 
,ValidFrom               
,ValidTo                 
,ETLCreateTime           
,ETLLastUpdateTime
) 
select
BIProductSpeKey        
,BIProductSpeID         
,ProductSpecId          
,ownerType              
,ownerid                
,CityId                 
,RealWarehouseId        
,TotalCount_MinUnit     
,TotalCount_MaxUnit     
,CreateTime             
,lastupdatetime         
,ProductInfoID             
,SpeName                   
,SpeInfoMaxUnit            
,SpeInfoMinUnit            
,SpeInfoQuantity           
,BrandName             
,StatisticsCategoryName
,productInfoName       
,OriginalPlace         
,ProductInfoStatusID   
,ProductInfoStatus     
,BottleCode            
,ProductCode           
,packagingCode         
,ProductInfoTypeID     
,ProductInfoType       
,ProductStatisticsClass
,SecondStatisticsClass 
,ShopId                
,ShelfLifeLongTime        
,PackageType              
,IsProcess                
,StorageType              
,ERPMinUnitCostPrice      
,ERPMaxUnitCostPrice      
,FirstDisPlayCategoryId 
,FirstDisPlayCategory   
,SecondDisPlayCategoryId
,SecondDisPlayCategory  
,ThirdDisPlayCategoryId 
,ThirdDisPlayCategory   
,BrandID                
,ProductBusinessClassID 
,ProductBusinessClass   
,UnitPriceClassID       
,UnitPriceClass         
,IsValid                 
,ValidFrom               
,ValidTo                 
,ETLCreateTime           
,ETLLastUpdateTime
from dim_bi_productspe_scd_hive; 
  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值