Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Aggregation using -Apply does not return aggregated results #87

Open
dchosnek opened this issue Dec 21, 2022 · 1 comment
Open

Aggregation using -Apply does not return aggregated results #87

dchosnek opened this issue Dec 21, 2022 · 1 comment
Labels
bug Something isn't working

Comments

@dchosnek
Copy link

The GroupBy/Aggregate operation of the API shown below works using the API explorer (return a list of all server models found in an Intersight account and the number of servers of each model). When attempting this same operation using the PowerShell SDK, a list of objects is returned that does not contain either model names or a count of the model names.

GET /api/v1/compute/RackUnits?$apply=groupby((Model), aggregate($count as Total))

The operation does return the right number of objects, implying that "GroupBy" is working. But the contents of the objects are not useful.

To reproduce:

(Get-IntersightComputeRackUnit -Apply 'groupby((Model), aggregate($count as Total))').Results

This is one of the objects returned when running the above command in my Intersight account. Again, the command returns seven objects like this and there are seven different models in my Intersight account.

Name                       : Model
Type                       : Property
HasValues                  : True
First                      : {}
Last                       : {}
Count                      : 1
Parent                     : {Model, Total}
Root                       : {Model, Total}
Next                       : {}
Previous                   : 
Path                       : Model
LineNumber                 : 0
LinePosition               : 0
IsReadOnly                 : False
AllowNew                   : True
AllowEdit                  : True
AllowRemove                : True
SupportsChangeNotification : True
SupportsSearching          : False
SupportsSorting            : False
IsSorted                   : False
SortProperty               : 
SortDirection              : Ascending
IsFixedSize                : False
SyncRoot                   : System.Object
IsSynchronized             : False

Version used
Intersight.PowerShell 1.0.9.6484
PowerShell 7.2.4

Expected behavior
The API browser returns:

{
  "ObjectType": "mo.AggregateTransform",
  "Results": [
    {
      "Model": "UCSC-C240-M4S",
      "Total": 1
    },
    {
      "Model": "HXAF220C-M5SX",
      "Total": 12
    },
    {
      "Model": "HX220C-M4S",
      "Total": 8
    },
    {
      "Model": "HXAF220C-M4S",
      "Total": 8
    },
    {
      "Model": "UCSC-C240-M5L",
      "Total": 4
    },
    {
      "Model": "UCSC-C240-M5SX",
      "Total": 1
    },
    {
      "Model": "UCSC-C220-M4S",
      "Total": 24
    }
  ]
}

I would expect the PowerShell SDK to return something like:

Model          Total
-----          -----
UCSC-C240-M4S   1
HXAF220C-M5SX   12
HX220C-M4S      8
HXAF220C-M4S    8
UCSC-C240-M5L   4
UCSC-C240-M5SX  1
UCSC-C220-M4S   24
@Ghufz
Copy link
Collaborator

Ghufz commented Jan 9, 2023

This is bug due to the underlying properties type as object. we are working on it.
We have workaround for the same

 $test = Get-IntersightComputeRackUnit -Apply 'groupby((Model), aggregate($count as Total))' -Json
 $testResult = $test | ConvertFrom-Json
 $testResult.Results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants