更正列名称选择

时间:2017-04-14 01:17:45

标签: sql google-bigquery

#standardSQL
SELECT
  blockchain.num_tx AS `num_tx`,
  blockchain.timestamp AS `timestamp`,
  GDELT.GLOBALEVENTID AS GLOBALEVENTID,
  PARSE_TIMESTAMP('%Y%m%d', CAST(GDELT.SQLDATE AS STRING)) AS SQLDATE,
  GDELT.Actor1Code AS Actor1Code,
  GDELT.Actor1Name AS Actor1Name,
  GDELT.Actor2Code AS Actor2Code,
  GDELT.Actor2Name AS Actor2Name,
  GDELT.AvgTone AS AvgTone,
  GDELT.SOURCEURL AS SOURCEURL
FROM
  w205_final_project.blockchain_data AS blockchain
INNER JOIN
  w205_final_project.GDELT AS GDELT
ON
  blockchain.timestamp = GDELT.SQLDATE

返回以下内容:

  

错误:对于参数类型,operator =没有匹配的签名:   TIMESTAMP,INT64。支持签名:[18:3]

时ANY = ANY

GDELT.SQLDATE列数据以整数格式开头,为YYYYMMDD; blockchain.timestamp列以timestamp格式开头,例如:

2015-01-01 04:29:21 UTC     

1 个答案:

答案 0 :(得分:2)

我不是BigQuery专家,但_embedded是仅在此查询中加入后生成的字段,您在{{1}中找不到SQLDAT(_PARSED)子句

您应该将SQLDATE(_PARSED)切换为join

GDELT.SQLDATE

第二点,不要为您的专栏PARSE_TIMESTAMP('%Y%m%d', CAST(GDELT.SQLDATE AS STRING))命名,它是一个SQL关键字,它是保留的,同样适用于#standardSQL SELECT blockchain.num_tx AS `num_tx`, blockchain.timestamp AS `timestamp`, GDELT.GLOBALEVENTID AS GLOBALEVENTID, PARSE_TIMESTAMP('%Y%m%d', CAST(SQLDATE AS STRING)) AS SQLDATE, GDELT.Actor1Code AS Actor1Code, GDELT.Actor1Name AS Actor1Name, GDELT.Actor2Code AS Actor2Code, GDELT.Actor2Name AS Actor2Name, GDELT.AvgTone AS AvgTone, GDELT.SOURCEURL AS SOURCEURL FROM final_project.blockchain_data AS blockchain INNER JOIN final_project.GDELT AS GDELT ON blockchain.timestamp = PARSE_TIMESTAMP('%Y%m%d', CAST(GDELT.SQLDATE AS STRING)) timestamp, ...至少,尝试将别名重命名为time created`

并且避免将您的别名命名为与列相同:

date

不一样:

blockchain.timestamp AS