Reputation: 49
Im trying to migrate queries from Google big query to postgresql, and Im getting this error
ERROR: operator does not exist: timestamp without time zone > integer
select *, DATE(_modification_time) as modification_date,
CASE WHEN t_start>0 THEN DATE(t_start) END as start_date,
CASE WHEN _creation_time>0 THEN DATE(_creation_time) END as creation_date,
CASE WHEN t_finish>0 THEN DATE(t_finish) END as finish_date,
'WMT' as source
from public.set_list
Upvotes: 2
Views: 23736
Reputation: 311
You are trying to compare a timestamp
value with an integer (0). This is not allowed in Postgres. Instead, you can turn the timestamp into an integer by using the extract function and getting the number of seconds since the start of the Unix epoch (1970-01-01 00:00:00), which is an integer, then compare that with the integer 0, like this:
select *, DATE(_modification_time) as modification_date,
CASE WHEN extract(EPOCH FROM t_start) > 0
THEN DATE(t_start) END as start_date,
CASE WHEN extract(EPOCH FROM _creation_time) > 0
THEN DATE(_creation_time) END as creation_date,
CASE WHEN extract(EPOCH FROM t_finish) > 0
THEN DATE(t_finish) END as finish_date,
'WMT' as source
from public.set_list
However, I doubt that this is what you want as it means you are comparing if any of those values t_start
, _creation_time
and t_finish
is later than 1970-01-01 00:00:00. Perhaps you can share a bit more about what you are trying to accomplish here. This would help you get more focused answers.
Upvotes: 2