Detecting master node vs worker in UDF for distributed queries

How do I control which portions of gsql get executed on master (driver) node vs worker nodes in distributed mode query? I call UDF from gsql and need to know in UDF whether I am being called on each worker or driver (master).

Others may feel differently, but I feel its a bit dangerous to try to build some type of dependency on the master vs worker nodes, or to try to turn a distributed query into an MPI or parallel processing app with different tasks. Can you give an example of what you are trying to do?