asmuth / clip

Create charts from the command line
https://clip-lang.org
Apache License 2.0
5.14k stars 386 forks source link

Allow expressions as first argument to TIMEWINDOW #211

Closed arvidj closed 5 years ago

arvidj commented 9 years ago

I would like to do:

SELECT
   FROM_TIMESTAMP(crdate) AS x,
   count(*) AS y,
   "circle" as pointstyle
   FROM fusers GROUP OVER TIMEWINDOW(FROM_TIMESTAMP(crdate), 3600*24); 

Currently the first argument must be a column reference. I store most my dates as unix timestamps, making this impractical. Could this feature be added, or are there any workarounds?

arvidj commented 9 years ago

I worked around this by implementing the YEAR, MONTH and DAY functions instead. I can now do:

SELECT
   FROM_TIMESTAMP(crdate) AS x,
   count(*) AS y,
   "circle" as pointstyle
   FROM fusers GROUP BY YEAR(FROM_TIMESTAMP(crdate)),  
         MONTH(FROM_TIMESTAMP(crdate)), 
         DAY(FROM_TIMESTAMP(crdate)), ; 

However, it seems like the labels on the X-axis is a bit weird. My data ranges over several years, yet I see only the time. screen shot 2014-11-28 at 11 23 31