AWS Athena: syntax for grouping data for week ending on a Saturday
select substring(
          cast(date_add(
                  'day',
                  5+(cast(dow(
                             date_parse('2020-04-12','%Y-%m-%d')
                             )=7
                          as integer)
                    )*7,
                  date_trunc(
                     'week',
                     date_parse('2020-04-12','%Y-%m-%d')
                  )
               ) as varchar
          ),
          1,
          10
       ) as week_ending;