Home > other >  query don't return same result value bigquery
query don't return same result value bigquery

Time:05-18

when I run my query on the interface proposed by Bigquery and I run it on a python script I don't get the same result

the table that I am querying is the correct one and the query is a simple query of a simple count and group by

qyery on BQ:

SELECT Criticity,COUNT(*) as nb
                             FROM  `project.mytable` 
                             WHERE project_key='pppp'  AND Criticity NOT IN ("") 
                                   AND  Components like '%%' 
                           GROUP BY
                               Criticity
                           ORDER BY Criticity 

query on python script (parameters are passed correctly)

query = f"""
                             SELECT Criticity,COUNT(*) as nb
                             FROM  `{same.table}` 
                             WHERE project_key='{projectKey}'  AND Criticity NOT IN ("") 
                                   AND  Components like '{component}' 
                           GROUP BY
                               Criticity
                           ORDER BY Criticity
                             """

CodePudding user response:

Don't use string formatting, try in this way:

query = "
                             SELECT Criticity,COUNT(*) as nb
                             FROM  %s 
                             WHERE project_key=%s  AND Criticity NOT IN ("") 
                                   AND  Components like %s 
                           GROUP BY
                               Criticity
                           ORDER BY Criticity
                             " % (same.table, projectKey, component)

CodePudding user response:

resolved clear firefox cache and reload.

  • Related