JSqlParser icon indicating copy to clipboard operation
JSqlParser copied to clipboard

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

Open lif123456 opened this issue 3 years ago • 4 comments

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

lif123456 avatar May 13 '22 03:05 lif123456

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

manticore-projects avatar May 13 '22 13:05 manticore-projects

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

lif123456 avatar May 13 '22 14:05 lif123456

  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);

wumpz avatar May 15 '22 20:05 wumpz

4. assertSqlCanBeParsedAndDeparsed

Thank you. I'll try when I have time

lif123456 avatar May 16 '22 01:05 lif123456