如何在SPARK 2.2.0中将外部表转换为托管表? [英] How can we convert an external table to managed table in SPARK 2.2.0?
问题描述
以下命令已成功将外部表转换为 Spark 2.0.0
中的托管表:
The below command was successfully converting external tables to managed tables in Spark 2.0.0
:
ALTER TABLE {table_name} SET TBLPROPERTIES(EXTERNAL=FLASE);
但是上述命令在 Spark 2.2.0
中失败,并显示以下错误:
However the above command is failing in Spark 2.2.0
with the below error:
查询错误:无法设置或更改保留的属性键:'EXTERNAL';
Error in query: Cannot set or change the preserved property key: 'EXTERNAL';
推荐答案
正如@AndyBrown在评论中指出的那样,您可以选择拖放到控制台并在其中调用Hive语句.在Scala中,这对我有用:
As @AndyBrown pointed our in a comment you have the option of dropping to the console and invoking the Hive statement there. In Scala this worked for me:
import sys.process._
val exitCode = Seq("hive", "-e", "ALTER TABLE {table_name} SET TBLPROPERTIES(\"EXTERNAL\"=\"FALSE\")").!
我在使用Spark 2.1.1时遇到了这个问题,其中@Joha的答案不起作用,因为由于被声明为惰性,无法访问spark.sessionState.
I faced this problem using Spark 2.1.1 where @Joha's answer does not work because spark.sessionState is not accessible due to being declared lazy.
这篇关于如何在SPARK 2.2.0中将外部表转换为托管表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!