Kirk
Kirk

Reputation: 1

GCP Cloud Function JOIN Statement for Bigquery

New to Python and GCP but trying to write a HTTPGet request for Cloud Function where it reaches out to Biqguery with specific client_Id, looks up value in one table to returns value from joined table. Works in BQ and when there's no join but when I put the join in the function it breaks. Using Python 3.7 in Cloud Function.

Thanks in advance.

name = 'audience-cookie.sometable.traffic'
name2 = 'audience-cookie.sometable.cardholder' 
name3 = 'audience-cookie.sometable.traffic.customerId' 
name4 = 'audience-cookie.sometable.cardholder.customerId'


QUERY = ('SELECT '+column+' FROM '+name+' INNER JOIN '+name2+' ON '+name3+'='+name4+' WHERE Client_Id='+client_Id)

Upvotes: 0

Views: 67

Answers (1)

Soumendra Mishra
Soumendra Mishra

Reputation: 3653

Please use the below format:

QUERY = """SELECT columns FROM {} INNER JOIN {} ON {} = {} WHERE Client_Id = '{}'""".format(name, name2, name3, name4, client_Id)

Upvotes: 1

Related Questions