查询失败,错误为RESOURCE_EXHAUSTED(ORDER BY而不是ORDER BY)

时间:2019-06-12 15:17:17

标签: google-bigquery

我在大型表(〜60GB)上运行以下形式的查询。我认为WITH OFFSET是某种形式的ORDER BY?欢迎任何想法来解决这个问题。

我收到以下错误: 作业xxx失败,出现错误RESOURCE_EXHAUSTED:查询执行期间超出了资源:无法在分配的内存中执行查询。高峰使用:限制的112%。内存使用大户:ORDER BY操作:98%其他/未分配:2%;职位编号:xxx

WITH
  test_data AS (
  SELECT
    CAST(CURRENT_TIMESTAMP() as DATETIME) datetime,
    'xyz' AS grp,
    '["7f9f98fh9g4ef393d3h5", "chg3g33f26949hg6067d", "g477e5973ec04g7c3232", "0de1ec83304d761he786", "3c1h1f153530g90g35c2", "946637g145h48322686f"]' AS ids
  UNION ALL
  SELECT
    CAST(CURRENT_TIMESTAMP() as DATETIME) datetime,
    'abc' AS grp,
    '["7f9f98fh9g4ef393d3h5", "chg3g33fdsfsdfs49hg6067d", "g477e5973ec04g7c3232", "0de1ec83304d761he786", "3c1h1f153530g90g35c2", "946637g145h48322686f"]' AS ids ),

  as_list AS (
    SELECT
      datetime,
      grp,
      id,
      pos
    FROM
     test_data, UNNEST(SPLIT(REGEXP_REPLACE(JSON_EXTRACT(ids,'$'), r'[\[\]\"]', ''), ',')) AS id WITH OFFSET AS pos)

SELECT
  *
FROM
  as_list
ORDER BY
  grp, datetime

1 个答案:

答案 0 :(得分:2)

要解决该问题,只需删除ORDER BY或添加LIMIT