I trying to write some case statements which might change the value of all entries in the call if a particular condition is satisfied INSIDE the partition. Here is the specific
It is entirely possible that this could be done with a smart usage of analytics functions, but my SQL-fu isn't up to it. That said, it sounds like what you want is achievable with a simple JOIN statement. Let's say your current query is called Q (you could even save this as a view to make it easier).
Run
SELECT t1.*, t2.has_some_property
FROM Q AS t1
LEFT OUTER JOIN (
SELECT unique_visit_id, 1 as has_some_property
FROM Q
WHERE (REGEXP_MATCH(lagged, ...)
AND REGEXP_MATCH(hits.page.pagePath))
GROUP BY unique_visit_id
) AS t2
ON t1.unique_visit_id == t2.unique_visit_id
If you are looking for avoiding joins, you can use an aggregated function with Over. something like:
Max(If((Your Condition here),Your value here, Null)) Over( Partition By Your_Partition)
the window functions used to had some performance issues that should have been improved recently. My experience with BQ drives me to prefer Jordan's Join suggestion. But hey, its a fun riddle...