gpt4 book ai didi

hadoop - 从分区文件结构创建 Impala 外部表

转载 作者:可可西里 更新时间:2023-11-01 14:20:48 28 4
gpt4 key购买 nike

提供了如下的分区 fs 结构:

logs
└── log_type
└── 2013
├── 07
│   ├── 28
│   │   ├── host1
│   │   │   └── log_file_1.csv
│   │   └── host2
│   │   ├── log_file_1.csv
│   │   └── log_file_2.csv
│   └── 29
│   ├── host1
│   │   └── log_file_1.csv
│   └── host2
│   └── log_file_1.csv
└── 08

我一直在尝试在 Impala 中创建一个外部表:

create external table log_type (
field1 string,
field2 string,
...
)
row format delimited fields terminated by '|' location '/logs/log_type/2013/08';

我希望 Impala 递归到子目录并加载所有 csv 文件;但没有雪茄。没有错误被抛出,但没有数据被加载到表中。

/logs/log_type/2013/08/*/*/logs/log_type/2013/08/*/*/* 等不同的 glob 不起作用要么。

有没有办法做到这一点?或者我应该重组 fs - 对此有什么建议吗?

最佳答案

如果您仍在寻找答案。您需要手动注册每个单独的分区。

详情请看这里Registering External Table

您的表格架构需要调整

create external table log_type (
field1 string,
field2 string,
...)
partitioned by (year int, month int, day int, host string)
row format delimited fields terminated by '|';

更改架构以包含年、月、日和主机后,您必须递归地将每个 分区添加到表中。

像这样

ALTER TABLE log_type ADD PARTITION (year=2013, month=07, day=28, host="host1")
LOCATION '/logs/log_type/2013/07/28/host1';

之后您需要在 impala 中刷新表格。

invalidate log_type;
refresh log_type;

关于hadoop - 从分区文件结构创建 Impala 外部表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18109030/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com