Fixing error “function array_length(bigint[]) does not exist”
Closer examination of the documentation shows that array_length() takes two parameters. I just had to change SELECT question_text, array_length(sort_order) AS level, … to SELECT question_text, array_length(sort_order, 1) AS level, …