66import logging
77import os
88import pathlib
9- import pandas as pd
109
1110from google .cloud import bigquery
1211from google .oauth2 import service_account
@@ -51,7 +50,8 @@ def run_query(query, dry_run=False, credentials_file=None):
5150
5251 job_config = bigquery .QueryJobConfig (dry_run = True , use_query_cache = False )
5352 dry_run_job = client .query (query , job_config = job_config )
54- LOGGER .info ('Estimated data processed in query (GBs): %.2f' , dry_run_job .total_bytes_processed / 1024 ** 3 )
53+ data_processed_gbs = dry_run_job .total_bytes_processed / 1024 ** 3
54+ LOGGER .info ('Estimated data processed in query (GBs): %.2f' , data_processed_gbs )
5555 # https://cloud.google.com/bigquery/pricing#on_demand_pricing
5656 # assuming have hit 1 terabyte processed in month
5757 cost_per_terabyte = 6.15
@@ -70,11 +70,17 @@ def run_query(query, dry_run=False, credentials_file=None):
7070 LOGGER .info ('Total cost for query: $%.2f' , cost )
7171 return data
7272
73+
7374def bytes_to_megabytes (bytes ):
75+ """Convert bytes to megabytes."""
7476 return bytes / 1024 / 1024
7577
78+
7679def bytes_to_gigabytes (bytes ):
80+ """Convert bytes to gigabytes."""
7781 return bytes_to_megabytes (bytes ) / 1024
7882
83+
7984def bytes_to_terabytes (bytes ):
85+ """Convert bytes to terabytes."""
8086 return bytes_to_gigabytes (bytes ) / 1024
0 commit comments