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.

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
답변함 한 달 전

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

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

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

관련 콘텐츠