timescaledb 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f5cb8809c9bfe578eca1fc5fd3e5d6f93a3ff7eaa9a82f6f343d6258aa591817
4
- data.tar.gz: 790728e08291b9df8539e08c37639bf81e8669df4e9321bc494cb27b25a21e81
3
+ metadata.gz: 06f324ce8793264ad6acb6a0f0f8f107511be08ecf2952e2fab285aeac366d35
4
+ data.tar.gz: d95da2805b53dafd174bb83fce7cf29cc2f13b5e8543bfa144d424e679aba701
5
5
  SHA512:
6
- metadata.gz: 61deae5c4a9884e56595771fbbd5de843bc4b06b395bd119495193c5de5a9eb66087453d749d940223e79bfccd5703def5c829f9737385ebd414460782ef5340
7
- data.tar.gz: fbd19b66f8d35af8995c25335bd001b92218acf30032533bd5972dff1bfed76105053c99c680ae705d67b6c87c8149c7426daa49de4913a58cc8d2b62327e442
6
+ metadata.gz: 14ce31badc6ae1eae1f51161a806354fcaea6b2d39197498766b4cefa2022565410f7fc745adfbaf0d51b68d67454460f3aabab2a94444dd377a93193d0465b2
7
+ data.tar.gz: 573dd6b5ae3bcfa0948176a86561c080a860d72634e1800b750554a694e17a17890a31492e2702b38ced8444b5725586bfcca6cb23109c968748edeb509bcf12
@@ -0,0 +1,72 @@
1
+ name: CI
2
+
3
+ on:
4
+ push:
5
+ pull_request:
6
+ workflow_dispatch:
7
+ # schedule:
8
+ # - cron: '42 5 * * *'
9
+
10
+ jobs:
11
+ test-in-container:
12
+ strategy:
13
+ fail-fast: false
14
+ matrix:
15
+ ruby: [ '3.1.2' ]
16
+ database:
17
+ - 'pg14.6-ts2.9.0-patroni-static-primary-latest'
18
+ - 'pg13.9-ts2.9-latest'
19
+
20
+ services:
21
+ database:
22
+ image: timescale/timescaledb-ha:${{matrix.database}}
23
+ env:
24
+ POSTGRES_USER: username
25
+ POSTGRES_PASSWORD: secret
26
+ POSTGRES_DB: testdb
27
+ options: >-
28
+ --health-cmd pg_isready
29
+ --health-interval 10s
30
+ --health-timeout 5s
31
+ --health-retries 5
32
+
33
+
34
+ runs-on: ubuntu-latest
35
+ name: OS Ruby ${{matrix.ruby}} database ${{matrix.database}}
36
+ container: ruby:${{matrix.ruby}}
37
+
38
+ steps:
39
+ - uses: actions/checkout@v3
40
+
41
+ - name: Show Ruby Version
42
+ run: |
43
+ ruby -v
44
+
45
+ - name: Install psql
46
+ run: |
47
+ apt-get update
48
+ apt-get install -y postgresql-client
49
+
50
+ - name: Show PostgreSQL version and time
51
+ env:
52
+ PGPASSWORD: secret
53
+ run: |
54
+ echo "SELECT version()" | psql -h database -U username testdb
55
+ echo "SELECT CURRENT_TIME" | psql -h database -U username testdb
56
+
57
+ - name: Setup
58
+ run: |
59
+ ./bin/setup
60
+
61
+ - name: run tsdb
62
+ run: ./bin/tsdb postgres://username:secret@database:5432/testdb --stats
63
+
64
+ - name: Test setup
65
+ run: |
66
+ echo PG_URI_TEST="postgres://username:secret@database:5432/testdb" > .env
67
+ cat .env
68
+ bundle exec rake test:setup
69
+
70
+ - name: Test
71
+ run: bundle exec rake
72
+
data/.travis.yml CHANGED
@@ -2,8 +2,8 @@
2
2
  language: ruby
3
3
  cache: bundler
4
4
  rvm:
5
- - 2.7.1
6
- before_install: gem install bundler -v 2.1.4
5
+ - 3.1.2
6
+ before_install: gem install bundler
7
7
  gemfile:
8
8
  - Gemfile
9
9
  - Gemfile.scenic
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- timescaledb (0.2.5)
4
+ timescaledb (0.2.6)
5
5
  activerecord
6
6
  activesupport
7
7
  pg (~> 1.2)
@@ -33,7 +33,7 @@ GEM
33
33
  concurrent-ruby (~> 1.0)
34
34
  method_source (1.0.0)
35
35
  minitest (5.14.4)
36
- pg (1.4.4)
36
+ pg (1.4.5)
37
37
  pry (0.14.1)
38
38
  coderay (~> 1.1)
39
39
  method_source (~> 1.0)
data/Gemfile.scenic.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- timescaledb (0.2.3)
4
+ timescaledb (0.2.6)
5
5
  activerecord
6
6
  activesupport
7
7
  pg (~> 1.2)
@@ -56,9 +56,7 @@ GEM
56
56
  nokogiri (1.12.5)
57
57
  mini_portile2 (~> 2.6.1)
58
58
  racc (~> 1.4)
59
- nokogiri (1.12.5-x86_64-darwin)
60
- racc (~> 1.4)
61
- pg (1.4.4)
59
+ pg (1.4.5)
62
60
  pry (0.14.1)
63
61
  coderay (~> 1.1)
64
62
  method_source (~> 1.0)
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Timescaledb
4
+ class ApplicationRecord < ::ActiveRecord::Base
5
+ self.abstract_class = true
6
+ end
7
+ end
@@ -1,5 +1,5 @@
1
1
  module Timescaledb
2
- class Chunk < ActiveRecord::Base
2
+ class Chunk < ::Timescaledb::ApplicationRecord
3
3
  self.table_name = "timescaledb_information.chunks"
4
4
  self.primary_key = "chunk_name"
5
5
 
@@ -1,5 +1,5 @@
1
1
  module Timescaledb
2
- class CompressionSetting < ActiveRecord::Base
2
+ class CompressionSetting < ::Timescaledb::ApplicationRecord
3
3
  self.table_name = "timescaledb_information.compression_settings"
4
4
  belongs_to :hypertable, foreign_key: :hypertable_name
5
5
  end
@@ -1,5 +1,5 @@
1
1
  module Timescaledb
2
- class ContinuousAggregate < ActiveRecord::Base
2
+ class ContinuousAggregate < ::Timescaledb::ApplicationRecord
3
3
  self.table_name = "timescaledb_information.continuous_aggregates"
4
4
  self.primary_key = 'materialization_hypertable_name'
5
5
 
@@ -1,5 +1,5 @@
1
1
  module Timescaledb
2
- class Dimension < ActiveRecord::Base
2
+ class Dimension < ::Timescaledb::ApplicationRecord
3
3
  self.table_name = "timescaledb_information.dimensions"
4
4
  # attribute :time_interval, :interval
5
5
  end
@@ -1,5 +1,5 @@
1
1
  module Timescaledb
2
- class Hypertable < ActiveRecord::Base
2
+ class Hypertable < ::Timescaledb::ApplicationRecord
3
3
  self.table_name = "timescaledb_information.hypertables"
4
4
  self.primary_key = "hypertable_name"
5
5
 
@@ -1,5 +1,5 @@
1
1
  module Timescaledb
2
- class Job < ActiveRecord::Base
2
+ class Job < ::Timescaledb::ApplicationRecord
3
3
  self.table_name = "timescaledb_information.jobs"
4
4
  self.primary_key = "job_id"
5
5
 
@@ -1,5 +1,5 @@
1
1
  module Timescaledb
2
- class JobStat < ActiveRecord::Base
2
+ class JobStat < ::Timescaledb::ApplicationRecord
3
3
  self.table_name = "timescaledb_information.job_stats"
4
4
 
5
5
  belongs_to :job
@@ -68,5 +68,5 @@ module Timescaledb
68
68
  end
69
69
 
70
70
 
71
+ Scenic::Adapters::Postgres.include(Timescaledb::Scenic::Extension)
71
72
  ActiveRecord::ConnectionAdapters::AbstractAdapter.include(Timescaledb::Scenic::MigrationHelpers)
72
- Scenic::Adapters::Postgres.prepend(Timescaledb::Scenic::Extension)
@@ -5,19 +5,12 @@ module Timescaledb
5
5
  module SchemaDumper
6
6
  def tables(stream)
7
7
  super # This will call #table for each table in the database
8
- views(stream) unless defined?(Scenic) # Don't call this twice if we're using Scenic
9
8
 
10
9
  return unless Timescaledb::Hypertable.table_exists?
11
10
 
12
11
  timescale_hypertables(stream)
13
12
  timescale_retention_policies(stream)
14
- end
15
-
16
- def views(stream)
17
- return unless Timescaledb::ContinuousAggregates.table_exists?
18
-
19
13
  timescale_continuous_aggregates(stream) # Define these before any Scenic views that might use them
20
- super if defined?(super)
21
14
  end
22
15
 
23
16
  def timescale_hypertables(stream)
@@ -61,17 +54,42 @@ module Timescaledb
61
54
 
62
55
  def timescale_compression_settings_for(hypertable)
63
56
  compression_settings = hypertable.compression_settings.each_with_object({}) do |setting, compression_settings|
64
- compression_settings[:compress_segmentby] = setting.attname if setting.segmentby_column_index
57
+ # It's possible to configure compression so that it is segmented by multiple
58
+ # columns. To make sure we capture that correctly, we'll treat them as an array.
59
+ compression_settings[:compress_segmentby] ||= []
60
+ compression_settings[:compress_orderby] ||= []
61
+
62
+ compression_settings[:compress_segmentby] << setting.attname if setting.segmentby_column_index
65
63
 
66
64
  if setting.orderby_column_index
67
- direction = setting.orderby_asc ? "ASC" : "DESC"
68
- compression_settings[:compress_orderby] = "#{setting.attname} #{direction}"
65
+ if setting.orderby_asc
66
+ direction = "ASC"
67
+ if setting.orderby_nullsfirst
68
+ direction += " NULLS FIRST"
69
+ end
70
+ else
71
+ direction = "DESC"
72
+ if !setting.orderby_nullsfirst
73
+ direction += " NULLS LAST"
74
+ end
75
+ end
76
+
77
+ compression_settings[:compress_orderby] << "#{setting.attname} #{direction}"
69
78
  end
70
79
  end
71
80
 
72
81
  hypertable.jobs.compression.each do |job|
73
82
  compression_settings[:compression_interval] = job.config["compress_after"]
74
83
  end
84
+
85
+ # Pack the compression setting arrays into a comma-separated string instead.
86
+ if compression_settings[:compress_segmentby]
87
+ compression_settings[:compress_segmentby] = compression_settings[:compress_segmentby].join(", ")
88
+ end
89
+ if compression_settings[:compress_orderby]
90
+ compression_settings[:compress_orderby] = compression_settings[:compress_orderby].join(", ")
91
+ end
92
+
75
93
  compression_settings
76
94
  end
77
95
 
@@ -92,6 +110,8 @@ module Timescaledb
92
110
  end
93
111
 
94
112
  def timescale_continuous_aggregates(stream)
113
+ return unless Timescaledb::ContinuousAggregates.table_exists?
114
+
95
115
  Timescaledb::ContinuousAggregates.all.each do |aggregate|
96
116
  opts = if (refresh_policy = aggregate.jobs.refresh_continuous_aggregate.first)
97
117
  interval = timescale_interval(refresh_policy.schedule_interval)
@@ -1,3 +1,3 @@
1
1
  module Timescaledb
2
- VERSION = '0.2.5'
2
+ VERSION = '0.2.6'
3
3
  end
data/lib/timescaledb.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'active_record'
2
2
 
3
+ require_relative 'timescaledb/application_record'
3
4
  require_relative 'timescaledb/acts_as_hypertable'
4
5
  require_relative 'timescaledb/acts_as_hypertable/core'
5
6
  require_relative 'timescaledb/toolkit'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: timescaledb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jônatas Davi Paganini
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-19 00:00:00.000000000 Z
11
+ date: 2023-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pg
@@ -144,6 +144,7 @@ executables:
144
144
  extensions: []
145
145
  extra_rdoc_files: []
146
146
  files:
147
+ - ".github/workflows/ci.yml"
147
148
  - ".gitignore"
148
149
  - ".rspec"
149
150
  - ".ruby-version"
@@ -240,6 +241,7 @@ files:
240
241
  - lib/timescaledb/acts_as_hypertable.rb
241
242
  - lib/timescaledb/acts_as_hypertable/core.rb
242
243
  - lib/timescaledb/acts_as_time_vector.rb
244
+ - lib/timescaledb/application_record.rb
243
245
  - lib/timescaledb/chunk.rb
244
246
  - lib/timescaledb/compression_settings.rb
245
247
  - lib/timescaledb/continuous_aggregates.rb