Python에서 BigQuery Query 실행 시 오류
안녕하세요.
Python을 통해서 BigQuery에 Query를 실행하여 결과 값을 이용하려고 할 때 오류가 발생하였습니다.
무슨 코드를 날렸지?
query_job = self.bigquery.query(
f"""
SELECT col1,col2,col3
FROM table
WHERE date = {self.date}
"""
)
results = query_job.result()
|
cs |
위와 같이 매우 단순한 코드를 만들었습니다.
Query를 BigQuery에 날려서 결과값을 가져와서 저장하고 이를 활용하고자 하였습니다.
오류 내용
google.api_core.exceptions.BadRequest: 400 No matching signature for operator = for argument types: STRING, INT64. Supported signature: ANY = ANY at
오류는 위와 같이 발생하였습니다.
어디가 잘못되었다고 하는 것으로 보이는데 어디인지...
해결법
구글링 하여 내용을 찾아보았는데 해당 링크에서 힌트를 얻었습니다.
https://copycoding.com/d/bigquery-error-no-matching-signature-for-operator
Google BigQuery error: No matching signature for operator >=
Google BigQuery error: No matching signature for operator >= Error Message: No matching signature for operator >= for argument types: STRING, INT64. Supported signatures: ANY >= ANY at [1:60] while running the below R script to fetch some data from
copycoding.com
Query만 때어서 보면 다음과 같이 볼 수 있는데요.
SELECT col1,col2,col3
FROM table
WHERE date = {self.date}
|
cs |
보시면 date를 검색하는 WHERE 조건에 ' ' 가 빠져 있습니다. (큰따옴표)
이를 f String에 추가해서 실행하시면 잘 동작하는 것을 볼 수 있습니다.
감사합니다.