Consider the following query:
select
   corpus_date as alias
   ,lead(word, 1) over (partition by corpus order by word_count desc) lead
   ,max(word_count) over (partition by corpus) max_word_count
from
   [publicdata:samples.shakespeare]
where corpus='othello' and length(word) > 10
limit 5
This gives me the error message Field 'alias' not found. But alias is only used as an alias in this query. Note also that the error disappears if I comment out either the alias, or the lead function or the min function. The error also disappears if I replace lead with another window function like min or sum, while the error remains if I likewise replace max, so the necessary ingredients appear to be
- the leadfunction
- another window function
- an aliased field
I would like to know what it is about how these functions work internally that causes this mysterious error.
