duckdb 0.5.1.1 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/test_on_macos.yml +4 -4
- data/.github/workflows/test_on_ubuntu.yml +4 -4
- data/.github/workflows/test_on_windows.yml +2 -2
- data/CHANGELOG.md +21 -7
- data/Gemfile.lock +1 -1
- data/ext/duckdb/duckdb.c +14 -0
- data/ext/duckdb/extconf.rb +22 -3
- data/ext/duckdb/prepared_statement.c +18 -0
- data/ext/duckdb/result.c +11 -0
- data/ext/duckdb/ruby-duckdb.h +4 -0
- data/lib/duckdb/appender.rb +2 -9
- data/lib/duckdb/converter.rb +13 -0
- data/lib/duckdb/prepared_statement.rb +30 -3
- data/lib/duckdb/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9967f34d6c3a9f9d30fc9c406043230d86ffe98d0ca5cf55e74a547f6877b756
|
4
|
+
data.tar.gz: e28bce3d7b8410ceff6da630aaa54eab4d345bfab16748f9150dfef6e3836bfe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 834d11017be58ad60d8f8d8600e22f7e97dbac4ef2789921d2da8f76487e7df3c60a7458ece7e7d5f3fb7d1aca3bcf178557968131673055c2bf2d932bc982d6
|
7
|
+
data.tar.gz: f63d824d611095b857310f6f2f1c432d0129be7bbc3d03cb339baf938bd00c43e7911689b988494e4613f4199abf72a1b08c022d7adac26cc29f2e13ecd49883
|
@@ -15,11 +15,11 @@ jobs:
|
|
15
15
|
runs-on: macos-latest
|
16
16
|
strategy:
|
17
17
|
matrix:
|
18
|
-
ruby: ['2.6.10', '2.7.
|
19
|
-
duckdb: ['0.5.1', '0.
|
18
|
+
ruby: ['2.6.10', '2.7.7', '3.0.5', '3.1.3', '3.2.0', 'head']
|
19
|
+
duckdb: ['0.5.1', '0.6.1']
|
20
20
|
|
21
21
|
steps:
|
22
|
-
- uses: actions/checkout@
|
22
|
+
- uses: actions/checkout@v3
|
23
23
|
|
24
24
|
- name: Set up Ruby
|
25
25
|
uses: ruby/setup-ruby@v1
|
@@ -28,7 +28,7 @@ jobs:
|
|
28
28
|
|
29
29
|
- name: duckdb cache
|
30
30
|
id: duckdb-cache
|
31
|
-
uses: actions/cache@
|
31
|
+
uses: actions/cache@v3
|
32
32
|
with:
|
33
33
|
path: duckdb-v${{ matrix.duckdb }}
|
34
34
|
key: ${{ runner.os }}-duckdb-v${{ matrix.duckdb }}
|
@@ -15,11 +15,11 @@ jobs:
|
|
15
15
|
runs-on: ubuntu-latest
|
16
16
|
strategy:
|
17
17
|
matrix:
|
18
|
-
ruby: ['2.6.10', '2.7.
|
19
|
-
duckdb: ['0.5.1', '0.
|
18
|
+
ruby: ['2.6.10', '2.7.7', '3.0.5', '3.1.3', '3.2.0', 'head']
|
19
|
+
duckdb: ['0.5.1', '0.6.1']
|
20
20
|
|
21
21
|
steps:
|
22
|
-
- uses: actions/checkout@
|
22
|
+
- uses: actions/checkout@v3
|
23
23
|
|
24
24
|
- name: Set up Ruby
|
25
25
|
uses: ruby/setup-ruby@v1
|
@@ -28,7 +28,7 @@ jobs:
|
|
28
28
|
|
29
29
|
- name: duckdb cache
|
30
30
|
id: duckdb-cache
|
31
|
-
uses: actions/cache@
|
31
|
+
uses: actions/cache@v3
|
32
32
|
with:
|
33
33
|
path: duckdb-v${{ matrix.duckdb }}
|
34
34
|
key: ${{ runner.os }}-duckdb-v${{ matrix.duckdb }}
|
@@ -16,10 +16,10 @@ jobs:
|
|
16
16
|
strategy:
|
17
17
|
matrix:
|
18
18
|
ruby: ['2.6.10', '2.7.6', '3.0.4', '3.1.2', 'ucrt', 'mingw', 'head']
|
19
|
-
duckdb: ['0.5.1', '0.
|
19
|
+
duckdb: ['0.5.1', '0.6.1']
|
20
20
|
|
21
21
|
steps:
|
22
|
-
- uses: actions/checkout@
|
22
|
+
- uses: actions/checkout@v3
|
23
23
|
|
24
24
|
- name: Set up Ruby
|
25
25
|
uses: ruby/setup-ruby@v1
|
data/CHANGELOG.md
CHANGED
@@ -1,16 +1,30 @@
|
|
1
1
|
# ChangeLog
|
2
2
|
|
3
|
+
# 0.6.1
|
4
|
+
- bump Ruby to 3.2.0 on CI
|
5
|
+
- fix deprected warning (double_heap is deprecated in GC.verify_compaction_references) with Ruby 3.2.0 on CI
|
6
|
+
- bump duckdb to 0.6.1 on CI
|
7
|
+
- add DuckDB::PreparedStatement#bind_hugeint_internal
|
8
|
+
- fix gem install error on M1 MacOS
|
9
|
+
- implement DuckDB.library_version
|
10
|
+
- use duckdb_value_string instead of duckdb_value_varchar if duckdb_value_string is available.
|
11
|
+
- bump Ruby to 3.2.0rc1
|
12
|
+
- bump duckdb to 0.6.0
|
13
|
+
|
14
|
+
## Breaking Change
|
15
|
+
- drop duckdb <= 0.4.x. ruby-duckdb supports duckdb >= 0.5.0
|
16
|
+
|
3
17
|
# 0.5.1.1
|
4
18
|
- bug fix: reading the boolean column
|
5
19
|
|
6
20
|
# 0.5.1
|
7
|
-
- bump duckdb 0.5.1
|
21
|
+
- bump duckdb to 0.5.1
|
8
22
|
|
9
23
|
# 0.5.0
|
10
24
|
- update bundle version of Gemfile.lock
|
11
25
|
- add ruby ucrt test on Windows
|
12
26
|
- use TypedData_Wrap_Struct, TypedData_Get_Struct
|
13
|
-
- bump duckdb 0.5.0
|
27
|
+
- bump duckdb to 0.5.0
|
14
28
|
- fix utf-8 encoding.
|
15
29
|
- add DuckDB::Result#enum_dictionary_values
|
16
30
|
- add DuckDB::Result#row_count, DuckDB::Result#row_size(alias of row_count).
|
@@ -20,19 +34,19 @@
|
|
20
34
|
- bind_varchar does not raised DuckDB::Error when the binding column is date or datetime.
|
21
35
|
|
22
36
|
# 0.3.4.0
|
23
|
-
- bump duckdb 0.3.4
|
37
|
+
- bump duckdb to 0.3.4
|
24
38
|
|
25
39
|
# 0.3.3.0
|
26
40
|
- DuckDB::Column#type supports :decimal.
|
27
|
-
- bump duckdb 0.3.3.
|
28
|
-
- bump Ruby 2.6.10, 2.7.6, 3.0.4, 3.1.2.
|
41
|
+
- bump duckdb to 0.3.3.
|
42
|
+
- bump Ruby to 2.6.10, 2.7.6, 3.0.4, 3.1.2.
|
29
43
|
|
30
44
|
# 0.3.2.0
|
31
45
|
|
32
46
|
- bind_time, bind_timestamp, bind_date, bind_timeinterval to DuckDB::PreparedStatement
|
33
47
|
- bump duckdb 0.3.2
|
34
|
-
- bump Ruby 3.1.1, add Ruby mingw in CI.
|
35
|
-
- bump Ruby 2.6.9, 2.7.5, 3.0.3 in CI.
|
48
|
+
- bump Ruby to 3.1.1, add Ruby mingw in CI.
|
49
|
+
- bump Ruby to 2.6.9, 2.7.5, 3.0.3 in CI.
|
36
50
|
|
37
51
|
## BREAKING CHANGE
|
38
52
|
- drop duckdb <= 0.2.8
|
data/Gemfile.lock
CHANGED
data/ext/duckdb/duckdb.c
CHANGED
@@ -2,10 +2,24 @@
|
|
2
2
|
|
3
3
|
VALUE mDuckDB;
|
4
4
|
|
5
|
+
#ifdef HAVE_DUCKDB_H_GE_V060
|
6
|
+
static VALUE duckdb_s_library_version(VALUE self);
|
7
|
+
#endif
|
8
|
+
|
9
|
+
#ifdef HAVE_DUCKDB_H_GE_V060
|
10
|
+
static VALUE duckdb_s_library_version(VALUE self) {
|
11
|
+
return rb_str_new2(duckdb_library_version());
|
12
|
+
}
|
13
|
+
#endif
|
14
|
+
|
5
15
|
void
|
6
16
|
Init_duckdb_native(void) {
|
7
17
|
mDuckDB = rb_define_module("DuckDB");
|
8
18
|
|
19
|
+
#ifdef HAVE_DUCKDB_H_GE_V060
|
20
|
+
rb_define_singleton_method(mDuckDB, "library_version", duckdb_s_library_version, 0);
|
21
|
+
#endif
|
22
|
+
|
9
23
|
init_duckdb_error();
|
10
24
|
init_duckdb_database();
|
11
25
|
init_duckdb_connection();
|
data/ext/duckdb/extconf.rb
CHANGED
@@ -1,15 +1,34 @@
|
|
1
1
|
require 'mkmf'
|
2
2
|
|
3
|
-
|
3
|
+
def duckdb_library_available?(func)
|
4
|
+
header = find_header('duckdb.h') || find_header('duckdb.h', '/opt/homebrew/include')
|
5
|
+
library = have_func('duckdb', func) || find_library('duckdb', func, '/opt/homebrew/opt/duckdb/lib')
|
6
|
+
header && library
|
7
|
+
end
|
8
|
+
|
9
|
+
def check_duckdb_library(func, version)
|
10
|
+
return if duckdb_library_available?(func)
|
4
11
|
|
5
|
-
|
12
|
+
msg = "duckdb >= #{version} is not found. Install duckdb >= #{version} library and header file."
|
13
|
+
puts ''
|
14
|
+
puts '*' * 80
|
15
|
+
puts msg
|
16
|
+
puts '*' * 80
|
17
|
+
puts ''
|
18
|
+
raise msg
|
19
|
+
end
|
6
20
|
|
7
|
-
|
21
|
+
dir_config('duckdb')
|
22
|
+
|
23
|
+
check_duckdb_library('duckdb_pending_prepared', '0.5.0')
|
8
24
|
|
9
25
|
# check duckdb >= 0.3.3
|
10
26
|
# ducdb >= 0.3.3 if duckdb_append_data_chunk() is defined.
|
11
27
|
have_func('duckdb_append_data_chunk', 'duckdb.h')
|
12
28
|
|
29
|
+
# check duckdb >= 0.6.0
|
30
|
+
have_func('duckdb_value_string', 'duckdb.h')
|
31
|
+
|
13
32
|
have_func('duckdb_free', 'duckdb.h')
|
14
33
|
|
15
34
|
create_makefile('duckdb/duckdb_native')
|
@@ -23,6 +23,7 @@ static VALUE duckdb_prepared_statement__bind_date(VALUE self, VALUE vidx, VALUE
|
|
23
23
|
static VALUE duckdb_prepared_statement__bind_time(VALUE self, VALUE vidx, VALUE hour, VALUE min, VALUE sec, VALUE micros);
|
24
24
|
static VALUE duckdb_prepared_statement__bind_timestamp(VALUE self, VALUE vidx, VALUE year, VALUE month, VALUE day, VALUE hour, VALUE min, VALUE sec, VALUE micros);
|
25
25
|
static VALUE duckdb_prepared_statement__bind_interval(VALUE self, VALUE vidx, VALUE months, VALUE days, VALUE micros);
|
26
|
+
static VALUE duckdb_prepared_statement__bind_hugeint(VALUE self, VALUE vidx, VALUE lower, VALUE upper);
|
26
27
|
|
27
28
|
static const rb_data_type_t prepared_statement_data_type = {
|
28
29
|
"DuckDB/PreparedStatement",
|
@@ -283,6 +284,22 @@ static VALUE duckdb_prepared_statement__bind_interval(VALUE self, VALUE vidx, VA
|
|
283
284
|
return self;
|
284
285
|
}
|
285
286
|
|
287
|
+
static VALUE duckdb_prepared_statement__bind_hugeint(VALUE self, VALUE vidx, VALUE lower, VALUE upper) {
|
288
|
+
duckdb_hugeint hugeint;
|
289
|
+
rubyDuckDBPreparedStatement *ctx;
|
290
|
+
idx_t idx = check_index(vidx);
|
291
|
+
|
292
|
+
TypedData_Get_Struct(self, rubyDuckDBPreparedStatement, &prepared_statement_data_type, ctx);
|
293
|
+
hugeint.lower = NUM2ULL(lower);
|
294
|
+
hugeint.upper = NUM2LL(upper);
|
295
|
+
|
296
|
+
if (duckdb_bind_hugeint(ctx->prepared_statement, idx, hugeint) == DuckDBError) {
|
297
|
+
rb_raise(eDuckDBError, "fail to bind %llu parameter", (unsigned long long)idx);
|
298
|
+
}
|
299
|
+
|
300
|
+
return self;
|
301
|
+
}
|
302
|
+
|
286
303
|
void init_duckdb_prepared_statement(void) {
|
287
304
|
cDuckDBPreparedStatement = rb_define_class_under(mDuckDB, "PreparedStatement", rb_cObject);
|
288
305
|
|
@@ -305,4 +322,5 @@ void init_duckdb_prepared_statement(void) {
|
|
305
322
|
rb_define_private_method(cDuckDBPreparedStatement, "_bind_time", duckdb_prepared_statement__bind_time, 5);
|
306
323
|
rb_define_private_method(cDuckDBPreparedStatement, "_bind_timestamp", duckdb_prepared_statement__bind_timestamp, 8);
|
307
324
|
rb_define_private_method(cDuckDBPreparedStatement, "_bind_interval", duckdb_prepared_statement__bind_interval, 4);
|
325
|
+
rb_define_private_method(cDuckDBPreparedStatement, "_bind_hugeint", duckdb_prepared_statement__bind_hugeint, 3);
|
308
326
|
}
|
data/ext/duckdb/result.c
CHANGED
@@ -271,14 +271,25 @@ static VALUE duckdb_result__to_double(VALUE oDuckDBResult, VALUE row_idx, VALUE
|
|
271
271
|
|
272
272
|
static VALUE duckdb_result__to_string(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx) {
|
273
273
|
rubyDuckDBResult *ctx;
|
274
|
+
#ifdef HAVE_DUCKDB_H_GE_V060
|
275
|
+
duckdb_string p;
|
276
|
+
#else
|
274
277
|
char *p;
|
278
|
+
#endif
|
275
279
|
VALUE obj;
|
276
280
|
TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
|
277
281
|
|
282
|
+
#ifdef HAVE_DUCKDB_H_GE_V060
|
283
|
+
p = duckdb_value_string(&(ctx->result), NUM2LL(col_idx), NUM2LL(row_idx));
|
284
|
+
if (p.data) {
|
285
|
+
obj = rb_utf8_str_new(p.data, p.size);
|
286
|
+
duckdb_free(p.data);
|
287
|
+
#else
|
278
288
|
p = duckdb_value_varchar(&(ctx->result), NUM2LL(col_idx), NUM2LL(row_idx));
|
279
289
|
if (p) {
|
280
290
|
obj = rb_utf8_str_new_cstr(p);
|
281
291
|
duckdb_free(p);
|
292
|
+
#endif
|
282
293
|
return obj;
|
283
294
|
}
|
284
295
|
return Qnil;
|
data/ext/duckdb/ruby-duckdb.h
CHANGED
data/lib/duckdb/appender.rb
CHANGED
@@ -33,15 +33,8 @@ module DuckDB
|
|
33
33
|
# .end_row
|
34
34
|
#
|
35
35
|
def append_hugeint(value)
|
36
|
-
|
37
|
-
|
38
|
-
half = 1 << 64
|
39
|
-
upper = value / half
|
40
|
-
lower = value - upper * half
|
41
|
-
_append_hugeint(lower, upper)
|
42
|
-
else
|
43
|
-
raise(ArgumentError, "2nd argument `#{value}` must be Integer.")
|
44
|
-
end
|
36
|
+
lower, upper = integer_to_hugeint(value)
|
37
|
+
_append_hugeint(lower, upper)
|
45
38
|
end
|
46
39
|
|
47
40
|
#
|
data/lib/duckdb/converter.rb
CHANGED
@@ -1,7 +1,20 @@
|
|
1
1
|
module DuckDB
|
2
2
|
module Converter
|
3
|
+
HALF_HUGEINT = 1 << 64
|
4
|
+
|
3
5
|
private
|
4
6
|
|
7
|
+
def integer_to_hugeint(value)
|
8
|
+
case value
|
9
|
+
when Integer
|
10
|
+
upper = value / HALF_HUGEINT
|
11
|
+
lower = value - upper * HALF_HUGEINT
|
12
|
+
[lower, upper]
|
13
|
+
else
|
14
|
+
raise(ArgumentError, "2nd argument `#{value}` must be Integer.")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
5
18
|
def iso8601_interval_to_hash(value)
|
6
19
|
digit = ''
|
7
20
|
time = false
|
@@ -15,10 +15,21 @@ module DuckDB
|
|
15
15
|
class PreparedStatement
|
16
16
|
include DuckDB::Converter
|
17
17
|
|
18
|
-
RANGE_INT16 = -
|
19
|
-
RANGE_INT32 = -
|
20
|
-
RANGE_INT64 = -
|
18
|
+
RANGE_INT16 = -32_768..32_767
|
19
|
+
RANGE_INT32 = -2_147_483_648..2_147_483_647
|
20
|
+
RANGE_INT64 = -9_223_372_036_854_775_808..9_223_372_036_854_775_807
|
21
21
|
|
22
|
+
# binds i-th parameter with SQL prepared statement.
|
23
|
+
# The first argument is index of parameter.
|
24
|
+
# The index of first parameter is 1 not 0.
|
25
|
+
# The second argument value is to expected Integer value.
|
26
|
+
# This method uses bind_varchar internally.
|
27
|
+
# require 'duckdb'
|
28
|
+
# db = DuckDB::Database.open('duckdb_database')
|
29
|
+
# con = db.connect
|
30
|
+
# sql ='SELECT name FROM users WHERE bigint_col = ?'
|
31
|
+
# stmt = PreparedStatement.new(con, sql)
|
32
|
+
# stmt.bind_hugeint(1, 1_234_567_890_123_456_789_012_345)
|
22
33
|
def bind_hugeint(i, value)
|
23
34
|
case value
|
24
35
|
when Integer
|
@@ -28,6 +39,22 @@ module DuckDB
|
|
28
39
|
end
|
29
40
|
end
|
30
41
|
|
42
|
+
# binds i-th parameter with SQL prepared statement.
|
43
|
+
# The first argument is index of parameter.
|
44
|
+
# The index of first parameter is 1 not 0.
|
45
|
+
# The second argument value must be Integer value.
|
46
|
+
# This method uses duckdb_bind_hugeint internally.
|
47
|
+
# require 'duckdb'
|
48
|
+
# db = DuckDB::Database.open('duckdb_database')
|
49
|
+
# con = db.connect
|
50
|
+
# sql ='SELECT name FROM users WHERE bigint_col = ?'
|
51
|
+
# stmt = PreparedStatement.new(con, sql)
|
52
|
+
# stmt.bind_hugeint_internal(1, 1_234_567_890_123_456_789_012_345)
|
53
|
+
def bind_hugeint_internal(index, value)
|
54
|
+
lower, upper = integer_to_hugeint(value)
|
55
|
+
_bind_hugeint(index, lower, upper)
|
56
|
+
end
|
57
|
+
|
31
58
|
# binds i-th parameter with SQL prepared statement.
|
32
59
|
# The first argument is index of parameter.
|
33
60
|
# The index of first parameter is 1 not 0.
|
data/lib/duckdb/version.rb
CHANGED
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.
|
4
|
+
version: 0.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masaki Suketa
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-12-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -129,7 +129,7 @@ metadata:
|
|
129
129
|
homepage_uri: https://github.com/suketa/ruby-duckdb
|
130
130
|
source_code_uri: https://github.com/suketa/ruby-duckdb
|
131
131
|
changelog_uri: https://github.com/suketa/ruby-duckdb/blob/master/CHANGELOG.md
|
132
|
-
post_install_message:
|
132
|
+
post_install_message:
|
133
133
|
rdoc_options: []
|
134
134
|
require_paths:
|
135
135
|
- lib
|
@@ -144,8 +144,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
144
144
|
- !ruby/object:Gem::Version
|
145
145
|
version: '0'
|
146
146
|
requirements: []
|
147
|
-
rubygems_version: 3.
|
148
|
-
signing_key:
|
147
|
+
rubygems_version: 3.4.1
|
148
|
+
signing_key:
|
149
149
|
specification_version: 4
|
150
150
|
summary: This module is Ruby binding for DuckDB database engine.
|
151
151
|
test_files: []
|