I keep getting "No matching signature for operator = for argument types: STRING, INT64. Supported signature: ANY = ANY at [18:54] in Big Query

huangapple go评论61阅读模式
英文:

I keep getting "No matching signature for operator = for argument types: STRING, INT64. Supported signature: ANY = ANY at [18:54] in Big Query

问题

我一直都在得到以下错误信息:

在 Big Query 中,参数类型为 STRING 和 INT64 的 = 运算符没有匹配的签名。支持的签名是:ANY = ANY [18:54]。

我尝试使用 CAST 将 station_id 更改为字符串,但它已经是一个字符串。我做错了什么?

英文:
SELECT
  station_id,
  name,
  number_of_rides AS number_of_rides_starting_at_station
FROM (
    SELECT
      start_station_id,
      COUNT(*) number_of_rides
    FROM bigquery-public-data.new_york.citibike_trips AS trips
    GROUP BY start_station_id
    ) AS station_num_trips
INNER JOIN bigquery-public-data.new_york.citibike_stations
ON station_id = start_station_id
ORDER BY number_of_rides DESC 

I keep getting
> No matching signature for operator = for argument types: STRING, INT64. Supported signature: ANY = ANY at [18:54] in Big Query

I tried CAST to change the station_id to a string but it already is a string.

What am I doing wrong?

答案1

得分: 0

看起来你的列中有一个是字符串。BigQuery 不能主动地将其转换为最可能的类型并进行比较。你需要在查询中明确定义值的类型转换:

SELECT
  SAFE_CAST(station_id as INT64) as station_id,
  name,
  number_of_rides AS number_of_rides_starting_at_station
FROM (
    SELECT
      start_station_id,
      COUNT(*) number_of_rides
    FROM bigquery-public-data.new_york.citibike_trips AS trips
    GROUP BY start_station_id
    ) AS station_num_trips
INNER JOIN bigquery-public-data.new_york.citibike_stations
ON SAFE_CAST(station_id AS INT64) = SAFE_CAST(start_station_id AS INT64)
ORDER BY number_of_rides DESC 
英文:

Looks like one of your columns is a string. BigQuery cannot proactively cast to the most probable types and compare values. You have to distinctively type-cast the values in your query:

SELECT
  SAFE_CAST(station_id as INT64) as station_id,
  name,
  number_of_rides AS number_of_rides_starting_at_station
FROM (
    SELECT
      start_station_id,
      COUNT(*) number_of_rides
    FROM bigquery-public-data.new_york.citibike_trips AS trips
    GROUP BY start_station_id
    ) AS station_num_trips
INNER JOIN bigquery-public-data.new_york.citibike_stations
ON SAFE_CAST(station_id AS INT64) = SAFE_CAST(start_station_id AS INT64)
ORDER BY number_of_rides DESC 

huangapple
  • 本文由 发表于 2023年2月8日 09:36:30
  • 转载请务必保留本文链接:https://go.coder-hub.com/75380605.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定