简体   繁体   中英

BigQuery: Scalar subquery produced more than one element

This query was running flawlessly for many months and, out of a sudden, started throwing: Scalar subquery produced more than one element

select event_id, user_id, created_at, company_id, message_id, conversation_id, message_text, 'sent' as message_direction, created_at as message_read_at from message_sent

union all

select distinct e.event_id, e.user_id, e.created_at, e.company_id, 
e.message_id, e.conversation_id, 
e.message_text, 'received' as message_direction, 
min(c.created_at) as message_read_at
from message_received e
left outer join conversation_read c on (e.conversation_id=c.conversation_id  and c.created_at > e.created_at)
group by e.event_id, e.user_id, e.created_at, e.company_id, 
e.message_id, e.conversation_id, 
e.message_text, message_direction

What could it be?

Found it after digging further.

It wasn't a problem with this query, but with a view that's used in the query. After debugging the view definition, I figured a problem with its subquery.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM