Automatically wrapping queries with duplicate columns into CTEs or Derived Tables

The requirement is to automatically wrap existing queries with duplicate columns either into CTE queries or Derived Table based queries.

The derived table approach is not that easy as mariadb doesn't yet seem to support https://jira.mariadb.org/browse/MDEV-16901.

Defining a CTE with a column list when there are duplicate columns in the query itself also triggers a duplicate column error, which I believe should not happen as the column list is already specified.

Any alternatives or possibility of future fix?

Content reproduced on this site is the property of its respective owners, and this content is not reviewed in advance by MariaDB. The views, information and opinions expressed by this content do not necessarily represent those of MariaDB or any other party.