I need this because it is a customer requirement. The underlying tables the api will query are dynamically created, they are period/content partitioned and distributed across multiple servers and database types... not just postgres. The api/function will determine what servers/databases/tables (some of them are foreign tables) to query based on the parameters passed to the api. The customer wants to use their current reporting tool that does not support function selects.
I am open to suggestions here.
I understand this type of method will restrict the type predicates that can be written at the top level of the query... But that is ok, we can work with the restrictions.
I also understand I may have overs simplified the question. So I hope I did not waste your time