HPE's Vertica database has a proprietary extension used for generating 
timeseries data. I am trying to figure out how to invoke it from Sequel 
with minimal hullabaloo.

Here's an example of the kind of query I'm trying to build:

SELECT slice_time,
       round(ts_last_value(a_column IGNORE NULLS, 'linear')) AS a_col
FROM(
  select occurred_at,
         a_column
  FROM a_table
  WHERE something = 'something else'
) subq -- this is not used, but the parser requires a name here
TIMESERIES slice_time AS '1 second' OVER(ORDER BY occurred_at)

I can build the subquery with:

subquery = DB.from(:a_table).select(:occurred_at, 
:a_column).where(something: 'something_else')

I can then compose it into the outer query with 

DB.from(subquery).select { |o| [o.slice_time, 
o.round(o.ts_last_value(Sequel.lit("a_column IGNORE NULLS"), 
'linear')).as(:a_col)] }

but I can't figure out how to add the TIMESERIES clause to the query. I 
don't mind dropping into Sequel.lit if required (as you can see), but I 
need to get a dataset back, since this query will itself be included into 
another query as a subquery. Any suggestions are greatly appreciated.

BTW, if there's a better way to do the round(ts_last_value(...)) bit, I'm 
not super-thrilled with how that looks (it works fine, though).

-=Eric

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.

Reply via email to