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

Cannot parse COUNT(DISTINCT ...) #52

Open
kendru opened this issue Jun 10, 2022 · 0 comments · May be fixed by #53
Open

Cannot parse COUNT(DISTINCT ...) #52

kendru opened this issue Jun 10, 2022 · 0 comments · May be fixed by #53

Comments

@kendru
Copy link

kendru commented Jun 10, 2022

The parser fails with an error when parsing a COUNT(DISTINCT ...) expression. It seems that the AST cannot represent this expression.

Example:

package main

import (
	"bytes"
	"log"

	"github.com/akito0107/xsqlparser"
	"github.com/akito0107/xsqlparser/dialect"
)

func main() {
	sql := "SELECT COUNT(DISTINCT id) FROM foo"
	parser, _ := xsqlparser.NewParser(bytes.NewBufferString(sql), &dialect.MySQLDialect{})
	_, err := parser.ParseStatement()
	if err != nil {
		log.Fatalln(err)
	}
}

Error:

2022/06/10 15:31:33 parseQueryBody failed: parseSelect failed: parseSelectList failed: ParseExpr failed: parsePrefix failed: parseFunction failed: expected RParen but &{Kind:SQLKeyword Value:id From:{Line:1 Col:23} To:{Line:1 Col:25}}
exit status 1
@kendru kendru linked a pull request Jun 10, 2022 that will close this issue
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