Skip to content

MySQL does not support derived tables without aliases #12993

@peasee

Description

@peasee

Describe the bug

In some logical plans, .derive() creates a new subquery as a derived table like FROM (SELECT ...).

In MySQL, every derived table requires an alias. .derive() does not supply an alias to these derived tables, so the queries fail in MySQL.

To Reproduce

Run a query on MySQL that triggers a logical plan derive, like:

select min(ta.j1_id) as j1_min from j1 ta order by min(ta.j1_id) limit 10;

Observe the query fail, because the re-written SQL contains a derived table without an alias.

Expected behavior

The query should succeed without a syntax error.

Additional context

As seen from the MySQL manual: https://dev.mysql.com/doc/refman/8.4/en/derived-tables.html

The [AS] tbl_name clause is mandatory because every table in a FROM clause must have a name.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions