But I'd like to know where in the code is this compilation / conversion from SQL to MAL done.

Check out the sources for the SQL frontend:
http://monetdb.cwi.nl/downloads/sources/Nov2009-SP1/MonetDB-SQL-2.34.2.tar.gz

It's actually (at least a high level) pretty easy to understand because it looks a lot like a traditional compiler [tho targetting MAL instead of say, bytecode] which for us Ocaml guys is bread-and-butter stuff ;-) Of course it's not quite that straight-forward tho because it's tightly coupled to the SQL runtime which in turn has to integrate to some extent with the underlying MAL interpreter and BAT stuff. But I digress...
 
Sorry, I'm quite new to MonetDB and still having a hard time with the documentation. What is this "explain" thing I should be doing?

In mclient you can do explains on queries, e.g. "explain select * from foo" to see the generated MAL. Of course that's probably only useful if you're planning on doing something at the MAL level.
 
Rewriting an SQL -> MAL translation is not my goal. Reusing an existing one would be one my goals.

Well, In that case I'm a bit unclear how this is much different than just feeding a SQL string through MAPI, just as you would e.g. to Oracle through OCI, etc. But in any case, best of luck.