I can see from public documentation that BigQuery partition table has this limitation that if the partition column has a subquery as a filter, it won't prune the queried partition and reduce "bytes processed"(cost). I'm wondering if there is a way to workaround.
For example, this query will scan 38.67 GB, is there a way to reduce it?
WITH sub_query_that_generates_filter AS (
SELECT DATE "2016-10-01" as month UNION ALL
SELECT "2017-10-01" UNION ALL
SELECT "2018-10-01"
)
SELECT block_hash, fee FROM `bigquery-public-data.crypto_bitcoin.transactions`
WHERE block_timestamp_month in
(SELECT month FROM sub_query_that_generates_filter)
