What happened?
The SQL formatter does not correctly format queries that contain a UNION inside a derived table (subquery in the FROM clause).
Instead of maintaining consistent indentation and formatting for nested queries, the formatter collapses parts of the query and places the closing parenthesis directly after the final SELECT, reducing readability.
Steps to Reproduce
-
Open the SQL editor.
-
Paste the following query:
SELECT
country,
avg(happiness_score) AS happiness_score
FROM
(
SELECT
YEAR,
country,
happiness_score
FROM
happiness_scores
UNION
SELECT
2024,
country,
ladder_score
FROM
happiness_scores_current
) AS final
GROUP BY
country;
-
Run the SQL formatter.
Expected Result
SELECT
country,
avg(happiness_score) AS happiness_score
FROM
(
SELECT
YEAR,
country,
happiness_score
FROM
happiness_scores
UNION
SELECT
2024,
country,
ladder_score
FROM
happiness_scores_current
) AS final
GROUP BY
country;
The formatter should preserve indentation for the derived table and align the UNION query blocks consistently.
Actual Result
SELECT country,
avg(happiness_score) AS happiness_score
FROM (
SELECT YEAR,
country,
happiness_score
FROM happiness_scores
UNION
SELECT 2024,
country,
ladder_score
FROM happiness_scores_current) AS final
GROUP BY country;
Database type
MySQL / MariaDB
TablePro version
0.51.1
macOS version & chip
macOS 26.5
What happened?
The SQL formatter does not correctly format queries that contain a
UNIONinside a derived table (subquery in the FROM clause).Instead of maintaining consistent indentation and formatting for nested queries, the formatter collapses parts of the query and places the closing parenthesis directly after the final SELECT, reducing readability.
Steps to Reproduce
Open the SQL editor.
Paste the following query:
Run the SQL formatter.
Expected Result
The formatter should preserve indentation for the derived table and align the
UNIONquery blocks consistently.Actual Result
Database type
MySQL / MariaDB
TablePro version
0.51.1
macOS version & chip
macOS 26.5