0
Select a,b,c from d where d.id in (select id from (select id from e)) 

Above is the sample query I want to parse using calcite.

ɢʀᴜɴᴛ
  • 32,025
  • 15
  • 116
  • 110

1 Answers1

1
String query = "Select a,b,c from d where d.id in (select id from (select id from e))";

try {
    SqlParser parser = SqlParser.create(query);
    SqlNode sqlNode = parser.parseQuery();

    sqlNode.accept(new SqlAnalyzer());

} catch (SqlParseException e) {
    e.printStackTrace();
}

With the above code you can use Calcite to parse the SQL query and you will get the parse tree. In order to actually use the tree you need to use the visitor pattern by implementing org.apache.calcite.sql.util.SqlVisitor interface.

Dhananjaya
  • 1,510
  • 2
  • 14
  • 19