bigquery

  • 2024
  • 21. Jul 2024 BigQuery - Sampling
  • Table sampling allows you to query subsets of large BigQuery tables, providing diverse records and reduces the cost of scanning the entire table. This query ~selects 10% of a data: SELECT * FROM datas

  • 2023
  • 19. Apr 2023 BigQuery - Set date to April 1st based on current date
  • When you need to set start_date to current financial year’s starting date. 2023-02-14 set to 2022-04-01 2023-10-34 set to 2023-04-01 DECLARE start_date DATE DEFAULT CURRENT_DATE(); SET start_d

  • 22. Apr 2023 BigQuery - calculating median
  • You can use PERCENTILE_CONT and PERCENTILE_DISC to calculate ~median. However, it doesn’t work as aggregate function in GROUP BY. APPROX_QUANTILES comes handy here using APPROX_QUANTILES(column,

  • 2022
  • 11. Nov 2022 BigQuery - Quickly mock a table
  • Sometimes to test queries, you might want to quickly mock tables like table_inplace. Here’s one way to do it. WITH table_inplace AS ( SELECT * FROM UNNEST([ STRUCT (1 AS num, 'Sun' AS na