-
-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathXMLA - Partitions - Process (Unprocessed).ps1
69 lines (54 loc) · 1.91 KB
/
XMLA - Partitions - Process (Unprocessed).ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
param (
$serverName = "powerbi://api.powerbi.com/v1.0/myorg/Session%20-%20PBI%20on%20Steroids"
, $databaseName = "WWI - Sales (Partitioned)"
, $maxParallelism = 2
, $batchPartitionCount = 5
)
$currentPath = (Split-Path $MyInvocation.MyCommand.Definition -Parent)
Import-Module "$currentPath\TOMHelper.psm1" -Force
$tables = Get-ASTable -serverName $serverName -databaseName $databaseName -includePartitions
$sw = [system.diagnostics.stopwatch]::StartNew()
foreach($table in $tables)
{
try
{
Write-Host "Processing table: $($table.Name)"
$unprocessedPartitions = @($table.Partitions |? State -ne "Ready")
if ($unprocessedPartitions.Count -gt 0)
{
$batchSkip = 0
$processOrders = @()
do
{
$batchPartitions = @($unprocessedPartitions | select -First $batchPartitionCount -Skip $batchSkip)
if ($batchPartitions.Count -gt 0)
{
$processOrders += @{
Server = $serverName
;
DatabaseName = $databaseName
;
TableName = $table.Name
;
Partitions = @($batchPartitions.Name)
;
Group = "Group $batchSkip"
}
$batchSkip += $batchPartitions.Count
}
}
while($batchPartitions)
$results = Invoke-ASTableProcess -tables $processOrders -maxParallelism $maxParallelism
}
else
{
Write-Host "Table fully processed"
}
}
catch
{
Write-Error -Message "Error on table '$($table.Name)'; Error: '$($_.Exception.Message)'" -Exception $_.Exception -ErrorAction Continue
}
}
$sw.Stop()
Write-Host "Time: $($sw.Elapsed.TotalSeconds)s"