As far as I can see, you don’t set dataGrid.setAggregatable(true); in your code.
Also, I want to inform you that common aggregation types (SUM, AVG etc.) are supported only if the meta property path is specified in the aggregation info. Otherwise, you need to implement a custom aggregation strategy.
This is expected behavior because the metaPropertyPath in a column only appears if it is specified when the column is created. See methods overloading:
Meta property path is calculated automatically when creating the column declaratively using XML markup, you can find an loader code here: io.jmix.flowui.xml.layout.loader.component.AbstractGridLoader#loadColumn
As I wrote earlier, if you don’t have a meta property path for a column, you can try using a custom aggregation strategy.
You can also provide a test project so that we can understand your issue in more detail.