Big Query, cost reduction

BigQuery Cheat Sheet

How much data in a specific dataset in GCP BigQuery?

select sum(size_bytes)/(1024*1024*1024) as size_GB
from DATA_LAKE_TRANSFORMATION.__TABLES__ 

how much data in BQ project?

SELECT
  dataset_id,
  count(*) AS tables,
  SUM(row_count) AS total_rows,
  SUM(size_bytes) AS size_bytes
FROM ( 
  SELECT * FROM `dataset1.__TABLES__` UNION ALL
  SELECT * FROM `dataset2.__TABLES__` UNION ALL
)
GROUP BY 1
ORDER BY size_bytes DESC

Parsing Google Analytics custom dimensions

SELECT
(SELECT distinct value FROM h.customDimensions where index=4) as cd_4
FROM
  `MyProject.MyDataSEt.ga_sessions_*` t, t.hits h

Notice , that here you may want to notice the costs. Relevant article to different approaches to parse google analytics .

Leave a Reply