grafana / redshift-datasource

Apache License 2.0
9 stars 11 forks source link

Add timeGroup macro without alias #293

Open thoechsmann opened 4 months ago

thoechsmann commented 4 months ago

What happened?

I am using grafana with a Amazon Redshift sql datesource.

The query SELECT $__timeGroupAlias(CURRENT_DATE, $__interval) does not work as $__timeGroupAlias seems to be unknown. (error executing query: ERROR: syntax error at or near \"$\" Position: 8)

The query SELECT $__timeGroup(CURRENT_DATE, $__interval) results in SELECT floor(extract(epoch from CURRENT_DATE)/300)*300 AS \"time\" which is not correct as according to the documentation it should not add the "time" alias.

What did you expect to happen?

Did this work before?

I have not tested in with older Grafana versions.

How do we reproduce it?

Use queries.

Is the bug inside a dashboard panel?

No response

Environment (with versions)?

Grafana: v11.2.0-73451 (a0268a9ad2) OS: Mac Browser: Brave

Grafana platform?

I use Grafana Cloud

Datasource(s)?

Amazon Redshift

iwysiu commented 3 months ago

Hi @thoechsmann ! The Redshift macro is documented here as having the AS "time" at the end. Are there other docs you we're looking at that say otherwise? We also could look into adding the macro without the alias if that would be useful.

thomas-calumma commented 2 months ago

You are right. I was looking at the MYSQL documentation. My mistake. But it is still confusing that the macros are defined differently.

And I have use cases where I would be very helpful to have the timegroup without alias. This is required whenever you want to do further calculations with the result.

iwysiu commented 2 months ago

Hi @thomas-calumma ! Thanks for getting back to us, I'll bring this up with the team next week and we'll try to get it in the backlog