【转】Hive的严格模式

在hive里面可以通过严格模式防止用户执行那些可能产生意想不到的不好的效果的查询,从而保护hive的集群。

用户可以通过 set hive.mapred.mode=strict 来设置严格模式,改成unstrict则为飞严格模式。  在严格模式下,用户在运行如下query的时候会报错。

1. 分区表的查询没有使用分区字段来限制。

select * from strategy.log where and id = "180843496599928148";

报错

ERROR: org.apache.hive.service.cli.HiveSQLException : Error while compiling statement: FAILED: SemanticException [Error 10041]: No partition predicate found for Alias "m_loss_prediction_log" Table "m_loss_prediction_log"
有异常抛出,执行结束。

指定分区:

select * from strategy.log where dt = "2018-08-16" and id = "123";

错误消除。

2. 使用了笛卡尔积

当用户写代码将表的别名写错的时候会引起笛卡尔积,例如

SELECT *
FROM origindb.promotion__campaign c
JOIN origindb.promotion__campaignex ce
ON c.id = c.id
limit 1000

3. order by 的时候没有使用limit

SELECT *
FROM origindb.promotion__campaign 
order by id

当使用的limit的时候错误消除。

转自:https://www.cnblogs.com/benchen/p/5817420.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值