Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
56 commits
Select commit Hold shift + click to select a range
57dc5ec
get error from duckdb when Appender#append_int32 failed.
suketa Jan 17, 2025
ec96ef5
add DuckDB::LogicalType#type
otegami Jan 12, 2025
0582631
Remove an unnecessary test because we explicitly define LogicalType
otegami Jan 12, 2025
0179d3e
Merge pull request #858 from otegami/logical_type_type
suketa Jan 18, 2025
886a4cf
Merge branch 'main' into refactoring_appender
suketa Jan 18, 2025
62dcc79
Merge pull request #859 from suketa/refactoring_appender
suketa Jan 18, 2025
4cc26a7
fix appender rdoc.
suketa Jan 18, 2025
c44ebd8
Merge pull request #860 from suketa/fix_appender_rdoc
suketa Jan 18, 2025
82109e7
try to make documents
suketa Jan 19, 2025
307cd4e
fix directory.
suketa Jan 19, 2025
279373b
fix docs directory.
suketa Jan 19, 2025
0b34233
Merge pull request #861 from suketa/try_to_create_duckdb_documents
suketa Jan 19, 2025
c7d9572
rename filename
suketa Jan 19, 2025
5fd2160
skip bundle install
suketa Jan 19, 2025
14d04b6
Merge pull request #863 from suketa/fix_make_documents_name
suketa Jan 19, 2025
69dcac9
change create published branch
suketa Jan 19, 2025
57396f1
Merge pull request #864 from suketa/change-published-branch
suketa Jan 19, 2025
40e62f9
fix rdoc files
suketa Jan 19, 2025
65f319b
Merge pull request #865 from suketa/fix_deploy_files
suketa Jan 19, 2025
90e633d
setup rdoc options
suketa Jan 19, 2025
7609326
Merge pull request #866 from suketa/rdoc-options
suketa Jan 19, 2025
234eaf5
add documentation url.
suketa Jan 19, 2025
6e6995f
Merge pull request #867 from suketa/add_documentation_url
suketa Jan 19, 2025
ffd7c27
get error message from duckdb when appender_int64 failed.
suketa Jan 24, 2025
7e7f0bc
fix typo
suketa Jan 24, 2025
297adfa
Merge pull request #868 from suketa/refactoring_appender
suketa Jan 24, 2025
3d0e896
fix typo.
suketa Jan 24, 2025
9402183
Merge pull request #869 from suketa/fix_typo
suketa Jan 24, 2025
a1dc64f
change error handling of DuckDB::Appender#append_uint8
suketa Jan 26, 2025
54b3caa
fix type casting
suketa Jan 26, 2025
026695c
remove comment.
suketa Jan 26, 2025
1e2ed8e
Merge pull request #871 from suketa/error_handling_appender
suketa Jan 26, 2025
73632c3
try to fix CI failures.
suketa Jan 26, 2025
6ac22ef
remove redundant connect
suketa Jan 26, 2025
0add4fe
Merge pull request #872 from suketa/try_to_fix_ci_failures
suketa Jan 26, 2025
c60b06c
logical_type: add DuckDB::LogicalType#child_type
otegami Feb 4, 2025
43013b2
add documentation to DuckDB::LogicalType#child_type
otegami Feb 4, 2025
1eaf16f
Merge pull request #874 from otegami/add-list-child-type-to-logical-type
suketa Feb 7, 2025
dacf016
update CHANGELOG.md
suketa Feb 7, 2025
a7ea783
Merge pull request #875 from suketa/logical_type_in_changelog
suketa Feb 7, 2025
c4d5f1f
bump duckdb 1.2.0
suketa Feb 7, 2025
a0a030a
Merge pull request #876 from suketa/bump_duckdb_1.2.0
suketa Feb 8, 2025
a2758d5
DuckDB::Result#row_count is depreacted
suketa Feb 8, 2025
54e9e97
Merge pull request #877 from suketa/deprecate_duckdb_result_row_count
suketa Feb 8, 2025
35e1246
deprecate DuckDB::Result.use_chunk_each, DuckDB::Result.use_chunk_each?
suketa Feb 8, 2025
a131a7c
Merge pull request #878 from suketa/deprecate_result_use_chunk_each
suketa Feb 8, 2025
654b7b5
always use duckdb_fetch_chunk
suketa Feb 8, 2025
d8100e4
Merge pull request #879 from suketa/use_duckdb_fetch_chunk
suketa Feb 9, 2025
777093c
try to ruby-asan test
suketa Jan 24, 2025
1e3b05c
fix some code.
suketa Jan 24, 2025
a602be3
fix memory leak.
suketa Jan 24, 2025
32c33f9
update
suketa Jan 24, 2025
807d3f7
Revert "update"
suketa Jan 24, 2025
57b8b7a
fix the DuckDB::PreparedStatement initialize function.
suketa Jan 25, 2025
88e34f6
use debug build for using asan
otegami Feb 10, 2025
e4f30bc
disable cache
otegami Feb 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions .github/workflows/make_documents.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Deploy RDoc to GitHub Pages

on:
push:
branches:
- main

jobs:
deploy:
name: Build and Deploy RDoc
runs-on: ubuntu-latest

steps:
# リポジトリをクローン
- name: Checkout code
uses: actions/checkout@v3

# Ruby をセットアップ
- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 3.4

# RDoc ドキュメントを生成
- name: Generate RDoc
run: rdoc -o docs

# GitHub Pages 用にデプロイ
- name: Deploy to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: ./docs
71 changes: 71 additions & 0 deletions .github/workflows/ruby_asan_on_ubuntu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Ubuntu

on:
push:
branches:
- main
pull_request:
types:
- opened
- synchronize
- reopened

jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
ruby: ['asan']
duckdb: ['1.1.3', '1.1.1', '1.0.0']

steps:
- uses: actions/checkout@v4

- name: Set up Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby }}

# - name: duckdb cache
# id: duckdb-cache
# uses: actions/cache@v4
# with:
# path: duckdb-v${{ matrix.duckdb }}
# key: ${{ runner.os }}-duckdb-v${{ matrix.duckdb }}

- name: Build duckdb ${{ matrix.duckdb }}
env:
DUCKDB_VERSION: ${{ matrix.duckdb }}
if: steps.duckdb-cache.outputs.cache-hit != 'true'
run: |
git clone -b v$DUCKDB_VERSION https://github.com/cwida/duckdb.git duckdb-tmp-v$DUCKDB_VERSION
cd duckdb-tmp-v$DUCKDB_VERSION && make debug && cd ..
rm -rf duckdb-v$DUCKDB_VERSION
mkdir -p duckdb-v$DUCKDB_VERSION/build/debug/src duckdb-v$DUCKDB_VERSION/src
cp -rip duckdb-tmp-v$DUCKDB_VERSION/build/debug/src/*.so duckdb-v$DUCKDB_VERSION/build/debug/src/
cp -rip duckdb-tmp-v$DUCKDB_VERSION/src/include duckdb-v$DUCKDB_VERSION/src/

- name: bundle install with Ruby ${{ matrix.ruby }}
env:
DUCKDB_VERSION: ${{ matrix.duckdb }}
run: |
bundle install --jobs 4 --retry 3

- name: Build test with DUCKDB_API_NO_DEPRECATED and Ruby ${{ matrix.ruby }}
env:
DUCKDB_VERSION: ${{ matrix.duckdb }}
run: |
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/debug/src/
bundle exec rake clean

- name: Build with Ruby ${{ matrix.ruby }}
env:
DUCKDB_VERSION: ${{ matrix.duckdb }}
run: |
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/debug/src/

- name: test with Ruby ${{ matrix.ruby }}
env:
DUCKDB_VERSION: ${{ matrix.duckdb }}
run: |
env RUBYOPT=-W:deprecated ruby -Ilib test/duckdb_test/ruby_asan_test.rb
2 changes: 1 addition & 1 deletion .github/workflows/test_on_macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
ruby: ['3.1.6', '3.2.6', '3.3.6', '3.4.1', 'head']
duckdb: ['1.1.3', '1.1.1', '1.0.0']
duckdb: ['1.2.0', '1.1.3', '1.1.1', '1.0.0']

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_on_ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
ruby: ['3.1.6', '3.2.6', '3.3.6', '3.4.1', 'head']
duckdb: ['1.1.3', '1.1.1', '1.0.0']
duckdb: ['1.2.0', '1.1.3', '1.1.1', '1.0.0']

steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_on_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
matrix:
ruby: ['3.1.6', '3.2.6', '3.3.6', 'ucrt', 'mingw', 'mswin', 'head']
duckdb: ['1.1.3', '1.1.1', '1.0.0']
duckdb: ['1.2.0', '1.1.3', '1.1.1', '1.0.0']

steps:
- uses: actions/checkout@v4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@
*.so
Makefile
ng_test
/docs/
22 changes: 22 additions & 0 deletions .rdoc_options
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
encoding: UTF-8
static_path: []
rdoc_include: []
charset: UTF-8
exclude:
- "~\\z"
- "\\.orig\\z"
- "\\.rej\\z"
- "\\.bak\\z"
- "\\.gemspec\\z"
- "ext/duckdb/extconf.rb"
- "Gemfile"
- "Gemfile.lock"
- "Rakefile"
- "getduckdb.sh"
- "rdoc.log"
- "tmp"
- "mkmf.log"
- "Dockerfile"
- "bin"
main_page: "README.md"
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,20 @@

All notable changes to this project will be documented in this file.
# Unreleased
- bump duckdb to 1.2.0.
- add `DuckDB::LogicalType` class(Thanks to @otegami).
- `DuckDB::LogicalType` class is under construction. `DuckDB::LogicalType#type`, `DuckDB::LogicalType#width`,
`DuckDB::LogicalType#scale`, `DuckDB::LogicalType#child_type` are available.
- add `DuckDB::Appender#error_message`.
- fix error message when `DuckDB::Appender#flush`, `DuckDB::Appender#close`, `DuckDB::Appender#end_row`,
`DuckDB::Appender#append_bool`, `DuckDB::Appender#append_int8`, `DuckDB::Appender#append_int16` failed.
`DuckDB::Appender#append_bool`, `DuckDB::Appender#append_int8`, `DuckDB::Appender#append_int16`,
`DuckDB::Appender#append_int32`, `DuckDB::Appender#append_int64`, `DuckDB::Appender#append_uint8` failed.
- `DuckDB::Appender#begin_row` does nothing. Only returns self. `DuckDB::Appender#end_row` is only required.

## Breaking changes
- `DuckDB::Result#row_count`, `DuckDB::Result#row_size` are deprecated.
- `DuckDB::Result#use_chunk_each?`, `DuckDB::Result#use_chunk_each=` are deprecated.

# 1.1.3.1 - 2024-11-27
- fix to `DuckDB::Connection#query` with multiple SQL statements. Calling PreparedStatement#destroy after each statement executed.
- install valgrind in docker development environment.
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
ARG RUBY_VERSION=3.3.6
FROM ruby:${RUBY_VERSION}

ARG DUCKDB_VERSION=1.1.3
ARG DUCKDB_VERSION=1.2.0
ARG VALGRIND_VERSION=3.21.0

RUN apt update -qq && \
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ gem install duckdb -- --with-duckdb-include=/duckdb_header_directory --with-duck

## Usage

The followings are some examples, for more detailed information, please refer to the [documentation](https://suketa.github.io/ruby-duckdb/index.html).

```ruby
require 'duckdb'

Expand Down
76 changes: 19 additions & 57 deletions ext/duckdb/appender.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ static VALUE appender_initialize(VALUE klass, VALUE con, VALUE schema, VALUE tab
static VALUE appender_error_message(VALUE self);
static VALUE appender__append_bool(VALUE self, VALUE val);
static VALUE appender__append_int8(VALUE self, VALUE val);
static VALUE appender__apend_int16(VALUE self, VALUE val);
static VALUE appender_append_int32(VALUE self, VALUE val);
static VALUE appender_append_int64(VALUE self, VALUE val);
static VALUE appender_append_uint8(VALUE self, VALUE val);
static VALUE appender__append_int16(VALUE self, VALUE val);
static VALUE appender__append_int32(VALUE self, VALUE val);
static VALUE appender__append_int64(VALUE self, VALUE val);
static VALUE appender__append_uint8(VALUE self, VALUE val);
static VALUE appender_append_uint16(VALUE self, VALUE val);
static VALUE appender_append_uint32(VALUE self, VALUE val);
static VALUE appender_append_uint64(VALUE self, VALUE val);
Expand Down Expand Up @@ -138,7 +138,7 @@ static VALUE appender__append_int8(VALUE self, VALUE val) {
}

/* :nodoc: */
static VALUE appender__apend_int16(VALUE self, VALUE val) {
static VALUE appender__append_int16(VALUE self, VALUE val) {
rubyDuckDBAppender *ctx;
int16_t i16val = (int16_t)NUM2INT(val);

Expand All @@ -147,72 +147,34 @@ static VALUE appender__apend_int16(VALUE self, VALUE val) {
return duckdb_state_to_bool_value(duckdb_append_int16(ctx->appender, i16val));
}

/* call-seq:
* appender.append_int32(val) -> self
*
* Appends an int32(INTEGER) value to the current row in the appender.
*
* require 'duckdb'
* db = DuckDB::Database.open
* con = db.connect
* con.query('CREATE TABLE users (id INTEGER, age INTEGER)')
* appender = con.appender('users')
* appender
* .append_int32(1)
* .append_int32(20)
* .end_row
* .flush
*/
static VALUE appender_append_int32(VALUE self, VALUE val) {
/* :nodoc: */
static VALUE appender__append_int32(VALUE self, VALUE val) {
rubyDuckDBAppender *ctx;
int32_t i32val = (int32_t)NUM2INT(val);

TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);

if (duckdb_append_int32(ctx->appender, i32val) == DuckDBError) {
rb_raise(eDuckDBError, "failed to append int32");
}
return self;
return duckdb_state_to_bool_value(duckdb_append_int32(ctx->appender, i32val));
}

/* call-seq:
* appender.append_int64(val) -> self
*
* Appends an int64(BIGINT) value to the current row in the appender.
*
* require 'duckdb'
* db = DuckDB::Database.open
* con = db.connect
* con.query('CREATE TABLE users (id INTEGER, age BIGINT)')
* appender = con.appender('users')
* appender
* .append_int32(1)
* .append_int64(20)
* .end_row
* .flush
*/
static VALUE appender_append_int64(VALUE self, VALUE val) {
/* :nodoc: */
static VALUE appender__append_int64(VALUE self, VALUE val) {
rubyDuckDBAppender *ctx;
int64_t i64val = (int64_t)NUM2LL(val);

TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);

if (duckdb_append_int64(ctx->appender, i64val) == DuckDBError) {
rb_raise(eDuckDBError, "failed to append int64");
}
return self;
return duckdb_state_to_bool_value(duckdb_append_int64(ctx->appender, i64val));
}

static VALUE appender_append_uint8(VALUE self, VALUE val) {
/* :nodoc: */
static VALUE appender__append_uint8(VALUE self, VALUE val) {
rubyDuckDBAppender *ctx;
int8_t ui8val = (uint8_t)NUM2UINT(val);
uint8_t ui8val = (uint8_t)NUM2UINT(val);

TypedData_Get_Struct(self, rubyDuckDBAppender, &appender_data_type, ctx);

if (duckdb_append_uint8(ctx->appender, ui8val) == DuckDBError) {
rb_raise(eDuckDBError, "failed to append uint8");
}
return self;
return duckdb_state_to_bool_value(duckdb_append_uint8(ctx->appender, ui8val));
}

static VALUE appender_append_uint16(VALUE self, VALUE val) {
Expand Down Expand Up @@ -458,9 +420,6 @@ void rbduckdb_init_duckdb_appender(void) {
rb_define_alloc_func(cDuckDBAppender, allocate);
rb_define_method(cDuckDBAppender, "initialize", appender_initialize, 3);
rb_define_method(cDuckDBAppender, "error_message", appender_error_message, 0);
rb_define_method(cDuckDBAppender, "append_int32", appender_append_int32, 1);
rb_define_method(cDuckDBAppender, "append_int64", appender_append_int64, 1);
rb_define_method(cDuckDBAppender, "append_uint8", appender_append_uint8, 1);
rb_define_method(cDuckDBAppender, "append_uint16", appender_append_uint16, 1);
rb_define_method(cDuckDBAppender, "append_uint32", appender_append_uint32, 1);
rb_define_method(cDuckDBAppender, "append_uint64", appender_append_uint64, 1);
Expand All @@ -480,7 +439,10 @@ void rbduckdb_init_duckdb_appender(void) {
rb_define_private_method(cDuckDBAppender, "_close", appender__close, 0);
rb_define_private_method(cDuckDBAppender, "_append_bool", appender__append_bool, 1);
rb_define_private_method(cDuckDBAppender, "_append_int8", appender__append_int8, 1);
rb_define_private_method(cDuckDBAppender, "_append_int16", appender__apend_int16, 1);
rb_define_private_method(cDuckDBAppender, "_append_int16", appender__append_int16, 1);
rb_define_private_method(cDuckDBAppender, "_append_int32", appender__append_int32, 1);
rb_define_private_method(cDuckDBAppender, "_append_int64", appender__append_int64, 1);
rb_define_private_method(cDuckDBAppender, "_append_uint8", appender__append_uint8, 1);
rb_define_private_method(cDuckDBAppender, "_append_date", appender__append_date, 3);
rb_define_private_method(cDuckDBAppender, "_append_interval", appender__append_interval, 3);
rb_define_private_method(cDuckDBAppender, "_append_time", appender__append_time, 4);
Expand Down
3 changes: 0 additions & 3 deletions ext/duckdb/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,6 @@ def print_message(msg)
# check duckdb >= 1.0.0
have_func('duckdb_fetch_chunk', 'duckdb.h')

# check duckdb >= 1.0.0
have_func('duckdb_fetch_chunk', 'duckdb.h')

# check duckdb >= 1.1.0
have_func('duckdb_result_error_type', 'duckdb.h')

Expand Down
Loading
Loading