Query step

A query step can be used to query data from the platform and produce an output Data Frame. A query step can have only one output, without any input.

Query config is identical to the API query and therefore can be either a wizata_dsapi.Request or its JSON form.

Query can be used to retrieves time-series data and can be based on template and/or properties.

Define Timeframe

Query can be defined using either:

  • fix start / end timeframe using datetime or timestamp epoch.
  • relative time based on now properties. By default, a pipeline defines now as the moment the pipeline was queued.
  • custom @variable that can be overridden by user or Trigger

📘

There is a dedicated article regarding Query functionality and usages

You can access to it by clicking here

Below is an example of a query executed using wizata_dsapi:

df = wizata_dsapi.api().query(
    template="my_example_factory_template",
    twin = "motor_1",
    datapoints = ["Bearing1","Bearing2","Bearing3","Bearing4"],
    interval=600000,
    start="now-2h",
    end="now",
    agg_method="mean",
    null="all"
    )

In the pipeline query steps:

pipeline.add_query(  #query step
    wizata_dsapi.Request(
        datapoints =["Bearing1","Bearing2","Bearing3","Bearing4"],
        start="now-1d",
        end="now",
        agg_method="mean",
        interval=60000,
        null="all"
    ),
    df_name="df"
)
{
    "id": "6d3bbdb2-373e-4c74-8c8e-7945d4cada47",
    "type": "query",
    "config": {
      "id": "6941f1f9-a53e-480f-99dd-f8623c04f095",
      "equipments_list": [
        {
          "id": null,
          "datapoints": [
            "Bearing1",
            "Bearing2",
            "Bearing3",
            "Bearing4"
          ],
          "shift": "0s"
        }
      ],
      "timeframe": {
        "start": "now-1d",
        "end": "now"
      },
      "aggregations": {
        "agg_method": "mean",
        "interval": 60000
      },
      "null": "all",
      "template": {
        "template_id": "61d63f8b-6142-43bc-bb98-ac146076601b"
      },
      "filters": {},
      "options": {}
    },
    "inputs": [],
    "outputs": [
      {
        "dataframe": "df"
      }
    ]
  }