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

JEXL. Expression evaluation on query results #4579

Open
fgalan opened this issue Jun 10, 2024 · 1 comment
Open

JEXL. Expression evaluation on query results #4579

fgalan opened this issue Jun 10, 2024 · 1 comment
Labels

Comments

@fgalan
Copy link
Member

fgalan commented Jun 10, 2024

Is your feature request related to a problem / use case? Please describe.

Use JEXL in queries so an expression can be evaluated on the query results to define virtual attributes.

Describe the solution you'd like

Let's consider an operation like this:

POST /v2/op/query

{
  "entities": [
    {
      "idPattern": ".*",
      "type": "Sensor"
    }
  ],
  "attrs": [
    "temperature"
  ],
  "virtualAttrs": {
      "tempRatio": {
        "value": "${temperature/100}",
        "type": "Number"
      }
  }
}

So assuming we have the following entities:

  • Sensor01 / Sensor, temperature=20
  • Sensor02 / Sensor, temperature=40

The response to that operation is:

  • Sensor01 / Sensor, temperature=20, tempRatio=0.02
  • Sensor02 / Sensor, temperature=40, tempRatio=0.04

Describe alternatives you've considered

Alternative syntax:

  "virtualAttrs": {
      "tempRatio": {
        "value": "temperature/100",
        "type": "Number"
      }
  }

Pros: simplified sintax avoiding ${...}
Const: lack of homogenity compared with httpCustom.ngsi in subscriptions

We have REST-style query ops (GET /v2/entities or GET /v2/entities/{id}) but it would be more complicated defining virtualAttrs on them (they don't use payload in the request).

Describe why you need this feature

  • To approach a new use case.
  • To improve or simplify an scenario.
@mapedraza
Copy link
Collaborator

Probably related:
#3815

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants