SQL is not converted into Mongo queries directly. SQL is converted into relational algebra which is then run through Calcite's optimizer to produce a query execution plan. Part of this execution plan will include Mongo operators that query Mongo during their execution.
So the short answer is that there's no easy way get a Mongo query from SQL. Part of the issue with trying to do this is that some SQL queries will not have a direct equivalent in Mongo and will require other operations on the retrieved data. If you could explain a bit more about what you're trying to achieve, that would be helpful. -- Michael Mior mm...@apache.org 2018-03-27 18:01 GMT-04:00 Jack Gindi <jack.gi...@opengov.com>: > Hi, > > I've been exploring some of the calcite code -- in particular, the > mongo-adapter -- and I cannot seem to figure out where the translation from > a sql-like query to a mongo pipeline is actually taking place (in the mongo > adapter test code). I've tracked the untranslated sql through the > CalciteAssert code and can't figure out where the conversion is actually > happening. I can see how the relational algebra gets used to build up the > mongo pipeline, but I don't see where code that constructs the pipeline is > active in the test code. > > Following up on the above, > (1a) What would be the best way to do sql->mongo translation using existing > code? > (1b) If (1a) is not a sensible approach and the mongo-adapter > pipeline-building capability cannot be factored out, what would be the most > sensible approach to hand-rolling sql->mongo translation? > > Thanks, > > Jack >