0

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.

Manfred Moser
  • 29,539
  • 13
  • 92
  • 123
Michael Szczepaniak
  • 1,970
  • 26
  • 35

2 Answers2

4

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

ebyhr
  • 1,537
  • 9
  • 15
1

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.

Philipp Johannis
  • 2,718
  • 1
  • 15
  • 18
  • I currently done have access to the backend, but will check with our admin to see if I can get a look at these logs. Will mark as answer if I can get at the generated mongo query. – Michael Szczepaniak Oct 19 '20 at 20:33
  • Our admin liked your answer and we were able to get at these. They weren't as helpful as we were hoping, but that has to do with how presto does these translations. – Michael Szczepaniak Oct 30 '20 at 19:15