mullerpeter / databricks-grafana

Grafana Databricks integration allowing direct connection to Databricks to query and visualize Databricks data in Grafana.
https://mullerpeter.github.io/databricks-grafana/
Apache License 2.0
55 stars 4 forks source link

Repeated panels show all variable values instead of one per panel #14

Closed honicky closed 1 year ago

honicky commented 1 year ago

Hi there,

This plugin is great! Thanks a lot for taking the time to develop and maintain it!

I am building a dashboard, and trying to use a repeated panel it it using a multi-select variable:

image

I have a panel with the repeat option selected:

image

You can see that the title also includes the ${table} variable.

Here is my query:

select ingestion_date, count(*) message_count
from tcc_metrics.${table:raw}
where ingestion_date >= cast('$__timeFrom' as date) 
  and ingestion_date <= cast('$__timeTo' as date) 
GROUP BY ingestion_date
ORDER BY ingestion_date ASC
LIMIT 10000

If I only select one table, the query works: image If, however, I select multiple tables, then then it interpolates ${table} with a list of all of the selected tables, rather than the specific one, like this: from tcc_metrics.${table:raw} -->from tcc_metrics.qos,connections_connection

Inspecting the query

{
  "request": {
...
          "querySettings": {
            "convertLongToWide": false,
            "fillMode": 1
          },
          "rawSqlQuery": "select ingestion_date, count(*) message_count\nfrom tcc_metrics.qos,connections_connection\nwhere ingestion_date >= cast('$__timeFrom' as date) \n  and ingestion_date <= cast('$__timeTo' as date) \nGROUP BY ingestion_date\nORDER BY ingestion_date ASC\nLIMIT 10000",
...
          "datasourceId": 1,
...
        }
      ],
...
  },
  "response": {
    "results": {
      "A": {
        "error": "Error running query: [TABLE_OR_VIEW_NOT_FOUND] org.apache.spark.sql.AnalysisException: [TABLE_OR_VIEW_NOT_FOUND] The table or view `connections_connection` cannot be found. Verify the spelling and correctness of the schema and catalog.\nIf you did not qualify the name with a schema, verify the current_schema() output, or qualify the name with the correct schema and catalog.\nTo tolerate the error on drop use DROP VIEW IF EXISTS or DROP TABLE IF EXISTS.; line 2 pos 21",
        "status": 500,
        "frames": [],
        "refId": "A"
      }
    }
  }
}

I'm wondering if the backend needs to select the correct value from the list sent over by the variable(in this case either connections_connection or qos

I'm guessing this will be easy to reproduce, but I'm happy to help reproduce it if you can figure out what is going on here.

Thanks in advance!

mullerpeter commented 1 year ago

Hey, thanks for opening the issue! Should be fixed now. Let me know if it still does not work for you.