How to Handle Nonexistent Tags in InfluxDB Cloud v3 with SQL and Grafana?

Hi everyone,

I’m facing an issue while migrating from InfluxQL to InfluxDB SQL (Cloud v3). Here’s the situation:

In my database, I have a tag mytag that might not exist yet because no data has been inserted with this tag. In the past, with InfluxQL, I could run queries like the following without any issues, even if the tag didn’t exist:

SELECT * FROM my_table WHERE mytag = 'myvalue'

However, in InfluxDB SQL, referencing a non-existent column/tag raises an exception, making it impossible to create queries that conditionally reference this tag.

My Context:

  • I’m using Grafana to visualize the data.
  • I don’t want to “pollute” my data by pre-inserting a placeholder value for mytag just to make the column exist in the schema.

Is there any way to write queries in InfluxDB SQL that gracefully handle nonexistent columns/tags? Ideally, I’d like to create a Grafana dashboard that doesn’t break if the column doesn’t yet exist in the data.

I’d appreciate any insights or alternative solutions!

Thanks in advance! :blush:

Hello @Ricko,
Welcome!
Unfortunately there isn’t a way to do this with SQL. But you can query with InfluxQL with v3. If you want to migrate your existing queries directly.