pub fn build_query(plan: &ActionPlan, role: Option<&str>) -> Result<MainQuery>
Build SQL from an action plan.