ossinsight icon indicating copy to clipboard operation
ossinsight copied to clipboard

[Explorer] Execution failed for question 989b795e-acf6-474a-9f64-1ddbd8f0d915: In GitHub, which repo's stars growth rate is higher than pingcap/tidb and may exceed pingcap/tidb after two years?

Open Win-Man opened this issue 2 years ago • 0 comments

Hi, It's failed to execute the question 989b795e-acf6-474a-9f64-1ddbd8f0d915 In GitHub, which repo's stars growth rate is higher than pingcap/tidb and may exceed pingcap/tidb after two years? (errorType = error-query-execute):

  • executedAt: 2023-02-15T06:58:12.000+00:00
  • requestedAt: 2023-02-15T06:58:12.000+00:00

Error message

Out Of Memory Quota![conn_id=486120478922959399]

Generated SQL

WITH
  star_history AS (
    SELECT
      DATE_FORMAT(ge.created_at, '%Y-%m-01') AS t_month,
      COUNT(*) AS stars
    FROM
      github_events ge
    WHERE
      ge.type = 'WatchEvent'
      AND ge.repo_id = (
        SELECT
          repo_id
        FROM
          github_repos
        WHERE
          repo_name = 'pingcap/tidb'
        LIMIT
          1
      )
    GROUP BY
      t_month
    ORDER BY
      t_month ASC
  ),
  star_growth_rate AS (
    SELECT
      t_month,
      stars,
      (
        stars - LAG(stars, 1) OVER (
          ORDER BY
            t_month
        )
      ) AS star_growth_rate
    FROM
      star_history
  )
SELECT
  gr.repo_name,
  sgr.star_growth_rate
FROM
  github_repos gr
  LEFT JOIN (
    SELECT
      repo_id,
      star_growth_rate
    FROM
      github_events ge
      LEFT JOIN star_growth_rate sgr ON DATE_FORMAT(ge.created_at, '%Y-%m-01') = sgr.t_month
    WHERE
      YEAR(ge.created_at) >= YEAR(NOW()) - 2
    GROUP BY
      repo_id,
      star_growth_rate
  ) sgr ON gr.repo_id = sgr.repo_id
WHERE
  sgr.star_growth_rate > (
    SELECT
      star_growth_rate
    FROM
      star_growth_rate
    WHERE
      t_month = (
        SELECT
          MAX(t_month)
        FROM
          star_growth_rate
      )
    LIMIT
      1
  )
ORDER BY
  sgr.star_growth_rate DESC

Win-Man avatar Feb 15 '23 07:02 Win-Man