Skip to Content
2
Mar 14, 2021 at 06:31 PM

Support for $apply as an Expand Option

334 Views

Hello CAP Team,

the OData V4 specification defines in 3.17 Evaluating $apply as an Expand Option. I've tried this in the project gregorwolf/sap-support-message-reporting with a REST Client request:

GET http://localhost:4004/reporting/MessageHeaderSet
    ?$top=2
    &$expand=to_MessageAlogSet($apply=groupby((Pointer),aggregate(numberOfLogs with sum as TotalNumberOfLogs)))

But this fails with:

[odata] - {
  id: '1144030',
  level: 'WARNING',
  timestamp: 1615743169082,
  message: 'Allowed query option expected',
  stack: 'UriSyntaxError: Allowed query option expected\n' +
    '    at ExpandParser._parseOptions (/Users/gwolf/Documents/projects/cap/sap-support-message-reporting/node_modules/@sap/cds-runtime/lib/cds-services/adapter/odata-v4/okra/odata-commons/uri/ExpandParser.js:354:17)\n' +
    '    at ExpandParser._parseItem (/Users/gwolf/Documents/projects/cap/sap-support-message-reporting/node_modules/@sap/cds-runtime/lib/cds-services/adapter/odata-v4/okra/odata-commons/uri/ExpandParser.js:154:14)\n' +
    '    at ExpandParser.parse (/Users/gwolf/Documents/projects/cap/sap-support-message-reporting/node_modules/@sap/cds-runtime/lib/cds-services/adapter/odata-v4/okra/odata-commons/uri/ExpandParser.js:55:31)\n' +
    '    at /Users/gwolf/Documents/projects/cap/sap-support-message-reporting/node_modules/@sap/cds-runtime/lib/cds-services/adapter/odata-v4/okra/odata-commons/uri/UriParser.js:97:46\n' +
    '    at UriParser.parseQueryOptions (/Users/gwolf/Documents/projects/cap/sap-support-message-reporting/node_modules/@sap/cds-runtime/lib/cds-services/adapter/odata-v4/okra/odata-commons/uri/UriParser.js:199:13)\n' +
    '    at QueryOptionsParserCommand.execute (/Users/gwolf/Documents/projects/cap/sap-support-message-reporting/node_modules/@sap/cds-runtime/lib/cds-services/adapter/odata-v4/okra/odata-server/invocation/QueryOptionsParserCommand.js:38:23)\n' +
    '    at CommandExecutor._execute (/Users/gwolf/Documents/projects/cap/sap-support-message-reporting/node_modules/@sap/cds-runtime/lib/cds-services/adapter/odata-v4/okra/odata-server/invocation/CommandExecutor.js:74:17)\n' +
    '    at /Users/gwolf/Documents/projects/cap/sap-support-message-reporting/node_modules/@sap/cds-runtime/lib/cds-services/adapter/odata-v4/okra/odata-server/invocation/CommandExecutor.js:84:18\n' +
    '    at QueryOptionsValidationCommand.execute (/Users/gwolf/Documents/projects/cap/sap-support-message-reporting/node_modules/@sap/cds-runtime/lib/cds-services/adapter/odata-v4/okra/odata-server/invocation/QueryOptionsValidationCommand.js:53:7)\n' +
    '    at CommandExecutor._execute (/Users/gwolf/Documents/projects/cap/sap-support-message-reporting/node_modules/@sap/cds-runtime/lib/cds-services/adapter/odata-v4/okra/odata-server/invocation/CommandExecutor.js:74:17)',
  name: 'UriSyntaxError'
}

Would be great if support for $apply as an Expand Option can be added to CAP.

Best regards
Gregor