gpt4 book ai didi

sql - Google BigQuery 标准 SQL - IN 子句在 BigQuery 中工作但不在命令行中工作

转载 作者:行者123 更新时间:2023-12-05 05:16:05 26 4
gpt4 key购买 nike

我有一个标准的 sql 查询,我正尝试在 bq 命令行工具中运行。该查询在 Google BigQuery 网络应用程序(即 www.bigquery.cloud.google.com)中完美执行,但在使用 bq 命令行工具时却没有。

我放入网络应用程序的查询是:

SELECT
EXTRACT(HOUR FROM start_date) AS ride_hour,
COUNT(*) AS count_rides
FROM
`aerobic-mile-205223.bike_trip_data.bike_trip_weekdays`
WHERE
((weekday_name_abbreviated IN ('Mon',
'Tue',
'Wed',
'Thu',
'Fri'))
AND (EXTRACT(HOUR
FROM
start_date) <= 12))
GROUP BY
ride_hour
ORDER BY
count_rides DESC
(“使用旧版 SQL”标志设置为 False)

使用命令行工具时,语法为:

bq query --use_legacy_sql=false 'SELECT EXTRACT(HOUR FROM start_date) AS ride_hour, COUNT(*) AS count_rides FROM `aerobic-mile-205223.bike_trip_data.bike_trip_weekdays` WHERE ((weekday_name_abbreviated IN ('Mon', 'Tue', 'Wed', 'Thu', 'Fri')) AND (EXTRACT(HOUR FROM start_date) <= 12)) GROUP BY ride_hour ORDER BY count_rides DESC'

当我在命令行中运行它时,出现错误:

Error in query string: Error processing job 'aerobic-mile-205223:bqjob_r6cad99b97a68c167_0000016410bbe9d9_1': Unrecognized name: Mon at [1:176]

关于为什么 IN 子句在网络应用程序中而不是在命令行中正确执行的任何见解?有有效的替代方案吗?提前致谢!

最佳答案

试试下面

bq query --use_legacy_sql=false "SELECT EXTRACT(HOUR FROM start_date) AS ride_hour, COUNT(*) AS count_rides FROM \`aerobic-mile-205223.bike_trip_data.bike_trip_weekdays\` WHERE ((weekday_name_abbreviated IN ('Mon', 'Tue', 'Wed', 'Thu', 'Fri')) AND (EXTRACT(HOUR FROM start_date) <= 12)) GROUP BY ride_hour ORDER BY count_rides DESC"                  

关于sql - Google BigQuery 标准 SQL - IN 子句在 BigQuery 中工作但不在命令行中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50902222/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com