Say from some legacy system I get some valid select stmt, e.g. "select a, b
from foobar" (and known field names/types, how do I push this as an
unparsed subquery into a relbuilder so I can do something like

    RelNode node = builder
        .projectPlus(builder.call(MINUS, builder.field("b"),
builder.field("a")))
        .build();

    Result result = new RelToSqlConverter(dialect).visitRoot(node);

    String sqlString = result
        .asSelect()
        .toSqlString(dialect)
        .getSql();

where "sqlString" would then become something like

SELECT `a` - `b` FROM (select a, b from foobar) AS `$f1`

(note; I could of course parse the SELECT statement but I'm not 100%
convinced all the possible SQL select statements would be parseable by
Calcite, so when they're not I want to use above approach to treat them
basically as black-box subqueries)

Thanks,
-Heiko

Reply via email to