斯波隼斗
斯波隼斗

Reputation: 25

Athena Query results are different when using the exactly same query twice

I use Athena for analyzing access log. The query in question is below.

  select  
  count(*) as count, 
  request_url
from logs
  where target_date = '2020/11/15'
group by request_url;

The 'target_date' column is from partition projection. This query returns different result when running it multiple times. Is there something wrong?

Upvotes: 1

Views: 1604

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269513

One thing that I can imagine is that you are thinking results are different because the results are in a different order. Without an order by clause, there is no guarantee on the ordering in the result set -- and that can change from one run to the next.

So, I would suggest something like:

select count(*) as count, request_url
from logs
where target_date = '2020/11/15'
group by request_url
order by request_url;

Upvotes: 2

Related Questions