jonatas / timescaledb

The timescaledb gem. Pack of helpers to work with TimescaleDB extension in Ruby.
https://jonatas.github.io/timescaledb/
MIT License
61 stars 18 forks source link

Allow compression to be segmented across multiple columns #38

Closed stevehill1981 closed 1 year ago

stevehill1981 commented 1 year ago

TimescaleDB allows compressed data to be segmented by multiple columns. Our previous implementation only captured the first column that was specified for a given table, which would result in different behaviour when restoring the schema definition.

The same is also true of ordering the compressed data - again, multiple columns can be specified.

This change captures the multiple column specifications correctly, and adds them to the schema.rb as expected.

jonatas commented 1 year ago

Very good @stevehill1981 ! thanks for the PR. Can you add some specs for it?

stevehill1981 commented 1 year ago

Sure thing - probably over the Christmas break, now! Have a great Christmas (if you celebrate)

jonatas commented 1 year ago

Awesome! Thank you, @stevehill1981!

Enjoy the holiday with your beloved ones! I'm heading to the beach for 🎅! 🚴‍♂️ 🏄‍♂️ 🥾 🎉

I probably will be reviewing it carefully in two weeks!

jonatas commented 1 year ago

Also, please rebase and push again because now we have CI 🎉 🚀

stevehill1981 commented 1 year ago

I have added tests! I'm glad I did, because my logic for the compress_orderby extraction turned out to be slightly off.

It now follows the behaviour of ORDER BY from Postgres:

  1. ORDER BY <column> ASC defaults to NULLS LAST unless otherwise specified
  2. ORDER BY <column> DESC defaults to NULLS FIRST unless otherwise specified

If you want to see more tests around compress_segmentby, let me know and I'll add some in.