3 ms·
Good points, thank you. And take this as respectful musing not arguing... > it would be a lot more complex I don't use redash, but isn't the 'complexity' just
by sago 9y ago
Good points, thank you. And take this as respectful musing not arguing...
> it would be a lot more complex
I don't use redash, but isn't the 'complexity' just the boiler plate literal text? The query is rather simple.
'<svg ...etc... d="L' +
SELECT ROW_NUMBER() OVER (ORDER BY Date DESC), Value FROM Data GROUP BY Date +
'" ...etc... /></svg>'
No more complex than the google chart call, surely?
- cldellow 9y agoYeah, "a lot more complex" is pretty sloppy. "A lot more annoying", perhaps. It's doable. The complexity comes when you aggregate tuples of (row number, value) instead of just aggregating value. To fit in the redash model, you need a single expression that returns a string of HTML. So the example you cite isn't quite there, as I don't think it's valid SQL (or is it? I'm mainly familiar with Postgres--perhaps that example is valid in some other DB?) So you need something like: SELECT 'preamble' || (SELECT string_agg(ROW_NUMBER() OVER (ORDER BY Date Desc), ...) || 'postamble' Except aggregate functions can't contain window functions, so something like: WITH windowed as (SELECT ROW_NUMBER(), ...) SELECT 'preamble' || (SELECT string_agg(row_number || ',' value, ',') FROM windowed) || 'postamble' is needed. Which isn't a big deal, but since you don't really care about the row number, it's nice to be able to skip the CTE and just directly smash the values into a string_agg. It's a minor thing, but I'm lazy.