使用分区创建外部

发布于 2024-12-29 21:06:33 字数 751 浏览 5 评论 0原文

我在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

離殇 2025-01-05 21:06:33

是的。您需要通知 Hive 有关新分区的信息。使用的命令是 ALTER TABLE ... ADD PARTITION。

Yes. You need to inform Hive about the new partition. The command to use is ALTER TABLE ... ADD PARTITION.

巴黎夜雨 2025-01-05 21:06:33

通过 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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文