on-internet
← Community

Is a partitioned where clause after a window function executed before or after

Stack Overflow ·

Table A has a partition column event_date. If I make a view for a customer like this: CREATE VIEW my_view AS SELECT * FROM( SELECT customer_id, event_date, ROW_NUMBER() OVER ( PARTITION BY customer_id ORDER BY event_date DESC ) AS rn FROM A) WHERE rn = 1; And they then use it like this SELECT * FROM my_view WHERE event_date >= '2026-08-01'; Will BigQuery do a full table scan, then window, then filter out event_date, or will it get data from 2026-08-01 (onwards), then window? The idea is that I want to own the logic of a window function and provide it as a view, but I don't want my customer to

Comments

Sign in or sign up to comment and upvote.

No comments yet.