Hi @jai_prakash It looks like there’s a bit of confusion with the APPENDS function, as it’s not a valid BigQuery function. This could be a mix-up in terminology or inspired by similar concepts from other platforms. In BigQuery, handling slow-arriving events and working with partitioned tables can be done using UNION ALL or by dynamically querying partitions. Here’s how you could approach it:
- Using UNION ALL for Specific Partitions
If you know the exact partitions you need to query, you can combine them explicitly like this:
WITH changed_records AS ( SELECT *, DATE(_CHANGE_TIMESTAMP) AS change_date FROM project.dataset.events_20240727 UNION ALL SELECT , DATE(_CHANGE_TIMESTAMP) AS change_date FROM project.dataset.events_20240801 ) SELECT event_date, change_date, COUNT() FROM changed_records GROUP BY 1, 2 ORDER BY change_date;
This method works well when you know which partitions you need to include.
- Dynamically Querying Multiple Partitions
If you’re working with a range of dates, you can dynamically find and query the partitions using INFORMATION_SCHEMA. Here’s an example:
DECLARE start_date STRING DEFAULT ‘20240727’; DECLARE end_date STRING DEFAULT ‘20240801’; EXECUTE IMMEDIATE FORMAT( ‘’’ SELECT event_date, DATE(_CHANGE_TIMESTAMP) AS change_date, COUNT(*) FROM %s.%s.INFORMATION_SCHEMA.PARTITIONS WHERE partition_id BETWEEN %s AND %s GROUP BY 1, 2 ORDER BY change_date ‘’', ‘project’, ‘dataset’, start_date, end_date );
- Automating with a Data Pipeline
If querying multiple partitions manually becomes tedious, consider automating the process using a data pipeline. For instance, platforms like Windsor.ai can help streamline the integration of GA4 data into BigQuery. These tools can handle schema changes and slow-arriving events automatically, saving you time and effort.
Final Thoughts
I hope these approaches help resolve your issue! Let me know if you’d like more guidance on optimizing your queries or handling partitioned tables in BigQuery. While working with partitions can feel a bit tricky at first, choosing the right method can make the process much smoother.
Hope this helps!