Hello @yolsever,
Welcome to the community!
You should be able to get help from your Plotly Services rep on this.
I havent messed with things like aggregations and pivots, but the flow should still be the same.
AG Grid loads up, sends a request to the datasource, and then gets the response.
Here is documentation for it in JS:
These flows will be similar to how it works in JS, basically you need to parse the request from AG Grid and adjust your SQL query and then give back the desired result.
Here is an example of the request flow and then Python picks up the mantle: