Original query:

SELECT MIN(i) AS range_from, MAX(i) AS range_to
FROM
(SELECT i, i-row_number() over (order by i) AS group_num FROM test ORDER BY i) AS t
GROUP BY group_num
ORDER BY group_num

Prettified:

SELECT
  min("i") AS range_from,
  max("i") AS range_to
FROM
  (
    SELECT
      "i",
      "i" - row_number() OVER (ORDER BY "i") AS group_num
    FROM
      "test"
    ORDER BY
      "i"
  ) t
GROUP BY
  "group_num"
ORDER BY
  "group_num"