external table in athena does not get data from partitioned parquet files

0

I am writing out a dataframe in Glue to S3

S3bucket_node3 = glueContext.write_dynamic_frame.from_options( frame=exploded_df, connection_type="s3", format="glueparquet", connection_options={ "path": "s3://raviglue/abc-output/", "partitionKeys": ["logId"], }, format_options={"compression": "snappy"}, transformation_ctx="S3bucket_node3", )

It writes out to s3 correctly.

I crawled the parquet files and took the schema of the table created from Athena

I am trying to create an external table on the parquet using:

CREATE EXTERNAL TABLE IF NOT EXISTS abc_wide_table ( utc string, sysid string, level int, itemtype string, logitem.int int, logitem.struct.fname string, logitem.struct.sig string, logitem.struct.key string, . . . . . . logitem.string string) PARTITIONED BY(logId int) STORED AS PARQUET LOCATION 's3://raviglue/abc-output/' tblproperties ("parquet.compress"="snappy");

The table creates but does not have any data.

Please suggest fix.

Thanks, Ravi.

질문됨 일 년 전992회 조회
2개 답변
1
수락된 답변

a. Did you add the partition to Athena table, after creating the table manually, using any of these: i. Use : MSCK REPAIR TABLE Table_Name; [] MSCK REPAIR TABLE - https://docs.aws.amazon.com/athena/latest/ug/msck-repair-table.htmlii. ii. Or Use like below ALTER TABLE orders ADD PARTITION (dt = '2016-05-14', country = 'IN') LOCATION 's3://mystorage/path/to/INDIA_14_May_2016/' PARTITION (dt = '2016-05-15', country = 'IN') LOCATION 's3://mystorage/path/to/INDIA_15_May_2016/'; [] ALTER TABLE ADD PARTITION - https://docs.aws.amazon.com/athena/latest/ug/alter-table-add-partition.html

b. Additionally, you can compare the table definition for both crawler created table and manually created table Then, check partition by running command : i. Crawler Created table : SHOW PARTITIONS <table_name> ii. Manually created table from Athena : SHOW PARTITIONS <table_name> [] SHOW PARTITIONS - Synopsis - https://docs.aws.amazon.com/athena/latest/ug/show-partitions.html#synopsis

AWS
답변함 일 년 전
AWS
전문가
검토됨 일 년 전
0

Thanks, MSCK REPAIR TABLE pointed me to 2 problems - permissions for athena to add partitions and dont have uppercase letters in the partitioning key. It works now !

답변함 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인