Bhupendra Dudhwal
Bhupendra Dudhwal

Reputation: 148

Why I'm getting the below error when running SQL with BigQuery

This is my sql

SELECT
  date,
  name,
  post
FROM
  [dataset.table]
WHERE
  date='2019-05-01';

This is the error

Error: Argument type mismatch in function EQUAL: 'date' is type int32, '2019-05-01' is type string

Upvotes: 0

Views: 1100

Answers (1)

Eric Keen
Eric Keen

Reputation: 423

Without a specific example for the format of data inside your date parameter this is impossible to give an exact working answer.

That said, you will need to specify that '2019-05-01' is a date, with date('2019-05-01').

Regarding your date parameter you will need to cast it to a date. Assuming it is currently formatted as an epoch timestamp the following will work: DATE(TIMESTAMP(date)).

So you would end up with something like:

WHERE 
    DATE(TIMESTAMP(date)) = date('2019-05-01')

It's worth mentioning that date is probably not a good parameter name.

Upvotes: 2

Related Questions