@simon Putting my UX hat on, why does it need a button at all? The ideal interaction could be just to do it live?

Or something like Show/Preview/Generate SQL/Query.