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

Wrong ast.Unnest in FROM INFORMATION_SCHEMA.TABLES #123

Closed
apstndb opened this issue Sep 29, 2024 · 1 comment · Fixed by #159
Closed

Wrong ast.Unnest in FROM INFORMATION_SCHEMA.TABLES #123

apstndb opened this issue Sep 29, 2024 · 1 comment · Fixed by #159

Comments

@apstndb
Copy link
Contributor

apstndb commented Sep 29, 2024

Currently, FROM INFORMATION_SCHEMA.* are parsed as ast.Unnest.

$ go run ./tools/parse --mode query 'SELECT * FROM INFORMATION_SCHEMA.TABLE'
--- AST
&ast.QueryStatement{
  Hint:  (*ast.Hint)(nil),
  With:  (*ast.With)(nil),
  Query: &ast.Select{
    Select:   0,
    Distinct: false,
    AsStruct: false,
    Results:  []ast.SelectItem{
      &ast.Star{
        Star: 7,
      },
    },
    From: &ast.From{
      From:   9,
      Source: &ast.Unnest{
        Unnest:   -1,
        Rparen:   -1,
        Implicit: true,
        Expr:     &ast.Path{
          Idents: []*ast.Ident{
            &ast.Ident{
              NamePos: 14,
              NameEnd: 32,
              Name:    "INFORMATION_SCHEMA",
            },
            &ast.Ident{
              NamePos: 33,
              NameEnd: 38,
              Name:    "TABLE",
            },
          },
        },
        Hint:       (*ast.Hint)(nil),
        As:         (*ast.AsAlias)(nil),
        WithOffset: (*ast.WithOffset)(nil),
        Sample:     (*ast.TableSample)(nil),
      },
    },
    Where:   (*ast.Where)(nil),
    GroupBy: (*ast.GroupBy)(nil),
    Having:  (*ast.Having)(nil),
    OrderBy: (*ast.OrderBy)(nil),
    Limit:   (*ast.Limit)(nil),
  },
}

--- SQL
SELECT * FROM INFORMATION_SCHEMA.TABLE

I think it is fixed after #100.

@apstndb
Copy link
Contributor Author

apstndb commented Sep 29, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant