How to intercept mondoDB Query from Presto Connector

284 views Asked by At

I have written a number of Presto queries that pull from mongoDB collections, but others in our project query mongo directly. These folks would like to use my queries to save them the time of having to rewrite them.

Is there a way to obtain/extract the mongoDB query language generated by Presto?

Didn't see anything in the MongoDB connector documentation that would indicate how or if this was possible.

I am aware of SQL-mongo converters out there, but Presto SQL extends normal SQL to enable things like unwrapping arrays etc. that we encounter with non-relational stores and these converts have trouble with these things in my experience.

2

There are 2 answers

2
Philipp Johannis On BEST ANSWER

I guess the easiest way is to look into Mongodb while the query is running and get it from there, for example via logging:

db.setProfilingLevel(2)
db.system.profile.find().pretty()

You may also use some GUIs like MongoVue or Robo 3T - I used MongoVue in the past to evaluate running queries.

0
ebyhr On

You can set MongoDB driver log level DEBUG in log.properties:

org.mongodb=DEBUG

However, it will print many unrelated logs (e.g. healthcheck). Filed an issue https://github.com/prestosql/presto/issues/5600