-
What Grafana version and what operating system are you using?
Grafana cloud
-
What are you trying to achieve?
I’d like to apply an aggregation on a set of column names that is the result of a variable query
-
How are you trying to achieve it?
*Here is the query I’m working with. The desired result is for to have: max(signal1), max(signal2), … *
select
window.start,
max(${generic_signal:csv})
from raw.${generic_table}
where $__timeFilter(kafka__timestamp)
group by window(kafka__timestamp, '$__interval_long')
- What happened?
This fails as expected
Welcome @jhermiz
What do you see when you click on Query Inspector?
This is what the query inspector shows:
select
window.start,
max(timestamp_year,timestamp_month)
from raw.fieldops_form_signals_enclosure
where kafka__timestamp >= '2024-07-12T19:32:02Z' AND kafka__timestamp <= '2024-07-12T22:28:28Z'
group by window(kafka__timestamp, '1 SECOND')
I’d like to have the query return:
select
window.start,
max(timestamp_year), max(timestamp_month)
from raw.fieldops_form_signals_enclosure
where kafka__timestamp >= '2024-07-12T19:32:02Z' AND kafka__timestamp <= '2024-07-12T22:28:28Z'
group by window(kafka__timestamp, '1 SECOND')
you cannot do that with variable interpolation. what is your datasource?
Darn.
Datasource is the databricks plugin
can one do dynamic query with this databricks plugin?
so you build sqlStr based on selected variable?
DECLARE sqlStr = 'SELECT SUM(c1) FROM VALUES(?), (?) AS t(c1)';
> DECLARE arg1 = 5;
> DECLARE arg2 = 6;
> EXECUTE IMMEDIATE sqlStr USING arg1, arg2;
11