Hive集成Solr、动态分区和补数据相关

Hive 集成Solr步骤

创建hive数据源用于存放数据
create table test(
a string,
b string,
c string
) partitioned by (ds string)
stored as orcfile;
-- ds是分区字段
创建外部表读取solr数据
drop table if exsits test_ext(
a string,
b string,
c string)
stored by 'com.easy.hive.store.SolrStorageHandler'
tblproperties('solr.url' = 'xxxxx',
'solr.query' = '*:*',
'solr.primary_key' = 'id',
'solr.cursor.batch.size' = '10000',
'solr.mapping.fields' = 'a, b, c'
);
外部表数据动态分区存储到数据源/补数据(两种)
set hive.exec.dynamic.partition.mode=nonstrict;
set hive.exec.dynamic.partition=true;
-- set hive.txn.manager=org.apache.hadoop.hive.ql.lockmgr.DummyTxnManager;

-- 第一种 同时新增多个动态分区
insert overwrite table test partition(ds string)
select *, c as ds
from test_ext;
-- 因为是以ds为分区字段,test_ext没有ds字段,所以需要多查一个字段出来

-- 第二种 新增指定分区
insert overwrite table test partition (ds='20210510')
select *
from test_ext;
-- 因为在partition (ds='20210510')指定了分区,也就相当于已经查了ds这个字段,所以这时候如果和上面一样多查一个字段就会出现字段数超出的报错

⭐分区表insert overwrite只会覆盖有操作的分区,其余分区不会受影响。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值