使用分区创建外部
我在 hadoop 中有数据并使用分区(日期和时间)创建了一个外部表。表创建很好,但是当我尝试查询数据时,我没有得到任何结果。
Hadoop文件路径-> /test/dt=2012-01-30/hr=17/testdata*
创建语句 ->
CREATE EXTERNAL TABLE test(adate STRING,
remoteIp STRING,
url STRING,
type STRING,
ip STRING,
useragent STRING)
COMMENT 'This is the Test view table'
PARTITIONED BY(dt STRING, hr STRING)
ROW FORMAT SERDE 'com.test.serde.ValidRawDataSerDe'
STORED AS SEQUENCEFILE
LOCATION '/test';
表创建消息->
OK
Time taken: 0.078 seconds
当我使用选择查询时,我没有得到结果 ->
hive> select * from test;
OK
Time taken: 0.052 seconds
hive> select * from test where dt='2008-08-09' and hr='17';
OK
我在这里错过了什么吗?请帮忙。
I have data in hadoop and created a external table using partitions (date and hour). The table creation is fine but when i try to query the data i m not getting any results.
Hadoop file path -> /test/dt=2012-01-30/hr=17/testdata*
Create statement ->
CREATE EXTERNAL TABLE test(adate STRING,
remoteIp STRING,
url STRING,
type STRING,
ip STRING,
useragent STRING)
COMMENT 'This is the Test view table'
PARTITIONED BY(dt STRING, hr STRING)
ROW FORMAT SERDE 'com.test.serde.ValidRawDataSerDe'
STORED AS SEQUENCEFILE
LOCATION '/test';
Table Creation message ->
OK
Time taken: 0.078 seconds
When i use select query i m not getting results ->
hive> select * from test;
OK
Time taken: 0.052 seconds
hive> select * from test where dt='2008-08-09' and hr='17';
OK
Am i missing anything here. Please help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
是的。您需要通知 Hive 有关新分区的信息。使用的命令是 ALTER TABLE ... ADD PARTITION。
Yes. You need to inform Hive about the new partition. The command to use is ALTER TABLE ... ADD PARTITION.
通过 HIVE JDBC 创建外部表不会反映在 Hive 数据仓库中。
通过 Hive JDBC 创建表后,
stmt.executeQuery("创建外部表 Trial5 (TOPIC STRING) 行格式分隔字段以 '' STORED as TEXTFILE LOCATION '/user/ranjitha/Trial5'");
我尝试从此文件中检索,但没有返回任何内容...
在此链接中:
https://groups.google.com /a/cloudera.org/forum/?fromgroups#!topic/cdh-user/YTekdFtbelE,它说使用 HIVE JDBC 无法创建外部表。
如果有人可以的话,这将非常有帮助指导我上面的内容..
谢谢!
External Table creation via HIVE JDBC isnt reflected in the hive datawarehouse.
After creating the table via Hive JDBC,
stmt.executeQuery("create external table trial5 (TOPIC STRING) row format delimited fields terminated by '' STORED as TEXTFILE LOCATION '/user/ranjitha/trial5'");,
and i try retrieving from this file, nothing is returned...
Here in this link:
https://groups.google.com/a/cloudera.org/forum/?fromgroups#!topic/cdh-user/YTekdFtbelE, it says external table creation not possible using HIVE JDBC..
It would be really helpful if someone can guide me on the above..
Thanks!