m-kovalsky / Tabular

Useful code for tabular modeling and automation.
MIT License
156 stars 60 forks source link

Creating Agg Table with M-Partition instead Legacy #18

Closed aven1912 closed 1 year ago

aven1912 commented 1 year ago

Hello Sir, In this snippet below, it creates a Legacy-Partition for the AggTable by default. I was wondering if it is possible at all to create a M-Partition instead. If so, I would greatly appreciate if you could point me to some documentation to do that. Thanks in advance.

foreach(var p in Model.Tables[tableName].Partitions.ToList()) { var aggPartitionName = p.Name.Replace(tableName,aggTableName); var aggQuery = p.Query.Replace(tableName,aggTableName); var pName = Model.Tables[aggTableName].AddPartition(aggPartitionName); // Update Data Source pName.DataSource = Model.DataSources[dataSource]; // Update Query pName.Query = aggQuery; } // Remove default partition Model.Tables[aggTableName].Partitions[aggTableName].Delete(); }

aven1912 commented 1 year ago

@m-kovalsky Just to add little bit more context. When I execute the agg table script by selecting a detail table with legacy partition, it works as expected. When I execute the agg table script by selecting a detail table with m-partition, it creates a legacy partition for the agg table. And it hardcodes the m-query statement from the detail table inside legacy partition query (which understandably fails during partition refresh).

MK_Troubleshoot

Thanks Aswanth

m-kovalsky commented 1 year ago

This tool is really geared towards legacy partitions. However, i've updated the AutoAggs script to create M-partitions in the agg table for corresponding M-partitions in the detail table.