Skip to content

Commit db478ef

Browse files
Aniket Mokashianiket486
authored andcommitted
Use only client time and update results
1 parent 1ad61f1 commit db478ef

File tree

2 files changed

+52
-68
lines changed

2 files changed

+52
-68
lines changed

bigquery/results/result.json

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,52 +9,52 @@
99

1010
"tags": ["serverless", "column-oriented", "gcp", "managed"],
1111

12-
"load_time": 781.50,
12+
"load_time": 776.91,
1313
"data_size": 8760000000,
1414

1515
"result": [
16-
[0.714,0.503,0.405],
17-
[0.53,0.33,0.426],
18-
[0.73,0.408,0.432],
19-
[0.799,0.33,0.281],
20-
[0.623,0.494,0.437],
21-
[0.738,0.553,0.546],
22-
[0.344,0.359,0.407],
23-
[0.434,0.772,0.379],
24-
[0.993,0.654,0.63],
25-
[0.855,0.855,0.82],
26-
[0.494,0.384,0.411],
27-
[0.585,0.564,0.596],
28-
[0.669,0.516,0.536],
29-
[2.199,2.128,1.78],
30-
[0.791,0.635,0.703],
31-
[0.571,0.561,0.546],
32-
[0.774,0.725,0.742],
33-
[0.577,0.896,0.517],
34-
[1.704,1.341,1.182],
35-
[0.31,0.289,0.331],
36-
[1.033,0.499,0.536],
37-
[0.588,0.62,0.544],
38-
[1.015,0.689,0.784],
39-
[1.399,0.754,0.903],
40-
[0.37,0.491,0.363],
41-
[0.369,0.348,0.34],
42-
[0.395,0.404,0.391],
43-
[0.651,0.667,0.818],
44-
[1.304,1.163,1.158],
45-
[0.659,0.425,0.529],
46-
[0.684,0.553,0.542],
47-
[0.876,0.57,0.492],
48-
[1.024,1.022,1.119],
49-
[1.261,1.257,1.374],
50-
[1.057,0.918,0.893],
51-
[0.556,0.585,0.522],
52-
[0.57,0.498,0.532],
53-
[0.473,0.411,0.411],
54-
[0.387,0.453,0.38],
55-
[0.703,0.623,0.626],
56-
[0.442,0.408,0.337],
57-
[0.372,0.361,0.442],
58-
[0.403,0.358,0.388]
16+
[0.383933,0.402355,0.370758],
17+
[0.334439,0.433776,0.416341],
18+
[0.469506,0.359557,0.386433],
19+
[0.491417,0.333208,0.4758],
20+
[0.552464,0.652322,0.555889],
21+
[0.581302,0.603089,0.674999],
22+
[1.087835,0.639649,0.360542],
23+
[0.438221,0.759105,0.497731],
24+
[0.702109,0.712533,0.678109],
25+
[0.857454,0.968303,0.995039],
26+
[0.547042,0.479513,0.475109],
27+
[0.547026,0.549529,0.614708],
28+
[0.686315,0.580551,0.630673],
29+
[1.792573,2.034019,1.845895],
30+
[0.610674,0.677655,0.643796],
31+
[0.580303,0.729024,0.622044],
32+
[0.760401,0.809858,0.822725],
33+
[0.721757,0.611165,0.744566],
34+
[1.49368,1.372045,1.498892],
35+
[0.363523,0.383959,0.366856],
36+
[0.625735,0.49802,0.473233],
37+
[0.513777,0.508772,0.527258],
38+
[0.895406,0.874879,0.799704],
39+
[0.909036,0.679151,0.730413],
40+
[0.358434,0.509104,0.467827],
41+
[0.421586,0.428603,0.33761],
42+
[0.54752,0.364919,0.444499],
43+
[0.691434,0.674469,0.930067],
44+
[1.143579,1.034013,1.105913],
45+
[0.569294,0.444362,0.463864],
46+
[0.517151,0.53565,0.523663],
47+
[0.56208,0.573,0.543899],
48+
[1.409102,1.116484,1.295522],
49+
[1.413902,1.346194,1.406088],
50+
[1.068575,0.985308,1.194028],
51+
[0.781501,0.524615,0.664192],
52+
[0.678144,0.666519,0.548661],
53+
[0.477265,0.445584,0.469621],
54+
[0.554599,0.530927,0.551336],
55+
[0.777017,0.696796,0.810055],
56+
[0.427604,0.43113,0.449339],
57+
[0.434927,0.407959,0.435918],
58+
[0.478507,0.425838,0.541504]
5959
]
6060
}

bigquery/run_queries.py

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def log(*objects: Any, sep: str = ' ', end: str = '\n', file: TextIO = sys.stder
2222
message = sep.join(str(obj) for obj in objects)
2323

2424
# 2. Prepare the log prefix
25-
timestamp = datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S")
25+
timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
2626
prefix = f"[{timestamp}] [{severity.upper()}]: "
2727

2828
# 3. Combine the prefix and the message
@@ -52,33 +52,17 @@ def log(*objects: Any, sep: str = ' ', end: str = '\n', file: TextIO = sys.stder
5252
log(f"\n[{i}]: {query}")
5353
try:
5454
client_start_time = datetime.now()
55-
query_job = client.query(query, job_config=job_config)
56-
results = query_job.result()
55+
results = client.query_and_wait(query, job_config=job_config)
5756
client_end_time = datetime.now()
5857

59-
execution_time = query_job.ended - query_job.started
60-
total_time = query_job.ended - query_job.created
61-
total_time_secs = total_time.total_seconds()
58+
client_time = client_end_time - client_start_time
59+
client_time_secs = client_time.total_seconds()
6260
endstr = "],\n" if i == 2 else ","
63-
print(f"{total_time_secs}", end=endstr)
61+
print(f"{client_time_secs}", end=endstr)
6462

65-
client_time = client_end_time - client_start_time
66-
log(f"Job ID: **{query_job.job_id}**")
67-
log(f"Query ID: **{query_job.query_id}**")
68-
log(f"State: **{query_job.state}**")
69-
log(f"Results Fetched from Cache: {query_job.cache_hit}")
70-
log(f"Created Time: {query_job.created}")
71-
log(f"Start Time: {query_job.started}")
72-
log(f"End Time: {query_job.ended}")
73-
log(f"Execution Time: {execution_time}")
74-
log(f"Total Time: {total_time}")
75-
log(f"Client Time: {client_time}")
76-
log(f"Total Rows Returned: {results.total_rows}")
63+
log(f"Job ID: **{results.job_id}**")
64+
log(f"Query ID: **{results.query_id}**")
65+
log(f"Client time: **{client_time}**")
7766

7867
except Exception as e:
7968
log(f"Job failed with error: {e}", severity="ERROR")
80-
# Print error details from the job itself
81-
if query_job.error_result:
82-
log("\n--- Job Error Details ---")
83-
log(f"Reason: {query_job.error_result.get('reason')}")
84-
log(f"Message: {query_job.error_result.get('message')}")

0 commit comments

Comments
 (0)