timestored / pulseui

Real-time interactive database applications
https://www.timestored.com/pulse/
Other
55 stars 6 forks source link

Feature: Allow combining multiple time-series #62

Open ryanhamilton opened 1 year ago

ryanhamilton commented 1 year ago

user-vol On some databases combining time-series is very difficult.

e.g. I have: queryA - returns (ts timestamp, price, ..........) queryB - returns (ts timestamp, size, ...........) I want a combined result (ts, price, size, ........) Where ts is matching join, where ts only occurs in queryB append as a new row.

Proposal: Allow the user to specify multiple queries Combine the result by taking the first timestamp column in each as the join. Do NOT support more than just joining on the 1 timestamp column. Some databases support this but given how we display data I don't think it makes sense for us.

AlternativesA: Extend SQL to have MERGE(query1, query2) that we then separate in backend. Don't like it as it means in the SQL editor, we would have non-SQL.

AlternativesB: Don't support. Difficult to say now as in some databases this join just wouldn't be possible.

ryanhamilton commented 1 year ago

Workaround: Use Union Join Annoying as:

  1. Every column needs specified with nulls
  2. Order of columns must match. Also shows that we need option for "fills". Fill forward? Fill backward? Else graph contains gaps on data zoomer.
select * from (
(select ts,bid,ask,
          cast(NULL as double)  as trade_SD_TRIANGLE,
          cast(NULL as double)  as trade_SD_SIZE 
          from order 
          WHERE ts > timestamp_floor('m', now() - 10*60000000L)
UNION 
  (select ts, NULL as bid, NULL as ask,
  price AS trade_SD_TRIANGLE,
  10+10*log(1+amount) AS trade_SD_SIZE
  from  trade WHERE ts > timestamp_floor('m', now() - (10*60000000L))))) order by ts;
ryanhamilton commented 1 year ago

Future Options:

  1. Allow JS scripting
  2. Allow q scripting
  3. Allow custom annotations similar to grafana
  4. ?