[英]Hive Table is MANAGED or EXTERNAL - issue post table type conversion
I have a hive table in XYZ
db named ABC
. 我在
XYZ
数据库中有一个名为ABC
的配置单元表。
When I run describe formatted XYZ.ABC;
当我运行
describe formatted XYZ.ABC;
from hue, I get the following.. 从色相中,我得到以下信息。
that is 那是
Table Type: MANAGED_TABLE
Table Parameters: EXTERNAL True
So is this actually an external or a managed/internal hive table? 那么,这实际上是外部还是托管/内部配置单元表?
This is treated as an EXTERNAL
table. 这被视为
EXTERNAL
表。 Dropping table will keep the underlying HDFS
data. 删除表将保留基础
HDFS
数据。 The table type is being shown as MANAGED_TABLE
since the parameter EXTERNAL
is set to True
, instead of TRUE
. 由于参数
EXTERNAL
设置为True
而不是TRUE
,因此表类型显示为MANAGED_TABLE
。
To fix this metadata, you can run this query: 要修复此元数据,您可以运行以下查询:
hive> ALTER TABLE XYZ.ABC SET TBLPROPERTIES('EXTERNAL'='TRUE');
Some details: 一些细节:
The table XYZ.ABC
must have been created via this kind of query: 表
XYZ.ABC
必须通过以下查询创建:
hive> CREATE TABLE XYZ.ABC
<additional table definition details>
TBLPROPERTIES (
'EXTERNAL'='True');
Describing this table will give: 描述此表将得到:
hive> desc formatted XYZ.ABC;
:
Location: hdfs://<location_of_data>
Table Type: MANAGED_TABLE
:
Table Parameters:
EXTERNAL True
Dropping this table will keep the data referenced in Location
in describe
output. 删除此表将保留
describe
输出中Location
中引用的数据。
hive> drop table XYZ.ABC;
# does not drop table data in HDFS
The Table Type
still shows as MANAGED_TABLE
which is confusing. Table Type
仍然显示为MANAGED_TABLE
,这令人困惑。
Making the value for EXTERNAL
as TRUE
will fix this. 将
EXTERNAL
的值设为TRUE
将解决此问题。
hive> ALTER TABLE XYZ.ABC SET TBLPROPERTIES('EXTERNAL'='TRUE');
Now, doing a describe
will show it as expected: 现在,进行
describe
将按预期显示它:
hive> desc formatted XYZ.ABC;
:
Location: hdfs://<location_of_data>
Table Type: EXTERNAL_TABLE
:
Table Parameters:
EXTERNAL TRUE
Lets create a sample MANAGED table , 让我们创建一个示例MANAGED表 ,
CREATE TABLE TEST_TBL(abc int, xyz string);
INSERT INTO TABLE test_tbl values(1, 'abc'),(2, 'xyz');
DESCRIBE FORMATTED test_tbl;
Changing type to EXTERNAL (in the wrong way using True
, instead of TRUE
) : 将类型更改为EXTERNAL (使用
True
而不是TRUE
以错误的方式) :
ALTER TABLE test_tbl SET TBLPROPERTIES('EXTERNAL'='True');
Now lets DROP the table , DROP TABLE test_tbl; 现在让DROP table ,DROP TABLE test_tbl;
The result: 结果:
Table is dropped but data on HDFS isn't.
表已删除,但HDFS上的数据未删除。 Showing correct external table behavior!
显示正确的外部表行为!
If we re-create the table we can see data exists: 如果重新创建表,我们可以看到数据存在:
CREATE TABLE test_tbl(abc int, xyz string);
SELECT * FROM test_tbl;
The describe shows it wrongly as MANAGED TABLE
along with EXTERNAL True
because of: 该描述将其与
EXTERNAL True
一起错误地显示为MANAGED TABLE
,原因是:
.equals check in the meta .equals签入中继
Hive Issue JIRA: HIVE-20057 蜂巢问题JIRA: HIVE-20057
Proposed fix: Use case insensitive equals 建议的解决方案: 用例不区分大小写
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.