外部表不返回其文件夹中的数据 [英] External table does not return the data in its folder
问题描述
我在 Hive 中在此位置创建了一个外部表:
I have created an external table in Hive with at this location :
CREATE EXTERNAL TABLE tb
(
...
)
PARTITIONED BY (datehour INT)
ROW FORMAT SERDE 'com.cloudera.hive.serde.JSONSerDe'
LOCATION '/user/cloudera/data';
数据存在于文件夹中,但是当我查询表时,它什么都不返回.表格的结构使其适合数据结构.
The data is present in the folder but when I query the table, it returns nothing. The table is structured in a way that it fits the data structure.
SELECT * FROM tb LIMIT 3;
Hive 表是否存在某种权限问题:特定用户是否有权查询某些表?您知道一些解决方案或变通方法吗?
Is there a kind of permission issue with Hive tables: do specific users have permissions to query some tables? Do you know some solutions or workarounds?
推荐答案
您已将表创建为基于 datehour 列的分区表,但是您正在放置数据在 /user/cloudera/data 中.Hive 将在 /user/cloudera/data/datehour=(some int value) 中查找数据.由于它是外部表配置单元不会更新元存储.你需要运行一些alter语句来更新
You have created your table as partitioned table base on column datehour, but you are putting your data in /user/cloudera/data. Hive will look for data in /user/cloudera/data/datehour=(some int value). Since it is an external table hive will not update the metastore. You need to run some alter statement to update that
这里是带分区的外部表的步骤:
So here are the steps for external tables with partition:
1.) 在您的外部位置 /user/cloudera/data 中,创建一个目录 datehour=0909201401
1.) In you external location /user/cloudera/data, create a directory datehour=0909201401
OR
加载数据使用:LOAD DATA [LOCAL] INPATH '/path/to/data/file' INTO TABLE partition(datehour=0909201401)
Load data using: LOAD DATA [LOCAL] INPATH '/path/to/data/file' INTO TABLE partition(datehour=0909201401)
2.) 创建表后,运行alter 语句:ALTER TABLE ADD PARTITION (datehour=0909201401)
2.) After creating your table run a alter statement: ALTER TABLE ADD PARTITION (datehour=0909201401)
希望它有帮助...!!!
Hope it helps...!!!
这篇关于外部表不返回其文件夹中的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!