我已经在Google Cloud Bigquery上部署了Web应用,当我查询数据时出现错误"400 No matching signature for operator BETWEEN for argument types: DATE, STRING, STRING. Supported signature: (ANY) BETWEEN (ANY) AND (ANY) at [2:38]"
。这是我的SQL:
"""SELECT
Record_Start_Time, Generator_Power
FROM
Furnace.FurnaceData
WHERE
Record_Start_Time BETWEEN TIMESTAMP("2018-01-21")
AND
TIMESTAMP("2018-07-21")
ORDER BY Record_Start_Time
LIMIT 100""".format(request.form['start'],request.form['end'])
答案 0 :(得分:2)
根据您收到的错误消息(我同意您问题中的注释,这很奇怪,我怀疑与该特定查询不符),看起来字段Record_Start_Time
是类型DATE
,而在BETWEEN
运算符中,您使用的是TIMESTAMP
值。
您应该了解收到的错误消息的方式如下:
[...] operator BETWEEN for argument types: DATE, STRING, STRING. Supported signature: (ANY) BETWEEN (ANY) AND (ANY)
此错误意味着BETWEEN
运算符支持的签名为field BETWEEN a AND b
,其中field
,a
和b
的类型应相同( ANY )。此外,错误消息还会告诉您您正在执行以下操作:_DATE_ BETWEEN _STRING_ AND _STRING_
,即您正尝试将DATE
类型与STRING
类型进行比较。这看起来很奇怪,因为TIMESTAMP("2018-01-21")
是TIMESTAMP
类型的,而不是STRING
,但是我想说也许您过去曾尝试运行类似WHERE Record_Start_Time BETWEEN "2018-01-21" AND "2018-07-21"
的查询,并且出现了错误消息您共享的是与该查询相对应的那个。对于您共享的查询,错误消息应该是:
400 No matching signature for operator BETWEEN for argument types: DATE, TIMESTAMP, TIMESTAMP. Supported signature: (ANY) BETWEEN (ANY) AND (ANY) at [2:38]
长话短说,请确认Record_Start_Time
字段为DATE
类型,并且是这种情况,请将您的WHERE
子句更改为以下内容:
WHERE
Record_Start_Time BETWEEN DATE("2018-01-21")
AND
DATE("2018-07-21")