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

List projection if not all items have the given key #624

Closed
McAlm opened this issue Apr 25, 2023 · 3 comments
Closed

List projection if not all items have the given key #624

McAlm opened this issue Apr 25, 2023 · 3 comments

Comments

@McAlm
Copy link

McAlm commented Apr 25, 2023

Is your feature request related to a problem? Please describe.
We have a context like this:

[{"QUESTIONARE":"SCHADEN.SACH"},
{"ROLLE":"VN"},
{"SCHILDERUNG":"bla."},
{"ROLLE2":"GES"},
{"SCHILDERUNG2":"blubber."},
{"ROLLE3":"VN"},
{"SCHILDERUNG3":"Palim."},
{"WASGANZANDERES":"blau"},
{"ANZAHL_KAPUTTE_STUEHLE":5}]

Filtering for QUESTIONARE works fine:

[{"QUESTIONARE":"SCHADEN.SACH"},
{"ROLLE":"VN"},
{"SCHILDERUNG":"bla."},
{"ROLLE2":"GES"},
{"SCHILDERUNG2":"blubber."},
{"ROLLE3":"VN"},
{"SCHILDERUNG3":"Palim."},
{"WASGANZANDERES":"blau"},
{"ANZAHL_KAPUTTE_STUEHLE":5}].QUESTIONARE[1]

But for another key (e.g. WASGANZANDERES) it fails. Reason for that being the fact that the keys are different in all given contexts.

Describe the solution you'd like
The filter should work also on lists of contents with different keys.

If a context doesn't have the key then the list contains null for this context.

For the example, it should return:

// expression
[{"QUESTIONARE":"SCHADEN.SACH"},
{"ROLLE":"VN"},
{"SCHILDERUNG":"bla."},
{"ROLLE2":"GES"},
{"SCHILDERUNG2":"blubber."},
{"ROLLE3":"VN"},
{"SCHILDERUNG3":"Palim."},
{"WASGANZANDERES":"blau"},
{"ANZAHL_KAPUTTE_STUEHLE":5}].WASGANZANDERES

// result
[null, null, null, null, null, null, null, "blue", null] 

EDIT: updated the expected behavior based on the comment.

Related issues

  • Camunda Autormation Platform 7:
  • Zeebe broker:
@saig0 saig0 changed the title Projection filter with different context keys List projection if not all items have the given key May 12, 2023
@saig0
Copy link
Member

saig0 commented May 12, 2023

@McAlm thank you for reporting. 👍

Here is a simple example that demonstrates the issue:

[{x: 1}, {y: 2}].x

The problem

Not all contexts of the list have a key x.

Actual behavior

It returns a list that contains an error. 🙈 If the expression access the second item, the evaluation fails with an error.

image

Expected behavior

It returns a list that contains null if a context doesn't have this key.

[{x: 1}, {y: 2}].x
// should return:
// [1, null]

The expected behavior was discussed in the DMN TCK here.

@saig0
Copy link
Member

saig0 commented May 12, 2023

@McAlm I updated the expected behavior in the description to align with the discussion in the DMN TCK.

It might not align with your expectations. The resulting list would return null values if the context doesn't contain the key.

If you want to access the first item that is not null, you would need to filter the list before.

For example:

my_list.WASGANZANDERES[item != null][1]

Does this work for you?

@saig0 saig0 removed their assignment May 15, 2023
@saig0
Copy link
Member

saig0 commented Jul 28, 2023

Closing this issue in favor of #674. This behavior is covered by the referenced issue.

@saig0 saig0 closed this as completed Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants