bloomberg/blazingmq

Subscriptions expressions: Ability to check whether a property exists

mlongob opened this issue · 1 comments

Is there an existing proposal for this?

  • I have searched the existing proposals

Is your feature request related to a problem?

The expression language currently does not provide a clear way to check for the existence of a property.

Let's assume I have a queue with two types of messages.

Messages of type A have the following properties:

radius = 34
color = "blue"

Messages of type B have the following properties:

height: 53
width: 100
color = "red"

If I want to filter for messages that contain a radius field in a subscription, I can currently recur to the following workaround expressions:

radius == radius
radius >= 0 || radius < 0

however my intent to check for existence is not clear.

Describe the solution you'd like

I would love if the expression language allowed me to check for existence of fields explicitly. This can be done by either checking if a field:

!= NULL

for the existence check.

and

== NULL

for the missing property check.

Alternatively an operator for exists() can be introduced. This alternative would require a unary negation operator.

Alternatives you considered

No response

jll63 commented

I prefer exists, because we might introduce new types for which NULL is a possible value. We may want to distinguish between the existence of a property, and its value being NULL. For example, in Python, these are different: { "question": None, answer: 42 } and { answer: 42 }.