Google BigQuery 标准 SQL - IN 子句适用于 BigQuery 但不适用于命令行

Google BigQuery Standard SQL - IN Clause working in BigQuery but not command line

我有一个标准 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 ("Use Legacy 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 子句在 Web 应用程序中而不是在命令行中正确执行?有有效的替代方案吗?提前致谢!

试试下面

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"