duckdb 1.1.0.0 β†’ 1.1.1.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: 17d405dc19edeb4bbdea3da427974d5a3904fb2f10536fae4494fa284bebd8ff
4
- data.tar.gz: 8f26f51c5d14d8854009619916008a8742ebf09f351e5e8f025ccc2fad9ccf13
3
+ metadata.gz: 84935b6317fa4bef4b62197645f061b179e3358e93cba3b976672eb1988715fc
4
+ data.tar.gz: 7ff6b2f4b46ea16bcfa2e7de486e9a5bb30aa7d4dccb14e32af7b9886d6fcac4
5
5
  SHA512:
6
- metadata.gz: 6a15f0763765f35dc5c86cde1425acc6c1e001bec99fd3901aeeeaf74ca94d3af9ad9905be43c8b2a7c0eb3b87a68d20945f25063c8a2e77ba527e54c3c8d49e
7
- data.tar.gz: 0061c636c7d80629677b27cab21b173690b8e7aed3f8f8df86783632e92bca9a7349ae80e2e6cb32b04ea356c61c31a9abfdd15da1b05b138f3de186411c5969
6
+ metadata.gz: d90dbdbf57d5cc282049f6297d00674ff57d9fafbfd7bfab8db8c87fb1153d3c9ea93ceda3b440d066c24ceef5dd1e349dedea6f4b17557bda590bb92f93fc5a
7
+ data.tar.gz: cbcbd5c50c6ddc92c01001b36cbe5aad8a87729ea5518a881dcf8c21621679d1c3740c0ed97672d597aca351ea09548d6f7b5e722fde32077cb811a57c3dfd40
@@ -15,8 +15,8 @@ jobs:
15
15
  runs-on: macos-latest
16
16
  strategy:
17
17
  matrix:
18
- ruby: ['3.1.6', '3.2.4', '3.3.5', '3.4.0-preview1', 'head']
19
- duckdb: ['1.1.0', '1.0.0', '0.10.3']
18
+ ruby: ['3.1.6', '3.2.5', '3.3.5', '3.4.0-preview1', 'head']
19
+ duckdb: ['1.1.1', '1.1.0', '1.0.0']
20
20
 
21
21
  steps:
22
22
  - uses: actions/checkout@v4
@@ -51,12 +51,12 @@ jobs:
51
51
  run: |
52
52
  bundle install --jobs 4 --retry 3
53
53
 
54
- # - name: Build test with DUCKDB_API_NO_DEPRECATED and Ruby ${{ matrix.ruby }}
55
- # env:
56
- # DUCKDB_VERSION: ${{ matrix.duckdb }}
57
- # run: |
58
- # env DUCKDB_API_NO_DEPRECATED=1 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/
59
- # bundle exec rake clean
54
+ - name: Build test with DUCKDB_API_NO_DEPRECATED and Ruby ${{ matrix.ruby }}
55
+ env:
56
+ DUCKDB_VERSION: ${{ matrix.duckdb }}
57
+ run: |
58
+ env DUCKDB_API_NO_DEPRECATED=1 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/
59
+ bundle exec rake clean
60
60
 
61
61
  - name: Build with Ruby ${{ matrix.ruby }}
62
62
  env:
@@ -15,8 +15,8 @@ jobs:
15
15
  runs-on: ubuntu-latest
16
16
  strategy:
17
17
  matrix:
18
- ruby: ['3.1.6', '3.2.4', '3.3.5', '3.4.0-preview1', 'head']
19
- duckdb: ['1.1.0', '1.0.0', '0.10.3']
18
+ ruby: ['3.1.6', '3.2.5', '3.3.5', '3.4.0-preview1', 'head']
19
+ duckdb: ['1.1.1', '1.1.0', '1.0.0']
20
20
 
21
21
  steps:
22
22
  - uses: actions/checkout@v4
@@ -15,8 +15,8 @@ jobs:
15
15
  runs-on: windows-latest
16
16
  strategy:
17
17
  matrix:
18
- ruby: ['3.1.5', '3.2.4', '3.3.4', 'ucrt', 'mingw', 'mswin', 'head']
19
- duckdb: ['1.1.0', '1.0.0', '0.10.3']
18
+ ruby: ['3.1.6', '3.2.5', '3.3.5', 'ucrt', 'mingw', 'mswin', 'head']
19
+ duckdb: ['1.1.1', '1.1.0', '1.0.0']
20
20
 
21
21
  steps:
22
22
  - uses: actions/checkout@v4
data/CHANGELOG.md CHANGED
@@ -1,6 +1,15 @@
1
1
  # Changelog
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
+ # Unreleased
5
+
6
+ # 1.1.1.0 - 2024-10-06
7
+ - bump duckdb 1.1.1.
8
+ ## Breaking changes
9
+ - drop duckdb v0.10.x.
10
+
11
+ # 1.1.0.1 - 2024-09-21
12
+ - add `DuckDB::Connection#prepare`. `DuckDB::Connection#prepare` is an alias of `DuckDB::Connection#prepared_statement`.
4
13
 
5
14
  # 1.1.0.0 - 2024-09-15
6
15
  - drop ruby 3.0.x.
@@ -31,7 +40,7 @@ All notable changes to this project will be documented in this file.
31
40
  ## Breaking changes
32
41
  - drop duckdb v0.9.x.
33
42
  - skip to check duckdb_parameter_name is available.
34
- - The following methods are deprecated.
43
+ - The following methods are obsoleted.
35
44
  - `DuckDB::Result#_null?`
36
45
  - `DuckDB::Result#_to_boolean`
37
46
  - `DuckDB::Result#_to_smallint`
data/Dockerfile CHANGED
@@ -1,7 +1,7 @@
1
1
  ARG RUBY_VERSION=3.3.5
2
2
  FROM ruby:${RUBY_VERSION}
3
3
 
4
- ARG DUCKDB_VERSION=1.1.0
4
+ ARG DUCKDB_VERSION=1.1.1
5
5
 
6
6
  RUN apt update -qq && \
7
7
  apt install -y build-essential curl git wget
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- duckdb (1.1.0.0)
4
+ duckdb (1.1.1.0)
5
5
  bigdecimal (>= 3.1.4)
6
6
 
7
7
  GEM
@@ -18,7 +18,7 @@ GEM
18
18
  racc (~> 1.4)
19
19
  racc (1.8.1)
20
20
  rake (13.2.1)
21
- rake-compiler (1.2.7)
21
+ rake-compiler (1.2.8)
22
22
  rake
23
23
  ruby_memcheck (3.0.0)
24
24
  nokogiri
data/README.md CHANGED
@@ -113,7 +113,19 @@ con.query('SELECT * FROM users WHERE name = ? AND email = ?', 'Alice', 'alice@ex
113
113
  # or
114
114
  con.query('SELECT * FROM users WHERE name = $name AND email = $email', name: 'Alice', email: 'alice@example.com')
115
115
  ```
116
+ ### Using prepared statement
116
117
 
118
+ You can use prepared statement.
119
+
120
+ ```ruby
121
+ stmt = con.prepare('SELECT * FROM users WHERE name = $name AND email = $email')
122
+ # or
123
+ # stmt = con.prepared_statement('SELECT * FROM users WHERE name = $name AND email = $email')
124
+ # or
125
+ # stmt = DuckDB::PreparedStatement.new(con, 'SELECT * FROM users WHERE name = $name AND email = $email')
126
+ stmt.bind(name: 'Alice', email: 'alice@example.com')
127
+ result = stmt.execute
128
+ ```
117
129
  ### Using async query
118
130
 
119
131
  You can use async query.
@@ -106,20 +106,12 @@ static VALUE duckdb_connection_interrupt(VALUE self) {
106
106
  */
107
107
  static VALUE duckdb_connection_query_progress(VALUE self) {
108
108
  rubyDuckDBConnection *ctx;
109
- #ifdef HAVE_DUCKDB_H_GE_V0_10_0
110
109
  duckdb_query_progress_type progress;
111
- #else
112
- double progress;
113
- #endif
114
110
 
115
111
  TypedData_Get_Struct(self, rubyDuckDBConnection, &connection_data_type, ctx);
116
112
  progress = duckdb_query_progress(ctx->con);
117
113
 
118
- #ifdef HAVE_DUCKDB_H_GE_V0_10_0
119
114
  return rb_funcall(mDuckDBConverter, rb_intern("_to_query_progress"), 3, DBL2NUM(progress.percentage), ULL2NUM(progress.rows_processed), ULL2NUM(progress.total_rows_to_process));
120
- #else
121
- return DBL2NUM(progress);
122
- #endif
123
115
  }
124
116
 
125
117
  static VALUE duckdb_connection_connect(VALUE self, VALUE oDuckDBDatabase) {
@@ -2,7 +2,7 @@
2
2
 
3
3
  require 'mkmf'
4
4
 
5
- DUCKDB_REQUIRED_VERSION = '0.10.0'
5
+ DUCKDB_REQUIRED_VERSION = '1.0.0'
6
6
 
7
7
  def check_duckdb_header(header, version)
8
8
  found = find_header(
@@ -58,8 +58,8 @@ dir_config('duckdb')
58
58
  check_duckdb_header('duckdb.h', DUCKDB_REQUIRED_VERSION)
59
59
  check_duckdb_library('duckdb', 'duckdb_appender_column_count', DUCKDB_REQUIRED_VERSION)
60
60
 
61
- # check duckdb >= 0.10.0
62
- have_func('duckdb_appender_column_count', 'duckdb.h')
61
+ # check duckdb >= 1.0.0
62
+ have_func('duckdb_fetch_chunk', 'duckdb.h')
63
63
 
64
64
  # check duckdb >= 1.0.0
65
65
  have_func('duckdb_fetch_chunk', 'duckdb.h')
@@ -67,6 +67,10 @@ have_func('duckdb_fetch_chunk', 'duckdb.h')
67
67
  # check duckdb >= 1.1.0
68
68
  have_func('duckdb_result_error_type', 'duckdb.h')
69
69
 
70
+ # Building with enabled DUCKDB_API_NO_DEPRECATED is failed with DuckDB v1.1.0 only.
71
+ # DuckDB v1.1.1 is fixed this issue https://github.com/duckdb/duckdb/issues/13872.
72
+ have_const('DUCKDB_TYPE_SQLNULL', 'duckdb.h')
73
+
70
74
  $CFLAGS << ' -DDUCKDB_API_NO_DEPRECATED' if ENV['DUCKDB_API_NO_DEPRECATED']
71
75
 
72
76
  create_makefile('duckdb/duckdb_native')
data/ext/duckdb/result.c CHANGED
@@ -310,7 +310,14 @@ static VALUE duckdb_result__column_type(VALUE oDuckDBResult, VALUE col_idx) {
310
310
  static VALUE duckdb_result__return_type(VALUE oDuckDBResult) {
311
311
  rubyDuckDBResult *ctx;
312
312
  TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
313
+ /*
314
+ * remove this #if ... #else statement when dropping duckdb 1.1.0.
315
+ */
316
+ #if !defined(HAVE_DUCKDB_H_GE_V1_1_1) && defined(HAVE_DUCKDB_H_GE_V1_1_0) && defined(DUCKDB_API_NO_DEPRECATED)
317
+ rb_raise(eDuckDBError, "duckdb_result_return_type C-API is not available with duckdb v1.1.0 with enabled DUCKDB_API_NO_DEPRECATED.");
318
+ #else
313
319
  return INT2FIX(duckdb_result_return_type(ctx->result));
320
+ #endif
314
321
  }
315
322
 
316
323
  static VALUE duckdb_result__statement_type(VALUE oDuckDBResult) {
@@ -7,10 +7,6 @@
7
7
  #include "ruby.h"
8
8
  #include <duckdb.h>
9
9
 
10
- #ifdef HAVE_DUCKDB_APPENDER_COLUMN_COUNT
11
- #define HAVE_DUCKDB_H_GE_V0_10_0 1
12
- #endif
13
-
14
10
  #ifdef HAVE_DUCKDB_FETCH_CHUNK
15
11
  #define HAVE_DUCKDB_H_GE_V1_0_0 1
16
12
  #endif
@@ -19,6 +15,10 @@
19
15
  #define HAVE_DUCKDB_H_GE_V1_1_0 1
20
16
  #endif
21
17
 
18
+ #ifdef HAVE_CONST_DUCKDB_TYPE_SQLNULL
19
+ #define HAVE_DUCKDB_H_GE_V1_1_1 1
20
+ #endif
21
+
22
22
  #include "./error.h"
23
23
  #include "./database.h"
24
24
  #include "./connection.h"
@@ -97,6 +97,14 @@ module DuckDB
97
97
  # returns PreparedStatement object.
98
98
  # The first argument is SQL string.
99
99
  #
100
+ # require 'duckdb'
101
+ # db = DuckDB::Database.open('duckdb_file')
102
+ # con = db.connect
103
+ #
104
+ # sql = 'SELECT * FROM users WHERE name = $name AND email = $email'
105
+ # stmt = con.prepared_statement(sql)
106
+ # stmt.bind_args(name: 'Dave', email: 'dave@example.com')
107
+ # result = stmt.execute
100
108
  def prepared_statement(str)
101
109
  PreparedStatement.new(self, str)
102
110
  end
@@ -126,5 +134,6 @@ module DuckDB
126
134
  alias async_execute async_query
127
135
  alias open connect
128
136
  alias close disconnect
137
+ alias prepare prepared_statement
129
138
  end
130
139
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  module DuckDB
4
4
  module Converter
5
- module IntToSym
5
+ module IntToSym # :nodoc: all
6
6
  STATEMENT_TYPES = %i[
7
7
  invalid
8
8
  select
@@ -34,90 +34,52 @@ module DuckDB
34
34
  multi
35
35
  ].freeze
36
36
 
37
- HASH_TYPES = if Gem::Version.new(DuckDB::LIBRARY_VERSION) == Gem::Version.new('0.10.0')
38
- {
39
- 0 => :invalid,
40
- 1 => :boolean,
41
- 2 => :tinyint,
42
- 3 => :smallint,
43
- 4 => :integer,
44
- 5 => :bigint,
45
- 6 => :utinyint,
46
- 7 => :usmallint,
47
- 8 => :uinteger,
48
- 9 => :ubigint,
49
- 10 => :float,
50
- 11 => :double,
51
- 12 => :timestamp,
52
- 13 => :date,
53
- 14 => :time,
54
- 15 => :interval,
55
- 16 => :hugeint,
56
- 17 => :uhugeint,
57
- 18 => :varchar,
58
- 19 => :blob,
59
- 20 => :decimal,
60
- 21 => :timestamp_s,
61
- 22 => :timestamp_ms,
62
- 23 => :timestamp_ns,
63
- 24 => :enum,
64
- 25 => :list,
65
- 26 => :struct,
66
- 27 => :map,
67
- 28 => :uuid,
68
- 29 => :union,
69
- 30 => :bit,
70
- 31 => :time_tz,
71
- 32 => :timestamp_tz
72
- }.freeze
73
- else
74
- {
75
- 0 => :invalid,
76
- 1 => :boolean,
77
- 2 => :tinyint,
78
- 3 => :smallint,
79
- 4 => :integer,
80
- 5 => :bigint,
81
- 6 => :utinyint,
82
- 7 => :usmallint,
83
- 8 => :uinteger,
84
- 9 => :ubigint,
85
- 10 => :float,
86
- 11 => :double,
87
- 12 => :timestamp,
88
- 13 => :date,
89
- 14 => :time,
90
- 15 => :interval,
91
- 16 => :hugeint,
92
- 32 => :uhugeint,
93
- 17 => :varchar,
94
- 18 => :blob,
95
- 19 => :decimal,
96
- 20 => :timestamp_s,
97
- 21 => :timestamp_ms,
98
- 22 => :timestamp_ns,
99
- 23 => :enum,
100
- 24 => :list,
101
- 25 => :struct,
102
- 26 => :map,
103
- 33 => :array,
104
- 27 => :uuid,
105
- 28 => :union,
106
- 29 => :bit,
107
- 30 => :time_tz,
108
- 31 => :timestamp_tz
109
- }.freeze
110
- end
37
+ HASH_TYPES = {
38
+ 0 => :invalid,
39
+ 1 => :boolean,
40
+ 2 => :tinyint,
41
+ 3 => :smallint,
42
+ 4 => :integer,
43
+ 5 => :bigint,
44
+ 6 => :utinyint,
45
+ 7 => :usmallint,
46
+ 8 => :uinteger,
47
+ 9 => :ubigint,
48
+ 10 => :float,
49
+ 11 => :double,
50
+ 12 => :timestamp,
51
+ 13 => :date,
52
+ 14 => :time,
53
+ 15 => :interval,
54
+ 16 => :hugeint,
55
+ 32 => :uhugeint,
56
+ 17 => :varchar,
57
+ 18 => :blob,
58
+ 19 => :decimal,
59
+ 20 => :timestamp_s,
60
+ 21 => :timestamp_ms,
61
+ 22 => :timestamp_ns,
62
+ 23 => :enum,
63
+ 24 => :list,
64
+ 25 => :struct,
65
+ 26 => :map,
66
+ 33 => :array,
67
+ 27 => :uuid,
68
+ 28 => :union,
69
+ 29 => :bit,
70
+ 30 => :time_tz,
71
+ 31 => :timestamp_tz
72
+ }.freeze
111
73
 
112
74
  module_function
113
75
 
114
- def statement_type_to_sym(val)
76
+ def statement_type_to_sym(val) # :nodoc:
115
77
  raise DuckDB::Error, "Unknown statement type: #{val}" if val >= STATEMENT_TYPES.size
116
78
 
117
79
  STATEMENT_TYPES[val]
118
80
  end
119
81
 
120
- def type_to_sym(val)
82
+ def type_to_sym(val) # :nodoc:
121
83
  raise DuckDB::Error, "Unknown type: #{val}" unless HASH_TYPES.key?(val)
122
84
 
123
85
  HASH_TYPES[val]
@@ -7,7 +7,7 @@ require_relative 'converter/int_to_sym'
7
7
  module DuckDB
8
8
  QueryProgress = Struct.new(:percentage, :rows_processed, :total_rows_to_process)
9
9
 
10
- module Converter
10
+ module Converter # :nodoc: all
11
11
  HALF_HUGEINT_BIT = 64
12
12
  HALF_HUGEINT = 1 << HALF_HUGEINT_BIT
13
13
  FLIP_HUGEINT = 1 << 63
@@ -122,7 +122,7 @@ module DuckDB
122
122
  end
123
123
 
124
124
  def _to_uuid_from_vector(lower, upper)
125
- upper = upper ^ FLIP_HUGEINT
125
+ upper ^= FLIP_HUGEINT
126
126
  upper += HALF_HUGEINT if upper.negative?
127
127
 
128
128
  str = _to_hugeint_from_vector(lower, upper).to_s(16).rjust(32, '0')
data/lib/duckdb/result.rb CHANGED
@@ -34,7 +34,7 @@ module DuckDB
34
34
  raise DuckDB::Error, 'DuckDB::Result cannot be instantiated directly.'
35
35
  end
36
36
 
37
- def use_chunk_each=(value)
37
+ def use_chunk_each=(value) # :nodoc:
38
38
  raise('`changing DuckDB::Result.use_chunk_each to false` was deprecated.') unless value
39
39
 
40
40
  warn('`DuckDB::Result.use_chunk_each=` will be deprecated.')
@@ -42,21 +42,21 @@ module DuckDB
42
42
  true
43
43
  end
44
44
 
45
- def use_chunk_each?
45
+ def use_chunk_each? # :nodoc:
46
46
  warn('`DuckDB::Result.use_chunk_each?` will be deprecated.')
47
47
  true
48
48
  end
49
49
  end
50
50
 
51
- def each
51
+ def each(&)
52
52
  if streaming?
53
53
  return _chunk_stream unless block_given?
54
54
 
55
- _chunk_stream { |row| yield row }
55
+ _chunk_stream(&)
56
56
  else
57
57
  return chunk_each unless block_given?
58
58
 
59
- chunk_each { |row| yield row }
59
+ chunk_each(&)
60
60
  end
61
61
  end
62
62
 
@@ -91,6 +91,14 @@ module DuckDB
91
91
  Converter::IntToSym.statement_type_to_sym(i)
92
92
  end
93
93
 
94
+ # returns all available ENUM type values of the specified column index.
95
+ # require 'duckdb'
96
+ # db = DuckDB::Database.open('duckdb_database')
97
+ # con = db.connect
98
+ # con.execute("CREATE TYPE mood AS ENUM ('sad', 'ok', 'happy', 'π˜ΎπΎΦ…Ι­ 😎')")
99
+ # con.execute("CREATE TABLE enums (id INTEGER, mood mood)")
100
+ # result = con.query('SELECT * FROM enums')
101
+ # result.enum_dictionary_values(1) # => ['sad', 'ok', 'happy', 'π˜ΎπΎΦ…Ι­ 😎']
94
102
  def enum_dictionary_values(col_index)
95
103
  values = []
96
104
  _enum_dictionary_size(col_index).times do |i|
@@ -3,5 +3,5 @@
3
3
  module DuckDB
4
4
  # The version string of ruby-duckdb.
5
5
  # Currently, ruby-duckdb is NOT semantic versioning.
6
- VERSION = '1.1.0.0'
6
+ VERSION = '1.1.1.0'
7
7
  end
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: 1.1.0.0
4
+ version: 1.1.1.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: 2024-09-15 00:00:00.000000000 Z
11
+ date: 2024-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bigdecimal