Strictly speaking, this function compiles a physical plan to JSON.  The logical plan is passed along for debugging purposes.