Function not found: group_concat

本小妞迷上赌 提交于 2019-12-11 02:27:08

问题


I'm interesting in execute a query using the "group_concat" BigQuery function. When I execute the query directly in the BigQuery interface, the query ends successfully, but when I try to execute that query via Node js, the bellow error appeared:

errors:
   [ { domain: 'global',
       reason: 'invalidQuery',
       message: 'Function not found: group_concat at [4:3]',
       locationType: 'other',
       location: 'query' } ]

The code is not the problem since it executes a simple query without any problem.

My query:

SELECT
  st_hub_session_id,
  num_requests,
  group_concat( group.code, '|' ) as Codes
FROM
  table.name
GROUP BY
  st_hub_session_id,
  group_concat
LIMIT
  1000

Where could be the problem?


回答1:


Use STRING_AGG in standard SQL instead of the legacy GROUP_CONCAT. You can use standard SQL through the UI by unchecking "Use legacy SQL" under "Show Options" or else putting #standardSQL at the top of your query. See also Enabling Standard SQL.




回答2:


BigQuery has two SQL modes, Standard SQL and Legacy SQL. You probably set your app to default Standard SQL, and by the interface runs LegacySQL.

try running the query using the pragma

#legacySQL
select group_concat(col) from (select '1' as col)

group_concat function is only available in Legacy SQL and it's not part of Standard SQL 2011.



来源:https://stackoverflow.com/questions/41298741/function-not-found-group-concat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!