【问题标题】:BigQuery error: No matching signature for operator >=BigQuery 错误:运算符没有匹配的签名 >=
【发布时间】:2018-02-26 20:48:52
【问题描述】:

当我运行此 R 脚本以从 BiqQuery 获取一些数据时,我收到错误 No matching signature for operator >= for argument types: STRING, INT64. Supported signatures: ANY >= ANY at [1:60]

这是我得到错误的地方:

a <- dbGetQuery(db,
paste0("select * from dta.tbl where col1='",
somevariable"' and date>=",substr(gsub("\\D","",as.character(start.date)),3,8),
" and date<=",substr(gsub("\\D","",as.character(end.date)),3,8)))

关于如何消除此错误的任何线索?我这里用的是standardsql

先谢谢了! :)

【问题讨论】:

  • 使用参数!

标签: sql r google-bigquery


【解决方案1】:

一目了然 - 试试下面

a <- dbGetQuery(db,
paste0("select * from dta.tbl where col1='",
somevariable,"' and date>='",substr(gsub("\\D","",as.character(start.date)),3,8),
"' and date<='",substr(gsub("\\D","",as.character(end.date)),3,8), "'"))

【讨论】:

  • 我现在收到此错误Error: unexpected string constant in: "paste0("select * from dta.tbl where col1='", somevariable"' and startdate&gt;='"" Execution halted
  • 要对你的 sql 进行故障排除,只需打印出你的最终字符串,看看你在哪里破坏了语法:o)
  • 我在 cronjob 中运行它,这样的故障排除有点困难:(
  • 没关系。如果你知道你的数据 - 你应该/必须 - 你可以在你的脑海中做它(“打印”结果),看看执行了什么!作为一个选项 - 您可以访问 BQ UI 并使用最近的查询来查看您正在运行的确切查询
  • 在 BQ UI 中显示Syntax error: Unclosed string literal at col1=' "。但它似乎并没有打开,这里的一切似乎都很好地关闭了
【解决方案2】:

看起来你只需要引号。

and date>='",substr(gsub("\\D","",as.character(start.date)),3,8),"' and date<='",substr(gsub("\\D","",as.character(end.date)),3,8), "'"))

【讨论】:

  • 您好,感谢您的回复,但我现在收到此错误Error: unexpected string constant in: "paste0("select * from dta.tbl where col1='", somevariable"' and startdate&gt;='"" Execution halted
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-05-20
  • 2020-04-30
  • 1970-01-01
  • 1970-01-01
  • 2019-06-16
  • 2015-06-20
  • 1970-01-01
相关资源
最近更新 更多