使用bq工具在WHERE子句中使用时间戳文字 [英] Using timestamp literals in a WHERE clause with bq tool

查看:106
本文介绍了使用bq工具在WHERE子句中使用时间戳文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我查看了BigQuery命令行工具文档,发现您可以在WHERE子句中使用时间戳文字。 ,以及微软官方网站的参考资料


I had a look at the BigQuery command line tool documentation and I saw that you are able to use timestamp literals in a WHERE clause. The documentation shows the following example:

$ bq query "SELECT name, birthday FROM dataset.table WHERE birthday <= '1959-01-01 01:02:05'"
Waiting on job_6262ac3ea9f34a2e9382840ee11538ef ... (0s) Current status: DONE
+------+---------------------+
| name |      birthday       |
+------+---------------------+
| kim  | 1958-06-24 12:18:35 |
+------+---------------------+

As the dataset.table is not a public dataset, I build an example using the wikipedia dataset.

SELECT title, timestamp, SEC_TO_TIMESTAMP(timestamp) AS human_timestamp 
FROM publicdata:samples.wikipedia 
HAVING human_timestamp>'2008-01-01 01:02:03' LIMIT 5

The example works on the BigQuery Browser but it does not on the bq tool. Why? I tried to use scape characters and several combinations of single and double quotes without success. It is a Windows issue? Here goes a screenshot:

EDIT: This is BigQuery CLI 2.0.18

解决方案

I found out that the problem is due to the greater operator > in the Windows command line. It does not have anything to do with the google-cloud-sdk, sorry.

It seems that you have to use the scape to echo the sign in the command line: ^>

I found it at google groups (by Todd and Margo Chester), and the official reference at Microsoft site.

这篇关于使用bq工具在WHERE子句中使用时间戳文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆