Search code examples
influxdbinfluxql

InfluxQL and missing length function


I must be missing something really simple and obvious but some basic InfluxQL string functions are not working for me. Trying to execute this query:

SELECT length(state::string) FROM "autogen"."state" WHERE entity_id::tag='klimatyzator_gabinet'

gives me:

InfluxDB Error: undefined function length()

while this works:

SELECT (state::string) FROM "autogen"."state" WHERE entity_id::tag='klimatyzator_gabinet'

I assume length should exist based on https://docs.influxdata.com/influxdb/cloud-serverless/reference/sql/functions/string/#length

Some more info about my setup: this is Home Assistant with InfluxDB and Grafana addons. Any idea what's going on here?


Solution

  • You are trying to use doc for InfluxDB Cloud Serverless

    InfluxDB Cloud Serverless powered by the IOx storage engine, which offers different functionality than InfluxDB Cloud powered by the TSM storage engine.

    But you are using InfluxDB v1.8, so you have to use different doc https://docs.influxdata.com/influxdb/v1/ - this version doesn't have length function, so error undefined function length() is correct.