Skip to content

The database option is not supported with the CTE statement #4598

@BabySid

Description

@BabySid

Describe the bug
In our system, the generated SQL will automatically use the form like db.table , but in CTE it do NOT works.
On the other hand, create table/view support grammar like db.table or db.view.
We hope that CTE can also support this feature

The case is shown as below

MySQL [(none)]> with tmp as (select dt, app, chan, count(distinct uids) as uv FROM db.mytale WHERE dt = 20200913 group by dt, app, chan)
    -> select dt,app, 
    -> sum(uv) as uv, 
    -> sum(distinct case when chan= 1 then uv else 0 end) as new_uv
    -> from tmp
    -> group by dt, app;
ERROR 1046 (3D000): errCode = 2, detailMessage = No database selected
MySQL [(none)]> 

Also, SQL statements like with db.tmp (....) cannot be run

To Reproduce

Expected behavior
support statement like

with database.tmp (xxx)
select f1 from database.tmp ...

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions