简体   繁体   English

创建表后的 Athena 查询没有结果

[英]Athena query after create table get no result

I received List, and Read permissions to the S3 bucket, as you can see I'm able to see it from my UI and the file is parquet.我收到了对 S3 存储桶的列表和读取权限,如您所见,我能够从我的 UI 中看到它并且该文件是镶木地板。

在此处输入图像描述

Now I'm try to query it by Athena so I used this statement to create a new table:现在我尝试通过 Athena 查询它,所以我使用此语句创建了一个新表:

CREATE EXTERNAL TABLE IF NOT EXISTS `test_data`.`test_funnel` (
  `request_id` string,
  `request_time_ms` timestamp,
  `request_date` timestamp,
  `request_day` timestamp,

)
PARTITIONED BY (`dt` string, `is_won` int)
ROW FORMAT SERDE 'org.apache.hadoop.hive.ql.io.parquet.serde.ParquetHiveSerDe'
STORED AS INPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetInputFormat' OUTPUTFORMAT 'org.apache.hadoop.hive.ql.io.parquet.MapredParquetOutputFormat'
LOCATION 's3://data/data_a/agg_data_b/'
TBLPROPERTIES ('classification' = 'parquet');

When I tried to query this table I got no result, please advice当我试图查询这个表时我没有得到结果,请指教

在此处输入图像描述

UPDATE: I ran MSCK REPAIR TABLE and got Partitions not in metastore: data_v2:dt=20210828/20210831223158/is_won=1 , query the data and still get no result.更新:我运行MSCK REPAIR TABLE并得到Partitions not in metastore: data_v2:dt=20210828/20210831223158/is_won=1 ,查询数据仍然没有结果。

在此处输入图像描述

You partitioned your table.您对表进行了分区。 To make your meta store aware of those partitions you need to run MSCK REPAIR TABLE .要让您的元存储知道这些分区,您需要运行MSCK REPAIR TABLE After that you should be able to see the data.之后,您应该能够看到数据。

Edit:编辑:

It seems like the way you partitioned is not Hive compatible.看来您的分区方式与 Hive 不兼容。 You have a folder level between your partition folder levels (20210905*** etc.) which is not Key-Value based.您在分区文件夹级别(20210905*** 等)之间有一个文件夹级别,它不是基于键值的。

A workaround is adding those partitions manually in Glue, which is only possible if there are not too many.解决方法是在 Glue 中手动添加这些分区,这只有在没有太多分区的情况下才有可能。 Otherwise you need to change your partitioning.否则你需要改变你的分区。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM