Athena views can't include Athena table partitions

1

Hi,

I found out this weird bug in Athena when showing table partitions using Athena engine version 2. When retrieving the most recent partition for a table, I can easily create this simple query which picks the latest year according to the partition. In my example I have a table which is partitioned by year e.g. year=2021/file.csv , year=2022/file.csv. If I run this query in Athena

select
	*
from
	"my_year_table$partitions"
order by
	year desc
limit 1

I get 2022 back

However, If I try to create a view that does this automatically for me

create or REPLACE view HURR_DURR as 
select
	*
from
	"my_year_table$partitions"
order by
	year desc
limit 1

I'm greeted with the following error

line 5:2: Table [aws-account-number].my_database.my_year_table$partitions does not exist. This query ran against the "my_database" database, unless qualified by the query. Please post the error message on our forum or contact customer support with Query Id: 266fb6e9-4a14-47de-8760-a9a21b88387e

The reason why I want to create a view is because I have tables with much more partitioning and I want some end users that query athena to simply run the view to retrieve the most recent partition key. Is there perhaps another way to go on about it?

Best regards

  • Bump Up - does such a feature work here?

  • Same problem. It's a pain because I have a complicated subquery that I want to use in several different ways, so it's ideal for a view, but it is based on the most recent partition key. I have to copy-paste.

ottarg
질문됨 2년 전298회 조회
답변 없음

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

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

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