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

Custom join statement #423

Open
1 of 4 tasks
darwin67 opened this issue May 21, 2024 · 2 comments · May be fixed by #430
Open
1 of 4 tasks

Custom join statement #423

darwin67 opened this issue May 21, 2024 · 2 comments · May be fixed by #430
Assignees

Comments

@darwin67
Copy link

Is your feature request related to a problem? Please describe.

I'm using goqu for building Clickhouse queries, and it's not possible to create a custom join syntax that's not in a typical SQL syntax.

The specific join I like to do is Clickhouse's ARRAY JOIN where it's commonly used for nested data structures.
https://clickhouse.com/docs/en/sql-reference/statements/select/array-join

This is what it'll likely look like when generated.

SELECT * FROM <table>
ARRAY JOIN Foobars AS Foobar
...

Describe the solution you'd like

I'd like to have an API that I can provide the exact JOIN syntax like the following.

goqu.Select(fields...).From(model).Join(sq.L("ARRAY JOIN Foobars AS Foobar"))

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

ArrayJoin method
Actually providing an ArrayJoin method in the builder that will result in ARRAY JOIN <whatever>. But this seems unrealistic considering no other SQL databases uses this syntax.

Dialect

  • postgres
  • mysql
  • sqlite3
  • clickhouse

Additional context
Add any other context or screenshots about the feature request here.

Overall, it has been great using goqu for Clickhouse even though it's not officially supported.
Because the query builder don't allow custom syntaxes, there are a couple of occasions that we need to resort to raw string construction, and this is one of those.
So it'll be helpful to have more options, where the specific builder could allow the full syntax specified by the user instead.

@WingGithub
Copy link

WingGithub commented May 31, 2024

I'm in the same boat. Trying to use clickhouse's LEFT ANY JOIN and it looks like it will not be supported even if a clickhouse dialect is created because the join type is not a standard join type supported in the const list of exp.JoinType.

@darwin67 darwin67 linked a pull request Sep 9, 2024 that will close this issue
@darwin67
Copy link
Author

darwin67 commented Sep 9, 2024

PR created here: #430

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.

3 participants