Thanks, @Danny Chan, need little more help like I am using calcite-babel for parsing the query: I have a sql query: *select * from my_table1 dwm INNER JOIN my_table2 wl ON (dwm.id <http://dwm.id> = wl.id <http://wl.id> ) where dwm.time - 'timeinterval'::interval*
and this is my config for using BABEL: * val sqlParserConfig = SqlParser.configBuilder() .setParserFactory(SqlBabelParserImpl.FACTORY) .setConformance(SqlConformanceEnum.BABEL) .build()* *SqlParser.create(sql,sqlParserConfig).parseQuery()* but this gave me exception on *.time (Was expecting one of)* *Shivraj Singh* Software Consultant Knoldus Inc. <http://www.knoldus.com> +91-8800782123 Canada - USA - India - Singapore <https://in.linkedin.com/company/knoldus> <https://twitter.com/Knolspeak> <https://www.facebook.com/KnoldusSoftware/> <https://blog.knoldus.com/> On Fri, Feb 14, 2020 at 2:31 PM Danny Chan <[email protected]> wrote: > The XXXDialect is used for translating the Calcite RelNode tree to normal > sql text that is used in the JDBC connection to external engines, so it is > actually “unparsing”, what you need is parsing sql text to RelNode. > > Best, > Danny Chan > 在 2020年2月14日 +0800 PM3:58,Shivraj Singh <[email protected]>,写道: > > Thanks @Danny Chan , > > > > Please tell me one more thing: > > Just curious what does the PostgresSqlDialect accomplish in Calcite, if > not > > to parse postgres sqls? > > *Shivraj Singh* > > Software Consultant > > Knoldus Inc. <http://www.knoldus.com> > > +91-8800782123 > > Canada - USA - India - Singapore > > <https://in.linkedin.com/company/knoldus> <https://twitter.com/Knolspeak > > > > <https://www.facebook.com/KnoldusSoftware/> <https://blog.knoldus.com/> > > > > > > On Fri, Feb 14, 2020 at 12:26 PM Danny Chan <[email protected]> > wrote: > > > > > You should extend the babel parser by yourself. > > > > > > Shivraj Singh <[email protected]>于2020年2月14日 周五下午2:33写道: > > > > > > > I tried for BABEL conformance but it also doesn't work. > > > > This is the way I used it: > > > > > > > > val sqlParserConfig = SqlParser.configBuilder() > > > > .setParserFactory(SqlParserImpl.FACTORY) > > > > .setConformance(SqlConformanceEnum.BABEL) > > > > .setConfig(sqlParserA) > > > > .build() > > > > > > > > SqlParser.create(new > > > > SourceStringReader(sql),sqlParserConfig).parseQuery() > > > > > > > > Am I doing something wrong? > > > > > > > > *Shivraj Singh* > > > > Software Consultant > > > > Knoldus Inc. <http://www.knoldus.com> > > > > +91-8800782123 > > > > Canada - USA - India - Singapore > > > > <https://in.linkedin.com/company/knoldus> < > https://twitter.com/Knolspeak > > > > > > > > <https://www.facebook.com/KnoldusSoftware/> < > https://blog.knoldus.com/> > > > > > > > > > > > > On Thu, Feb 13, 2020 at 11:42 PM Julian Hyde <[email protected]> > wrote: > > > > > > > > > Note that Calcite's default parser only parses SQL in Calcite's > > > > > dialect (with a little leeway such as choice of quoting > characters). > > > > > > > > > > To parse other dialects, use the Babel parser. It can handle (or > could > > > > > handle) SQL extensions that are not in standard SQL and which we > don't > > > > > want to bring into Calcite SQL. PostgreSQL's "::" cast operator is > an > > > > > example of that. > > > > > > > > > > On Thu, Feb 13, 2020 at 4:00 AM Danny Chan <[email protected]> > > > wrote: > > > > > > > > > > > > If you want to parse the sql in PostgreSQL dialect, there is no > way > > > to > > > > do > > > > > > that now. You need a new SqlConformance actually. > > > > > > > > > > > > Shivraj Singh <[email protected]>于2020年2月13日 周四下午3:50写道: > > > > > > > > > > > > > Hi, I want to parse the query of PostgreSQL via Calcite and > while I > > > > am > > > > > > > parsing the query using the calcite parser it gives me > exception > > > for > > > > > system > > > > > > > keyword. > > > > > > > > > > > > > > This is the program: > > > > > > > This is the query : > > > > > > > " select system from my_table;" > > > > > > > > > > > > > > val parser:SqlParser = SqlParser.create(query) > > > > > > > parser.parseQuery() > > > > > > > > > > > > > > Exception I got. > > > > > > > org.apache.calcite.sql.parser.SqlParseException: Encountered > > > > > "*system*" at > > > > > > > line 1, column 8. > > > > > > > Was expecting one of: > > > > > > > "ABS" ... > > > > > > > "ALL" ... > > > > > > > > > > > > > > And I also got exception for this scenario to : > > > > > > > query : > > > > > > > INSERT INTO my_table(id,system_state) > > > > > > > VALUES (?, ?::system_state_type) > > > > > > > > > > > > > > exception I got: > > > > > > > org.apache.calcite.sql.parser.SqlParseException: Encountered > "*:*" > > > at > > > > > line. > > > > > > > Was expecting one of: > > > > > > > <EOF> > > > > > > > "EXCEPT" ... > > > > > > > > > > > > > > Please help me > > > > > > > 1. How to parse these queries? > > > > > > > 2. Can we parse query using PostgresqlSqlDialect, if yes then > how. > > > > > > > > > > > > > > Thanks. > > > > > > > > > > > > > > *Shivraj Singh* > > > > > > > Software Consultant > > > > > > > Knoldus Inc. <http://www.knoldus.com> > > > > > > > +91-8800782123 > > > > > > > Canada - USA - India - Singapore > > > > > > > <https://in.linkedin.com/company/knoldus> < > > > > > https://twitter.com/Knolspeak> > > > > > > > <https://www.facebook.com/KnoldusSoftware/> < > > > > https://blog.knoldus.com/ > > > > > > > > > > > > > > > > > > > > > > > > > >
