bigquery中的函数TIMESTAMP_SUB没有匹配的签名

时间:2017-05-10 13:08:39

标签: google-bigquery

我正在尝试在Google BigQuery中运行此查询,但

No matching signature for function TIMESTAMP_SUB for argument types: DATETIME, INT64, DATE_TIME_PART. Supported signature: TIMESTAMP_SUB(TIMESTAMP, INTERVAL INT64 DATE_TIME_PART) at [8:5]

这是查询:

#standardSQL
CREATE TEMPORARY FUNCTION URL_DECODE(enc STRING)
RETURNS STRING
LANGUAGE js AS """
  try { 
    return decodeURI(enc);;
  } catch (e) { return null }
  return null;
""";

select 
replace(JSON_EXTRACT(URL_DECODE(l.ed), '$.phone'),"\"","") as phone
from pixel_logs.full_logs l
where ev = 'user_authentication'
and ed not like '%filipe.ferminiano%'
AND TIMESTAMP_SUB(CURRENT_DATETIME(), interval 60 minute) > timestamp
group by
phone
;

1 个答案:

答案 0 :(得分:2)

CURRENT_DATETIME()返回DATETIME值,而不是TIMESTAMP。也许您打算使用CURRENT_TIMESTAMP()

#standardSQL
CREATE TEMPORARY FUNCTION URL_DECODE(enc STRING)
RETURNS STRING
LANGUAGE js AS """
  try { 
    return decodeURI(enc);;
  } catch (e) { return null }
  return null;
""";

select 
replace(JSON_EXTRACT(URL_DECODE(l.ed), '$.phone'),"\"","") as phone
from pixel_logs.full_logs l
where ev = 'user_authentication'
and ed not like '%filipe.ferminiano%'
AND TIMESTAMP_SUB(CURRENT_TIMESTAMP(), interval 60 minute) > timestamp
group by
phone
;