使用 spark2.3.2 + hive3.1.0(HDP3.1.5) ① Hive 3.x 之后,内部表是支持 ACID 特性,且只支持 ORC 格式;插入式事务(仅插入事务生效),格式没有限制,配置如下两个参数:
hive.create.as.insert.only=true
metastore.create.as.acid=true
② 在 spark-sql 创建的都是外部表,可以获取到内部表,但是插入不了数据,报错如下:
spark-sql> insert into info1 values(1,'ok');
Error in query:
Spark has no access to table `linfs`.`info1`. Clients can access this table only if
they have the following capabilities: CONNECTORREAD,HIVEFULLACIDREAD,HIVEFULLACIDWRITE,HIVEMANAGESTATS,HIVECACHEINVALIDATE,CONNECTORWRITE.
This table may be a Hive-managed ACID table, or require some other capability that Spark
currently does not implement;
③ 解决方案,统一使用外部表,修改配置如下:
hive.strict.managed.tables=false
hive.create.as.insert.only=false
metastore.create.as.acid=false
|