duckdb 0.7.1 → 0.8.0

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: 469588c48fb9f9d16254cd6f78f3fd4ceb1e6886e3fc859a507d635542ba50fa
4
- data.tar.gz: 1ccee32eb696806c13da87d5c8825965575575e83c45e466712a69bfa107547e
3
+ metadata.gz: 8e8040d795ad975b4472fe439aa2cfb403ad5f24f9c602bca7dbdf6103c37b65
4
+ data.tar.gz: 82cd61d78fec67f62be8ad0280305b224ae605ffd2ea453855168dcaa77f4d32
5
5
  SHA512:
6
- metadata.gz: ebd03d8e45cb57530924a62c94e02df312b6d93624c303a1f05fb1a886b9c92aaae208feaa4419774dc325ba4078c3d90b281819dbc695f0d5a37139c787a481
7
- data.tar.gz: 6096e668ea12bd32950cea838844537ea3ed872398d944e88473f4efc9f9088320dc8f565cd62e9c48522596062a2034d3c89456afc4b2952df42d57492b0b2a
6
+ metadata.gz: b54b53aa6ec96ef9e8607bea7f96b8ef9fc7c4e2189675e575eeabdfaa2d608320c02ac86dc8ca7453cd9d314ceb943241a0a858689c85b8221374ff5dc6e00e
7
+ data.tar.gz: 86936495132694846dd8931998c9f716d405571dd34842f6f8563ad531f2e0b8fb678f4477cff9ec33a1c0d3affc615884a4dd8063909f57cb8e4a1da2a0434f
@@ -15,8 +15,8 @@ jobs:
15
15
  runs-on: macos-latest
16
16
  strategy:
17
17
  matrix:
18
- ruby: ['2.7.7', '3.0.5', '3.1.3', '3.2.1', 'head']
19
- duckdb: ['0.7.1', '0.6.1']
18
+ ruby: ['2.7.8', '3.0.6', '3.1.4', '3.2.2', 'head']
19
+ duckdb: ['0.7.1', '0.8.0']
20
20
 
21
21
  steps:
22
22
  - uses: actions/checkout@v3
@@ -52,11 +52,14 @@ jobs:
52
52
  cp duckdb-v$DUCKDB_VERSION/src/include/*.h /usr/local/include
53
53
  cp duckdb-v$DUCKDB_VERSION/build/release/src/*.dylib /usr/local/lib
54
54
 
55
- - name: Build and test with Rake with Ruby ${{ matrix.ruby }}
55
+ - name: Build with Ruby ${{ matrix.ruby }}
56
56
  run: |
57
- ruby -v
58
57
  bundle install --jobs 4 --retry 3
59
- bundle exec rake
58
+ rake build
59
+
60
+ - name: run test with Ruby ${{ matrix.ruby }}
61
+ run: |
62
+ rake test
60
63
 
61
64
  post-test:
62
65
  name: All tests passed on macos
@@ -15,8 +15,8 @@ jobs:
15
15
  runs-on: ubuntu-latest
16
16
  strategy:
17
17
  matrix:
18
- ruby: ['2.7.7', '3.0.5', '3.1.3', '3.2.1', 'head']
19
- duckdb: ['0.7.1', '0.6.1']
18
+ ruby: ['2.7.8', '3.0.6', '3.1.4', '3.2.2', 'head']
19
+ duckdb: ['0.7.1', '0.8.0']
20
20
 
21
21
  steps:
22
22
  - uses: actions/checkout@v3
@@ -45,13 +45,19 @@ jobs:
45
45
  cp -rip duckdb-tmp-v$DUCKDB_VERSION/build/release/src/*.so duckdb-v$DUCKDB_VERSION/build/release/src
46
46
  cp -rip duckdb-tmp-v$DUCKDB_VERSION/src/include duckdb-v$DUCKDB_VERSION/src/
47
47
 
48
- - name: Build and test with Rake with Ruby ${{ matrix.ruby }}
48
+ - name: Build with Ruby ${{ matrix.ruby }}
49
49
  env:
50
50
  DUCKDB_VERSION: ${{ matrix.duckdb }}
51
51
  run: |
52
52
  gem install bundler
53
53
  bundle install --jobs 4 --retry 3
54
- bundle exec rake -- --with-duckdb-include=${GITHUB_WORKSPACE}/duckdb-v${DUCKDB_VERSION}/src/include --with-duckdb-lib=${GITHUB_WORKSPACE}/duckdb-v${DUCKDB_VERSION}/build/release/src/
54
+ bundle exec rake build -- --with-duckdb-include=${GITHUB_WORKSPACE}/duckdb-v${DUCKDB_VERSION}/src/include --with-duckdb-lib=${GITHUB_WORKSPACE}/duckdb-v${DUCKDB_VERSION}/build/release/src/
55
+
56
+ - name: test with Ruby ${{ matrix.ruby }}
57
+ env:
58
+ DUCKDB_VERSION: ${{ matrix.duckdb }}
59
+ run: |
60
+ rake test
55
61
 
56
62
  post-test:
57
63
  name: All tests passed on Ubuntu
@@ -15,8 +15,8 @@ jobs:
15
15
  runs-on: windows-latest
16
16
  strategy:
17
17
  matrix:
18
- ruby: ['2.7.7', '3.0.5', '3.1.3', '3.2.1', 'ucrt', 'mingw', 'mswin', 'head']
19
- duckdb: ['0.7.1', '0.6.1']
18
+ ruby: ['2.7.8', '3.0.6', '3.1.4', '3.2.2', 'ucrt', 'mingw', 'mswin', 'head']
19
+ duckdb: ['0.7.1', '0.8.0']
20
20
 
21
21
  steps:
22
22
  - uses: actions/checkout@v3
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # ChangeLog
2
2
 
3
+ # 0.8.0
4
+ - bump duckdb to 0.8.0
5
+ - add DuckDB::Result#_to_decimal_internal
6
+ - add DuckDB::Result#_to_hugeint_internal
7
+
8
+ ## Breaking Change
9
+ - DuckDB::Result returns BigDecimal object instead of String object if the column type is DECIMAL.
10
+
11
+ # 0.7.1
3
12
  - bump duckdb to 0.7.1
4
13
  - fix docker build error on M1 Mac
5
14
 
data/Gemfile CHANGED
@@ -2,3 +2,8 @@ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in duckdb.gemspec
4
4
  gemspec
5
+
6
+ if /(linux|darwin)/ =~ RUBY_PLATFORM
7
+ gem 'benchmark-ips'
8
+ gem 'stackprof'
9
+ end
data/Gemfile.lock CHANGED
@@ -1,23 +1,30 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- duckdb (0.7.1)
4
+ duckdb (0.8.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- minitest (5.17.0)
9
+ benchmark-ips (2.12.0)
10
+ minitest (5.18.0)
10
11
  rake (13.0.6)
11
12
  rake-compiler (1.2.1)
12
13
  rake
14
+ stackprof (0.2.24)
13
15
 
14
16
  PLATFORMS
15
17
  ruby
16
18
  x86_64-linux
17
19
 
18
20
  DEPENDENCIES
21
+ benchmark-ips
19
22
  bundler (~> 2.3)
20
23
  duckdb!
21
24
  minitest (~> 5.0)
22
25
  rake (~> 13.0)
23
26
  rake-compiler
27
+ stackprof
28
+
29
+ BUNDLED WITH
30
+ 2.4.9
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/setup'
4
+ require 'duckdb'
5
+ require 'benchmark/ips'
6
+
7
+ db = DuckDB::Database.open
8
+ con = db.connect
9
+ con.query('CREATE TABLE decimals (decimal_value DECIMAL(38, 3))')
10
+ con.query('INSERT INTO decimals VALUES (1234567890123.456)')
11
+ result = con.query('SELECT decimal_value FROM decimals')
12
+
13
+ Benchmark.ips do |x|
14
+ x.report('_to_decimal') { result.send(:_to_decimal, 0, 0) }
15
+ x.report('_to_decimal_internal') { result.send(:_to_decimal_internal, 0, 0) }
16
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/setup'
4
+ require 'duckdb'
5
+ require 'benchmark/ips'
6
+
7
+ db = DuckDB::Database.open
8
+ con = db.connect
9
+ con.query('CREATE TABLE hugeints (hugeint_value HUGEINT)')
10
+ con.query('INSERT INTO hugeints VALUES (123456789012345678901234567890123456789)')
11
+ result = con.query('SELECT hugeint_value FROM hugeints')
12
+
13
+ Benchmark.ips do |x|
14
+ x.report('_to_hugeint') { result.send(:_to_hugeint, 0, 0) }
15
+ x.report('_to_hugeint_internal') { result.send(:_to_hugeint_internal, 0, 0) }
16
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/setup'
4
+ require 'duckdb'
5
+ require 'stackprof'
6
+
7
+ db = DuckDB::Database.open
8
+ con = db.connect
9
+ con.query('CREATE TABLE hugeints (hugeint_value HUGEINT)')
10
+ con.query('INSERT INTO hugeints VALUES (123456789012345678901234567890123456789)')
11
+ result = con.query('SELECT hugeint_value FROM hugeints')
12
+
13
+ def profile(name, &block)
14
+ profile = StackProf.run(mode: :wall, interval: 1_000) do
15
+ 2_000_000.times(&block)
16
+ end
17
+
18
+ result = StackProf::Report.new(profile)
19
+ puts
20
+ puts "=== #{name} ==="
21
+ result.print_text
22
+ puts
23
+ end
24
+
25
+ profile(:_to_hugeint) { result.send(:_to_hugeint, 0, 0) }
26
+ profile(:_to_hugeint_internal) { result.send(:_to_hugeint_internal, 0, 0) }
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'date'
2
4
  require 'time'
3
5
  require_relative './converter'
data/lib/duckdb/column.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module DuckDB
2
4
  class Column
3
5
  #
data/lib/duckdb/config.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module DuckDB
2
4
  if defined?(DuckDB::Config)
3
5
  # The DuckDB::Config encapsulates DuckDB Configuration.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module DuckDB
2
4
  # The DuckDB::Connection encapsulates connection with DuckDB database.
3
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module DuckDB
2
4
  module Converter
3
5
  HALF_HUGEINT = 1 << 64
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module DuckDB
2
4
  # The Database class encapsulates a DuckDB database.
3
5
  #
@@ -1,4 +1,5 @@
1
1
  require 'date'
2
+ require 'bigdecimal'
2
3
  require_relative './converter'
3
4
 
4
5
  module DuckDB
@@ -192,6 +193,8 @@ module DuckDB
192
193
  bind_varchar(i, value.strftime('%Y-%m-%d %H:%M:%S.%N'))
193
194
  when Date
194
195
  bind_varchar(i, value.strftime('%Y-%m-%d'))
196
+ when BigDecimal
197
+ bind_varchar(i, value.to_s('F'))
195
198
  else
196
199
  raise(DuckDB::Error, "not supported type `#{value}` (#{value.class})")
197
200
  end
data/lib/duckdb/result.rb CHANGED
@@ -1,3 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bigdecimal'
4
+
1
5
  module DuckDB
2
6
  # The Result class encapsulates a execute result of DuckDB database.
3
7
  #
@@ -28,8 +32,9 @@ module DuckDB
28
32
  5 => :_to_bigint,
29
33
  10 => :_to_float,
30
34
  11 => :_to_double,
31
- 16 => :_to_hugeint,
35
+ 16 => :_to_hugeint_internal,
32
36
  18 => :_to_blob,
37
+ 19 => :_to_decimal_internal
33
38
  }
34
39
 
35
40
  ToRuby.default = :_to_string
@@ -70,5 +75,21 @@ module DuckDB
70
75
  def _to_hugeint(row, col)
71
76
  _to_string(row, col).to_i
72
77
  end
78
+
79
+ def _to_hugeint_internal(row, col)
80
+ lower, upper = __to_hugeint_internal(row, col)
81
+ upper * Converter::HALF_HUGEINT + lower
82
+ end
83
+
84
+ def _to_decimal(row, col)
85
+ BigDecimal(_to_string(row, col))
86
+ end
87
+
88
+ def _to_decimal_internal(row, col)
89
+ lower, upper, _width, scale = __to_decimal_internal(row, col)
90
+ v = (upper * Converter::HALF_HUGEINT + lower).to_s
91
+ v[-scale, 0] = '.'
92
+ BigDecimal(v)
93
+ end
73
94
  end
74
95
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module DuckDB
2
4
  # The version string of ruby-duckdb.
3
5
  # Currently, ruby-duckdb is NOT semantic versioning.
4
- VERSION = '0.7.1'.freeze
6
+ VERSION = '0.8.0'.freeze
5
7
  end
data/lib/duckdb.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'duckdb/duckdb_native'
2
4
  require 'duckdb/library_version'
3
5
  require 'duckdb/version'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: duckdb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaki Suketa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-03-05 00:00:00.000000000 Z
11
+ date: 2023-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -87,6 +87,9 @@ files:
87
87
  - LICENSE
88
88
  - README.md
89
89
  - Rakefile
90
+ - benchmark/to_bigdecimal_ips.rb
91
+ - benchmark/to_hugeint_ips.rb
92
+ - benchmark/to_hugeint_profile.rb
90
93
  - bin/console
91
94
  - bin/setup
92
95
  - docker-compose.yml
@@ -148,7 +151,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
148
151
  - !ruby/object:Gem::Version
149
152
  version: '0'
150
153
  requirements: []
151
- rubygems_version: 3.4.6
154
+ rubygems_version: 3.4.10
152
155
  signing_key:
153
156
  specification_version: 4
154
157
  summary: This module is Ruby binding for DuckDB database engine.