Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cte table not found when using limit #4230

Closed
dphil opened this issue Aug 30, 2022 · 2 comments
Closed

cte table not found when using limit #4230

dphil opened this issue Aug 30, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@dphil
Copy link

dphil commented Aug 30, 2022

Using dolt 0.40.31

Ex. this works:

dolt_db> with recursive a as (select 1 union select 2) select * from a union select * from a;
+---+
| 1 |
+---+
| 1 |
| 2 |
+---+

but this does not:

dolt_db> with recursive a as (select 1 union select 2) select * from a union select * from a limit 50;
table not found: a

Note: the same goes with non-recursive cte's

@max-hoffman
Copy link
Contributor

The issue for this one is that our CTE pattern matching rules, for regular and recursive CTEs, expect the top-level node to be WITH. Either we need to push LIMITs below WITH, or make CTE resolve pattern match more accommodating:

Limit(50)
 └─ With(a
     └─ Distinct
         └─ Union
             ├─ Project(1)
             │   └─ UnresolvedTable(dual)
             └─ Project(2)
                 └─ UnresolvedTable(dual)
    )
     └─ Distinct
         └─ Union
             ├─ Project(*)
             │   └─ UnresolvedTable(a)
             └─ Project(*)
                 └─ UnresolvedTable(a)

@fulghum fulghum added the bug Something isn't working label Aug 30, 2022
@max-hoffman
Copy link
Contributor

Fix here dolthub/go-mysql-server#1225.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants