\unset ECHO clickhouse_raw_query ---------------------- (1 row) clickhouse_raw_query ---------------------- (1 row) clickhouse_raw_query ---------------------- (1 row) clickhouse_raw_query ---------------------- (1 row) -- ROW_NUMBER pushdown (binary) QUERY PLAN --------------------------------- Foreign Scan Relations: Window on (events) (2 rows) entity_id | ts_event | amount | rn -----------+------------------------+--------+---- lead_100 | 2026-03-15 14:00:00+00 | 200 | 1 lead_100 | 2026-03-01 10:00:00+00 | 100 | 2 lead_200 | 2026-03-20 11:00:00+00 | 300 | 1 lead_200 | 2026-03-10 09:00:00+00 | 150 | 2 lead_300 | 2026-03-05 08:00:00+00 | 250 | 1 (5 rows) -- ROW_NUMBER pushdown (http) QUERY PLAN --------------------------------- Foreign Scan Relations: Window on (events) (2 rows) entity_id | ts_event | amount | rn -----------+------------------------+--------+---- lead_100 | 2026-03-15 14:00:00+00 | 200 | 1 lead_100 | 2026-03-01 10:00:00+00 | 100 | 2 lead_200 | 2026-03-20 11:00:00+00 | 300 | 1 lead_200 | 2026-03-10 09:00:00+00 | 150 | 2 lead_300 | 2026-03-05 08:00:00+00 | 250 | 1 (5 rows) -- MIN/MAX OVER pushdown (binary) QUERY PLAN --------------------------------- Foreign Scan Relations: Window on (events) (2 rows) entity_id | ts_event | amount | min_amount | max_amount -----------+------------------------+--------+------------+------------ lead_100 | 2026-03-01 10:00:00+00 | 100 | 100 | 200 lead_100 | 2026-03-15 14:00:00+00 | 200 | 100 | 200 lead_200 | 2026-03-10 09:00:00+00 | 150 | 150 | 300 lead_200 | 2026-03-20 11:00:00+00 | 300 | 150 | 300 lead_300 | 2026-03-05 08:00:00+00 | 250 | 250 | 250 (5 rows) -- MIN/MAX OVER pushdown (http) QUERY PLAN --------------------------------- Foreign Scan Relations: Window on (events) (2 rows) entity_id | ts_event | amount | min_amount | max_amount -----------+------------------------+--------+------------+------------ lead_100 | 2026-03-01 10:00:00+00 | 100 | 100 | 200 lead_100 | 2026-03-15 14:00:00+00 | 200 | 100 | 200 lead_200 | 2026-03-10 09:00:00+00 | 150 | 150 | 300 lead_200 | 2026-03-20 11:00:00+00 | 300 | 150 | 300 lead_300 | 2026-03-05 08:00:00+00 | 250 | 250 | 250 (5 rows) -- LEAD pushdown (binary) QUERY PLAN --------------------------------- Foreign Scan Relations: Window on (events) (2 rows) entity_id | ts_event | next_event -----------+------------------------+------------------------ lead_100 | 2026-03-01 10:00:00+00 | 2026-03-15 14:00:00+00 lead_100 | 2026-03-15 14:00:00+00 | 1970-01-01 00:00:00+00 lead_200 | 2026-03-10 09:00:00+00 | 2026-03-20 11:00:00+00 lead_200 | 2026-03-20 11:00:00+00 | 1970-01-01 00:00:00+00 lead_300 | 2026-03-05 08:00:00+00 | 1970-01-01 00:00:00+00 (5 rows) -- LEAD pushdown (http) QUERY PLAN --------------------------------- Foreign Scan Relations: Window on (events) (2 rows) entity_id | ts_event | next_event -----------+------------------------+------------------------ lead_100 | 2026-03-01 10:00:00+00 | 2026-03-15 14:00:00+00 lead_100 | 2026-03-15 14:00:00+00 | 1970-01-01 00:00:00+00 lead_200 | 2026-03-10 09:00:00+00 | 2026-03-20 11:00:00+00 lead_200 | 2026-03-20 11:00:00+00 | 1970-01-01 00:00:00+00 lead_300 | 2026-03-05 08:00:00+00 | 1970-01-01 00:00:00+00 (5 rows) -- LAG pushdown (binary) QUERY PLAN --------------------------------- Foreign Scan Relations: Window on (events) (2 rows) entity_id | ts_event | prev_amount -----------+------------------------+------------- lead_100 | 2026-03-01 10:00:00+00 | 0 lead_100 | 2026-03-15 14:00:00+00 | 100 lead_200 | 2026-03-10 09:00:00+00 | 0 lead_200 | 2026-03-20 11:00:00+00 | 150 lead_300 | 2026-03-05 08:00:00+00 | 0 (5 rows) -- rank pushdown (binary) QUERY PLAN --------------------------------- Foreign Scan Relations: Window on (events) (2 rows) entity_id | amount | rk -----------+--------+---- lead_100 | 100 | 1 lead_100 | 200 | 2 lead_100 | 210 | 3 lead_200 | 150 | 1 lead_200 | 300 | 2 lead_200 | 310 | 3 lead_300 | 250 | 1 lead_300 | 260 | 2 (8 rows) -- dense_rank pushdown (binary) QUERY PLAN --------------------------------- Foreign Scan Relations: Window on (events) (2 rows) entity_id | amount | dr -----------+--------+---- lead_100 | 100 | 1 lead_100 | 200 | 2 lead_100 | 210 | 3 lead_200 | 150 | 1 lead_200 | 300 | 2 lead_200 | 310 | 3 lead_300 | 250 | 1 lead_300 | 260 | 2 (8 rows) -- ntile pushdown (binary) QUERY PLAN --------------------------------- Foreign Scan Relations: Window on (events) (2 rows) entity_id | ts_event | bucket -----------+------------------------+-------- lead_100 | 2026-03-01 10:00:00+00 | 1 lead_300 | 2026-03-05 08:00:00+00 | 1 lead_200 | 2026-03-10 09:00:00+00 | 1 lead_100 | 2026-03-15 14:00:00+00 | 2 lead_200 | 2026-03-20 11:00:00+00 | 2 (5 rows) -- cume_dist pushdown (binary) QUERY PLAN --------------------------------- Foreign Scan Relations: Window on (events) (2 rows) entity_id | amount | cd -----------+--------+----- lead_100 | 100 | 0.2 lead_200 | 150 | 0.4 lead_100 | 200 | 0.6 lead_300 | 250 | 0.8 lead_200 | 300 | 1 (5 rows) -- percent_rank pushdown (binary) QUERY PLAN --------------------------------- Foreign Scan Relations: Window on (events) (2 rows) entity_id | amount | pr -----------+--------+------ lead_100 | 100 | 0 lead_200 | 150 | 0.25 lead_100 | 200 | 0.5 lead_300 | 250 | 0.75 lead_200 | 300 | 1 (5 rows) -- ROW_NUMBER + ORDER BY pushdown (binary) QUERY PLAN --------------------------------- Foreign Scan Relations: Window on (events) (2 rows) entity_id | ts_event | amount | rn -----------+------------------------+--------+---- lead_100 | 2026-03-15 14:00:00+00 | 200 | 1 lead_100 | 2026-03-01 10:00:00+00 | 100 | 2 lead_200 | 2026-03-20 11:00:00+00 | 300 | 1 lead_200 | 2026-03-10 09:00:00+00 | 150 | 2 lead_300 | 2026-03-05 08:00:00+00 | 250 | 1 (5 rows) -- ROW_NUMBER + ORDER BY pushdown (http) QUERY PLAN --------------------------------- Foreign Scan Relations: Window on (events) (2 rows) entity_id | ts_event | amount | rn -----------+------------------------+--------+---- lead_100 | 2026-03-15 14:00:00+00 | 200 | 1 lead_100 | 2026-03-01 10:00:00+00 | 100 | 2 lead_200 | 2026-03-20 11:00:00+00 | 300 | 1 lead_200 | 2026-03-10 09:00:00+00 | 150 | 2 lead_300 | 2026-03-05 08:00:00+00 | 250 | 1 (5 rows) -- MIN/MAX OVER + ORDER BY pushdown (binary) QUERY PLAN --------------------------------- Foreign Scan Relations: Window on (events) (2 rows) entity_id | ts_event | amount | min_amount | max_amount -----------+------------------------+--------+------------+------------ lead_100 | 2026-03-01 10:00:00+00 | 100 | 100 | 200 lead_100 | 2026-03-15 14:00:00+00 | 200 | 100 | 200 lead_200 | 2026-03-10 09:00:00+00 | 150 | 150 | 300 lead_200 | 2026-03-20 11:00:00+00 | 300 | 150 | 300 lead_300 | 2026-03-05 08:00:00+00 | 250 | 250 | 250 (5 rows) -- Window + ORDER BY + LIMIT pushdown (binary) QUERY PLAN --------------------------------- Foreign Scan Relations: Window on (events) (2 rows) entity_id | ts_event | amount | rn -----------+------------------------+--------+---- lead_100 | 2026-03-01 10:00:00+00 | 100 | 2 lead_100 | 2026-03-15 14:00:00+00 | 200 | 1 lead_200 | 2026-03-10 09:00:00+00 | 150 | 2 (3 rows) -- VERBOSE ROW_NUMBER pushdown (binary) QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Foreign Scan Output: entity_id, ts_event, (row_number()) Relations: Window on (events) Remote SQL: SELECT entity_id, ts_event, row_number() OVER (PARTITION BY entity_id ORDER BY ts_event DESC NULLS FIRST) FROM wf_test.events WHERE ((event_name = 'lead_created')) (4 rows) -- VERBOSE ROW_NUMBER pushdown (http) QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Foreign Scan Output: entity_id, ts_event, (row_number()) Relations: Window on (events) Remote SQL: SELECT entity_id, ts_event, row_number() OVER (PARTITION BY entity_id ORDER BY ts_event DESC NULLS FIRST) FROM wf_test.events WHERE ((event_name = 'lead_created')) (4 rows) -- VERBOSE MIN/MAX OVER pushdown (binary) QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Foreign Scan Output: entity_id, amount, (min(amount)), (max(amount)) Relations: Window on (events) Remote SQL: SELECT entity_id, amount, min(amount) OVER (PARTITION BY entity_id), max(amount) OVER (PARTITION BY entity_id) FROM wf_test.events WHERE ((event_name = 'lead_created')) (4 rows) -- VERBOSE LEAD pushdown (binary) QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Foreign Scan Output: entity_id, ts_event, (lead(ts_event)) Relations: Window on (events) Remote SQL: SELECT entity_id, ts_event, lead(ts_event) OVER (PARTITION BY entity_id ORDER BY ts_event ASC) FROM wf_test.events WHERE ((event_name = 'lead_created')) (4 rows) -- VERBOSE LAG pushdown (binary) QUERY PLAN --------------------------------------------------------------------------------------------------------------------------------------------------------------------- Foreign Scan Output: entity_id, ts_event, (lag(amount)) Relations: Window on (events) Remote SQL: SELECT entity_id, ts_event, lag(amount) OVER (PARTITION BY entity_id ORDER BY ts_event ASC) FROM wf_test.events WHERE ((event_name = 'lead_created')) (4 rows) -- VERBOSE rank pushdown (binary) QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Foreign Scan Output: entity_id, amount, (rank()) Relations: Window on (events) Remote SQL: SELECT entity_id, amount, rank() OVER (PARTITION BY entity_id ORDER BY amount ASC) FROM wf_test.events ORDER BY entity_id ASC NULLS LAST, amount ASC NULLS LAST (4 rows) -- VERBOSE dense_rank pushdown (binary) QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Foreign Scan Output: entity_id, amount, (dense_rank()) Relations: Window on (events) Remote SQL: SELECT entity_id, amount, dense_rank() OVER (PARTITION BY entity_id ORDER BY amount ASC) FROM wf_test.events ORDER BY entity_id ASC NULLS LAST, amount ASC NULLS LAST (4 rows) -- VERBOSE ntile pushdown (binary) QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Foreign Scan Output: entity_id, ts_event, (ntile(2)) Relations: Window on (events) Remote SQL: SELECT entity_id, ts_event, ntile(2) OVER (ORDER BY ts_event ASC) FROM wf_test.events WHERE ((event_name = 'lead_created')) ORDER BY ts_event ASC NULLS LAST (4 rows) -- VERBOSE window + ORDER BY + LIMIT pushdown (binary) QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Foreign Scan Output: entity_id, ts_event, amount, (row_number()) Relations: Window on (events) Remote SQL: SELECT entity_id, ts_event, amount, row_number() OVER (PARTITION BY entity_id ORDER BY ts_event DESC NULLS FIRST) FROM wf_test.events WHERE ((event_name = 'lead_created')) ORDER BY entity_id ASC NULLS LAST, ts_event ASC NULLS LAST LIMIT 3 (4 rows) -- VERBOSE duplicate window call (binary) QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Foreign Scan Output: entity_id, ts_event, (row_number()), (row_number()) Relations: Window on (events) Remote SQL: SELECT entity_id, ts_event, row_number() OVER (PARTITION BY entity_id ORDER BY ts_event ASC), row_number() OVER (PARTITION BY entity_id ORDER BY ts_event ASC) FROM wf_test.events WHERE ((event_name = 'lead_created')) (4 rows) entity_id | ts_event | rn1 | rn2 -----------+------------------------+-----+----- lead_100 | 2026-03-01 10:00:00+00 | 1 | 1 lead_100 | 2026-03-15 14:00:00+00 | 2 | 2 lead_200 | 2026-03-10 09:00:00+00 | 1 | 1 lead_200 | 2026-03-20 11:00:00+00 | 2 | 2 lead_300 | 2026-03-05 08:00:00+00 | 1 | 1 (5 rows) clickhouse_raw_query ---------------------- (1 row) NOTICE: drop cascades to foreign table wf_bin.events NOTICE: drop cascades to foreign table wf_http.events