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

I use it to analyze clickhouse sql,But there is a problem,Can you show me #1535

Closed
lif123456 opened this issue May 13, 2022 · 4 comments · Fixed by #1676
Closed

I use it to analyze clickhouse sql,But there is a problem,Can you show me #1535

lif123456 opened this issue May 13, 2022 · 4 comments · Fixed by #1676

Comments

@lif123456
Copy link

lif123456 commented May 13, 2022

select
b.name,
a.pay_amount,
a.partner_team_id
from
order_pay a
GLOBAL join team b on a.partner_team_id = b.id

error
net.sf.jsqlparser.JSQLParserException: Encountered unexpected token: "GLOBAL" "GLOBAL"
at line 1, column 73.

Was expecting one of:

","
";"
"APPLY"
"CONNECT"
"CROSS"
"EXCEPT"
"FOR"
"FULL"
"GROUP"
"HAVING"
"INNER"
"INTERSECT"
"JOIN"
"LEFT"
"MINUS"
"NATURAL"
"ORDER"
"OUTER"
"PIVOT"
"RIGHT"
"START"
"STRAIGHT_JOIN"
"UNION"
"WHERE"
"WINDOW"
<EOF>

at net.sf.jsqlparser.parser.CCJSqlParserUtil.parseStatement(CCJSqlParserUtil.java:165)
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:59)
at net.sf.jsqlparser.parser.CCJSqlParserUtil.parse(CCJSqlParserUtil.java:37)

Because Clickhouse distributed tables need to use global join syntax
version:jsqlparser 4.0
jdk:1.8

@manticore-projects
Copy link
Contributor

Greetings!
Clickhouse's specific GLOBAL JOIN is not supported yet, but your contribution/PR will be very welcome.

@lif123456
Copy link
Author

Thank you for your reply. Can you give me an idea to modify it? It helped me a lot

@wumpz
Copy link
Member

wumpz commented May 15, 2022

  1. Start in grammar JSqlParserCC.jjt production JoinerExpression() line 2583.
  2. introduce in class Join your global flag
  3. adapt toStringand deparser to reproduce this join construct
  4. add tests in SelectTests using assertSqlCanBeParsedAndDeparsed(stmt);

@lif123456
Copy link
Author

4. assertSqlCanBeParsedAndDeparsed

Thank you. I'll try when I have time

manticore-projects added a commit to manticore-projects/JSqlParser that referenced this issue Nov 28, 2022
wumpz pushed a commit that referenced this issue Dec 22, 2022
* support clickhouse global keyword in join

* fix: add missing public Getter

Add public Getter for `updateSets`
Fixes #1630

* feat: Clickhouse GLOBAL JOIN

All credits to @julianzlzhang

fixes #1615
fixes #1535

* feat: IF/ELSE statements supports Block

Make `If... Else...` statements work with Blocks
Make `Statement()` production work with `Block()`
Rewrite the `Block()` related Unit Tests

fixes #1682

* fix: Revert unintended changes to the Special Oracle Tests

* fix: `SET` statement supports `UserVariable`

Make `SetStatement` parse Objects instead of Names only
Add Grammar to accept `UserVariable` (e.g. "set @Flag = 1")
Add Test Case for `UserVariable`

fixes #1682

* feat: Google Spanner Support

Replaces PR #1415, all credit goes to @s13o
Re-arranged some recently added Tokens in alphabetical order
Update Keywords

* fix: fix JSonExpression, accept Expressions

Make JSonExpression accept Expressions
Add Testcase
Expose Idents() and Operators()
Fixes #1696

* test: add Test for Issue #1237

Co-authored-by: Zhang Zhongliang <zhangzhongliang@xiaomi.com>
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