Athena - CTAS - query fails - COLUMN_NOT_FOUND - Column cannot be resolved or requester is not authorized to access requested resources.

0

Hi,

The following CTAS query fails with Col not found error.

CREATE table <table_name>
with(
format='PARQUET'
, write_compression='SNAPPY'
, partitioned_by=ARRAY["yearMonth"]
, external_location = <s3-location>
)
AS SELECT
sum("list_price") as total_list_price_1
, sum("total_list_price") as total_list_price_2
, sum("total_effective_cost") as total_effective_cost_1
, "yearMonth" 
, "clientid"
, "productcode"
from <view-name>
where "yearmonth" = '202301' 
and  "clientid" = '<some id>'
group by "yearmonth", "clientid", "productcode"

Error - COLUMN_NOT_FOUND: line 5:27: Column 'yearmonth' cannot be resolved or requester is not authorized to access requested resources. You may need to manually clean the data at location 's3://athena-604727574140-prism-frontend-wg-query-results/Unsaved/2023/10/30/tables/6b9a2284-037b-498a-a337-718f26d80230' before retrying. Athena will not delete data in your account.

the column 'yearmonth' is present in the view. The error doesnot occur if the option partitioned_by is disabled.

已提問 6 個月前檢視次數 264 次
1 個回答
0

In the WHERE and GROUP BY you reference "yearmonth" (all lower case) and in the partitioned_by you reference "yearMonth" which is mixed case. Best practice is to use lower case for column names, then you don't have to qualify them with quotes.

AWS
Don_D
已回答 1 個月前

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南