Mysterious error when combining lead function, second window function and column alias

一世执手 提交于 2019-12-12 06:00:12

问题


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 lead function
  • 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.

来源:https://stackoverflow.com/questions/32887946/mysterious-error-when-combining-lead-function-second-window-function-and-column

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!