If you can parse & convert to get a RelNode, then the RelNode will probably be 
a Project with a Filter underneath. So you can write

  RelNode r;
  RexNode condition = ((Filter) ((Project) r).getInput()).getCondition;

Now, how to parse a SQL statement to a RelNode? I think I’d use

  String sql = …;
  FrameworkConfig config = ...;
  Planner planner = Frameworks.getPlanner(config);
  SqlNode node = planner.parse(sql);
  RelRoot relRoot = planner.rel(node);
  RelNode r = relRoot.project();

but I’d like to hear what others consider to be the most painless way to use 
Calcite’s parser.

Julian

> On Sep 9, 2016, at 2:21 AM, 沈志宏 <[email protected]> wrote:
> 
> hi, dear all
> 
> is there any tool class to generate RexNodes from a SQL command?
> for example,
> 
> List<RexNode> RexNodeUtils.parse(schema, "select * from persons where name 
> like 'm%' and age>10")
> 
> i am writing a solr adapter and i really really need it to help write java 
> tests for my query translator.
> 
> best regards
> 
> 
> 

Reply via email to