duckdb 1.0.0.1 → 1.1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test_on_macos.yml +15 -3
- data/.github/workflows/test_on_ubuntu.yml +15 -3
- data/.github/workflows/test_on_windows.yml +2 -2
- data/CHANGELOG.md +64 -1
- data/Dockerfile +2 -2
- data/Gemfile.lock +6 -6
- data/README.md +0 -3
- data/benchmark/async_query.rb +0 -2
- data/benchmark/to_intern_ips.rb +0 -1
- data/duckdb.gemspec +1 -1
- data/ext/duckdb/duckdb.c +4 -0
- data/ext/duckdb/extconf.rb +6 -7
- data/ext/duckdb/pending_result.c +7 -0
- data/ext/duckdb/prepared_statement.c +35 -9
- data/ext/duckdb/result.c +246 -411
- data/ext/duckdb/ruby-duckdb.h +6 -0
- data/lib/duckdb/column.rb +2 -38
- data/lib/duckdb/config.rb +47 -49
- data/lib/duckdb/connection.rb +0 -1
- data/lib/duckdb/converter/int_to_sym.rb +127 -0
- data/lib/duckdb/converter.rb +68 -0
- data/lib/duckdb/database.rb +2 -4
- data/lib/duckdb/infinity.rb +8 -0
- data/lib/duckdb/pending_result.rb +16 -5
- data/lib/duckdb/prepared_statement.rb +29 -2
- data/lib/duckdb/result.rb +39 -78
- data/lib/duckdb/version.rb +1 -1
- data/lib/duckdb.rb +1 -0
- data/sample/async_query.rb +0 -1
- data/sample/async_query_stream.rb +0 -1
- metadata +6 -7
- data/benchmark/to_bigdecimal_ips.rb +0 -16
- data/benchmark/to_hugeint_ips.rb +0 -16
- data/benchmark/to_hugeint_profile.rb +0 -26
data/ext/duckdb/result.c
CHANGED
@@ -13,20 +13,16 @@ static ID id__to_interval_from_vector;
|
|
13
13
|
static ID id__to_hugeint_from_vector;
|
14
14
|
static ID id__to_decimal_from_hugeint;
|
15
15
|
static ID id__to_uuid_from_vector;
|
16
|
+
static ID id__to_time_from_duckdb_timestamp_s;
|
17
|
+
static ID id__to_time_from_duckdb_timestamp_ms;
|
18
|
+
static ID id__to_time_from_duckdb_timestamp_ns;
|
19
|
+
static ID id__to_time_from_duckdb_time_tz;
|
20
|
+
static ID id__to_time_from_duckdb_timestamp_tz;
|
21
|
+
static ID id__to_infinity;
|
16
22
|
|
17
23
|
static void deallocate(void *ctx);
|
18
24
|
static VALUE allocate(VALUE klass);
|
19
25
|
static size_t memsize(const void *p);
|
20
|
-
static VALUE to_ruby_obj_boolean(duckdb_result *result, idx_t col_idx, idx_t row_idx);
|
21
|
-
static VALUE to_ruby_obj_smallint(duckdb_result *result, idx_t col_idx, idx_t row_idx);
|
22
|
-
static VALUE to_ruby_obj_utinyint(duckdb_result *result, idx_t col_idx, idx_t row_idx);
|
23
|
-
static VALUE to_ruby_obj_integer(duckdb_result *result, idx_t col_idx, idx_t row_idx);
|
24
|
-
static VALUE to_ruby_obj_bigint(duckdb_result *result, idx_t col_idx, idx_t row_idx);
|
25
|
-
static VALUE to_ruby_obj_hugeint(duckdb_result *result, idx_t col_idx, idx_t row_idx);
|
26
|
-
static VALUE to_ruby_obj_decimal(duckdb_result *result, idx_t col_idx, idx_t row_idx);
|
27
|
-
static VALUE to_ruby_obj_float(duckdb_result *result, idx_t col_idx, idx_t row_idx);
|
28
|
-
static VALUE to_ruby_obj_double(duckdb_result *result, idx_t col_idx, idx_t row_idx);
|
29
|
-
static VALUE to_ruby_obj_blob(duckdb_result *result, idx_t col_idx, idx_t row_idx);
|
30
26
|
static VALUE duckdb_result_column_count(VALUE oDuckDBResult);
|
31
27
|
static VALUE duckdb_result_row_count(VALUE oDuckDBResult);
|
32
28
|
static VALUE duckdb_result_rows_changed(VALUE oDuckDBResult);
|
@@ -38,23 +34,13 @@ static VALUE duckdb_result_chunk_each(VALUE oDuckDBResult);
|
|
38
34
|
static VALUE duckdb_result__chunk_stream(VALUE oDuckDBResult);
|
39
35
|
static VALUE yield_rows(VALUE arg);
|
40
36
|
static VALUE duckdb_result__column_type(VALUE oDuckDBResult, VALUE col_idx);
|
41
|
-
static VALUE
|
42
|
-
static VALUE
|
43
|
-
static VALUE duckdb_result__to_smallint(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx);
|
44
|
-
static VALUE duckdb_result__to_utinyint(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx);
|
45
|
-
static VALUE duckdb_result__to_integer(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx);
|
46
|
-
static VALUE duckdb_result__to_bigint(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx);
|
47
|
-
static VALUE duckdb_result___to_hugeint_internal(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx);
|
48
|
-
static VALUE duckdb_result___to_decimal_internal(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx);
|
49
|
-
static VALUE duckdb_result__to_float(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx);
|
50
|
-
static VALUE duckdb_result__to_double(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx);
|
51
|
-
static VALUE duckdb_result__to_string(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx);
|
52
|
-
static VALUE duckdb_result__to_string_internal(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx);
|
53
|
-
static VALUE duckdb_result__to_blob(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx);
|
37
|
+
static VALUE duckdb_result__return_type(VALUE oDuckDBResult);
|
38
|
+
static VALUE duckdb_result__statement_type(VALUE oDuckDBResult);
|
54
39
|
static VALUE duckdb_result__enum_internal_type(VALUE oDuckDBResult, VALUE col_idx);
|
55
40
|
static VALUE duckdb_result__enum_dictionary_size(VALUE oDuckDBResult, VALUE col_idx);
|
56
41
|
static VALUE duckdb_result__enum_dictionary_value(VALUE oDuckDBResult, VALUE col_idx, VALUE idx);
|
57
42
|
|
43
|
+
static VALUE infinite_date_value(duckdb_date date);
|
58
44
|
static VALUE vector_date(void *vector_data, idx_t row_idx);
|
59
45
|
static VALUE vector_timestamp(void* vector_data, idx_t row_idx);
|
60
46
|
static VALUE vector_time(void* vector_data, idx_t row_idx);
|
@@ -64,12 +50,20 @@ static VALUE vector_varchar(void* vector_data, idx_t row_idx);
|
|
64
50
|
static VALUE vector_hugeint(void* vector_data, idx_t row_idx);
|
65
51
|
static VALUE vector_uhugeint(void* vector_data, idx_t row_idx);
|
66
52
|
static VALUE vector_decimal(duckdb_logical_type ty, void* vector_data, idx_t row_idx);
|
53
|
+
static VALUE infinite_timestamp_value(duckdb_timestamp timestamp);
|
54
|
+
static VALUE vector_timestamp_s(void* vector_data, idx_t row_idx);
|
55
|
+
static VALUE vector_timestamp_ms(void* vector_data, idx_t row_idx);
|
56
|
+
static VALUE vector_timestamp_ns(void* vector_data, idx_t row_idx);
|
67
57
|
static VALUE vector_enum(duckdb_logical_type ty, void* vector_data, idx_t row_idx);
|
68
58
|
static VALUE vector_array(duckdb_logical_type ty, duckdb_vector vector, idx_t row_idx);
|
69
|
-
static VALUE
|
59
|
+
static VALUE vector_value_at(duckdb_vector vector, duckdb_logical_type element_type, idx_t index);
|
70
60
|
static VALUE vector_list(duckdb_logical_type ty, duckdb_vector vector, void* vector_data, idx_t row_idx);
|
71
|
-
static VALUE vector_map(duckdb_logical_type ty, duckdb_vector vector, idx_t row_idx);
|
61
|
+
static VALUE vector_map(duckdb_logical_type ty, duckdb_vector vector, void* vector_data, idx_t row_idx);
|
72
62
|
static VALUE vector_struct(duckdb_logical_type ty, duckdb_vector vector, idx_t row_idx);
|
63
|
+
static VALUE vector_union(duckdb_logical_type ty, duckdb_vector vector, void* vector_data, idx_t row_idx);
|
64
|
+
static VALUE vector_bit(void* vector_data, idx_t row_idx);
|
65
|
+
static VALUE vector_time_tz(void* vector_data, idx_t row_idx);
|
66
|
+
static VALUE vector_timestamp_tz(void* vector_data, idx_t row_idx);
|
73
67
|
static VALUE vector_uuid(void* vector_data, idx_t row_idx);
|
74
68
|
static VALUE vector_value(duckdb_vector vector, idx_t row_idx);
|
75
69
|
|
@@ -101,114 +95,6 @@ rubyDuckDBResult *get_struct_result(VALUE obj) {
|
|
101
95
|
return ctx;
|
102
96
|
}
|
103
97
|
|
104
|
-
static VALUE to_ruby_obj_boolean(duckdb_result *result, idx_t col_idx, idx_t row_idx) {
|
105
|
-
#ifdef DUCKDB_API_NO_DEPRECATED
|
106
|
-
return Qnil;
|
107
|
-
#else
|
108
|
-
rb_warn("private method `_to_boolean` will be deprecated in the future. Set DuckDB::Result#use_chunk_each to true.");
|
109
|
-
bool bval = duckdb_value_boolean(result, col_idx, row_idx);
|
110
|
-
return bval ? Qtrue : Qfalse;
|
111
|
-
#endif
|
112
|
-
}
|
113
|
-
|
114
|
-
static VALUE to_ruby_obj_smallint(duckdb_result *result, idx_t col_idx, idx_t row_idx) {
|
115
|
-
#ifdef DUCKDB_API_NO_DEPRECATED
|
116
|
-
return Qnil;
|
117
|
-
#else
|
118
|
-
rb_warn("private method `_to_smallint` will be deprecated in the future. Set DuckDB::Result#use_chunk_each to true.");
|
119
|
-
int16_t i16val = duckdb_value_int16(result, col_idx, row_idx);
|
120
|
-
return INT2FIX(i16val);
|
121
|
-
#endif
|
122
|
-
}
|
123
|
-
|
124
|
-
static VALUE to_ruby_obj_utinyint(duckdb_result *result, idx_t col_idx, idx_t row_idx) {
|
125
|
-
#ifdef DUCKDB_API_NO_DEPRECATED
|
126
|
-
return Qnil;
|
127
|
-
#else
|
128
|
-
rb_warn("private method `_to_utinyint` will be deprecated in the future. Set DuckDB::Result#use_chunk_each to true.");
|
129
|
-
uint8_t ui8val = duckdb_value_uint8(result, col_idx, row_idx);
|
130
|
-
return UINT2NUM(ui8val);
|
131
|
-
#endif
|
132
|
-
}
|
133
|
-
|
134
|
-
static VALUE to_ruby_obj_integer(duckdb_result *result, idx_t col_idx, idx_t row_idx) {
|
135
|
-
#ifdef DUCKDB_API_NO_DEPRECATED
|
136
|
-
return Qnil;
|
137
|
-
#else
|
138
|
-
rb_warn("private method `_to_integer` will be deprecated in the future. Set DuckDB::Result#use_chunk_each to true.");
|
139
|
-
int32_t i32val = duckdb_value_int32(result, col_idx, row_idx);
|
140
|
-
return INT2NUM(i32val);
|
141
|
-
#endif
|
142
|
-
}
|
143
|
-
|
144
|
-
static VALUE to_ruby_obj_bigint(duckdb_result *result, idx_t col_idx, idx_t row_idx) {
|
145
|
-
#ifdef DUCKDB_API_NO_DEPRECATED
|
146
|
-
return Qnil;
|
147
|
-
#else
|
148
|
-
rb_warn("private method `_to_bigint` will be deprecated in the future. Set DuckDB::Result#use_chunk_each to true.");
|
149
|
-
int64_t i64val = duckdb_value_int64(result, col_idx, row_idx);
|
150
|
-
return LL2NUM(i64val);
|
151
|
-
#endif
|
152
|
-
}
|
153
|
-
|
154
|
-
static VALUE to_ruby_obj_hugeint(duckdb_result *result, idx_t col_idx, idx_t row_idx) {
|
155
|
-
#ifdef DUCKDB_API_NO_DEPRECATED
|
156
|
-
return Qnil;
|
157
|
-
#else
|
158
|
-
rb_warn("private method `__to_hugeint_internal` will be deprecated in the future. Set DuckDB::Result#use_chunk_each to true.");
|
159
|
-
duckdb_hugeint hugeint = duckdb_value_hugeint(result, col_idx, row_idx);
|
160
|
-
return rb_ary_new3(2, ULL2NUM(hugeint.lower), LL2NUM(hugeint.upper));
|
161
|
-
#endif
|
162
|
-
}
|
163
|
-
|
164
|
-
static VALUE to_ruby_obj_decimal(duckdb_result *result, idx_t col_idx, idx_t row_idx) {
|
165
|
-
#ifdef DUCKDB_API_NO_DEPRECATED
|
166
|
-
return Qnil;
|
167
|
-
#else
|
168
|
-
rb_warn("private method `__to_decimal_internal` will be deprecated in the future. Set DuckDB::Result#use_chunk_each to true.");
|
169
|
-
duckdb_decimal decimal = duckdb_value_decimal(result, col_idx, row_idx);
|
170
|
-
return rb_ary_new3(4, ULL2NUM(decimal.value.lower), LL2NUM(decimal.value.upper), UINT2NUM(decimal.width), UINT2NUM(decimal.scale));
|
171
|
-
#endif
|
172
|
-
}
|
173
|
-
|
174
|
-
static VALUE to_ruby_obj_float(duckdb_result *result, idx_t col_idx, idx_t row_idx) {
|
175
|
-
#ifdef DUCKDB_API_NO_DEPRECATED
|
176
|
-
return Qnil;
|
177
|
-
#else
|
178
|
-
rb_warn("private method `_to_float` will be deprecated in the future. Set DuckDB::Result#use_chunk_each to true.");
|
179
|
-
float fval = duckdb_value_float(result, col_idx, row_idx);
|
180
|
-
return DBL2NUM(fval);
|
181
|
-
#endif
|
182
|
-
}
|
183
|
-
|
184
|
-
static VALUE to_ruby_obj_double(duckdb_result *result, idx_t col_idx, idx_t row_idx) {
|
185
|
-
#ifdef DUCKDB_API_NO_DEPRECATED
|
186
|
-
return Qnil;
|
187
|
-
#else
|
188
|
-
rb_warn("private method `_to_double` will be deprecated in the future. Set DuckDB::Result#use_chunk_each to true.");
|
189
|
-
double dval = duckdb_value_double(result, col_idx, row_idx);
|
190
|
-
return DBL2NUM(dval);
|
191
|
-
#endif
|
192
|
-
}
|
193
|
-
|
194
|
-
static VALUE to_ruby_obj_blob(duckdb_result *result, idx_t col_idx, idx_t row_idx) {
|
195
|
-
|
196
|
-
#ifdef DUCKDB_API_NO_DEPRECATED
|
197
|
-
return Qnil;
|
198
|
-
#else
|
199
|
-
VALUE str;
|
200
|
-
rb_warn("private method `_to_blob` will be deprecated in the future. Set DuckDB::Result#use_chunk_each to true.");
|
201
|
-
duckdb_blob bval = duckdb_value_blob(result, col_idx, row_idx);
|
202
|
-
str = rb_str_new(bval.data, bval.size);
|
203
|
-
|
204
|
-
if (bval.data) {
|
205
|
-
duckdb_free(bval.data);
|
206
|
-
}
|
207
|
-
|
208
|
-
return str;
|
209
|
-
#endif
|
210
|
-
}
|
211
|
-
|
212
98
|
/*
|
213
99
|
* call-seq:
|
214
100
|
* result.rows_changed -> integer
|
@@ -421,128 +307,16 @@ static VALUE duckdb_result__column_type(VALUE oDuckDBResult, VALUE col_idx) {
|
|
421
307
|
return LL2NUM(duckdb_column_type(&(ctx->result), NUM2LL(col_idx)));
|
422
308
|
}
|
423
309
|
|
424
|
-
static VALUE
|
310
|
+
static VALUE duckdb_result__return_type(VALUE oDuckDBResult) {
|
425
311
|
rubyDuckDBResult *ctx;
|
426
|
-
bool is_null;
|
427
|
-
#ifdef DUCKDB_API_NO_DEPRECATED
|
428
|
-
return Qfalse;
|
429
|
-
#else
|
430
|
-
rb_warn("private method `_null?` will be deprecated in the future. Set DuckDB::Result#use_chunk_each to true.");
|
431
312
|
TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
|
432
|
-
|
433
|
-
is_null = duckdb_value_is_null(&(ctx->result), NUM2LL(col_idx), NUM2LL(row_idx));
|
434
|
-
return is_null ? Qtrue : Qfalse;
|
435
|
-
#endif
|
313
|
+
return INT2FIX(duckdb_result_return_type(ctx->result));
|
436
314
|
}
|
437
315
|
|
438
|
-
static VALUE
|
316
|
+
static VALUE duckdb_result__statement_type(VALUE oDuckDBResult) {
|
439
317
|
rubyDuckDBResult *ctx;
|
440
318
|
TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
|
441
|
-
|
442
|
-
return to_ruby_obj_boolean(&(ctx->result), NUM2LL(col_idx), NUM2LL(row_idx)) ? Qtrue : Qfalse;
|
443
|
-
}
|
444
|
-
|
445
|
-
static VALUE duckdb_result__to_smallint(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx) {
|
446
|
-
rubyDuckDBResult *ctx;
|
447
|
-
TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
|
448
|
-
|
449
|
-
return to_ruby_obj_smallint(&(ctx->result), NUM2LL(col_idx), NUM2LL(row_idx));
|
450
|
-
}
|
451
|
-
|
452
|
-
static VALUE duckdb_result__to_utinyint(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx) {
|
453
|
-
rubyDuckDBResult *ctx;
|
454
|
-
TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
|
455
|
-
|
456
|
-
return to_ruby_obj_utinyint(&(ctx->result), NUM2LL(col_idx), NUM2LL(row_idx));
|
457
|
-
}
|
458
|
-
|
459
|
-
static VALUE duckdb_result__to_integer(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx) {
|
460
|
-
rubyDuckDBResult *ctx;
|
461
|
-
TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
|
462
|
-
|
463
|
-
return to_ruby_obj_integer(&(ctx->result), NUM2LL(col_idx), NUM2LL(row_idx));
|
464
|
-
}
|
465
|
-
|
466
|
-
static VALUE duckdb_result__to_bigint(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx) {
|
467
|
-
rubyDuckDBResult *ctx;
|
468
|
-
TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
|
469
|
-
|
470
|
-
return to_ruby_obj_bigint(&(ctx->result), NUM2LL(col_idx), NUM2LL(row_idx));
|
471
|
-
}
|
472
|
-
|
473
|
-
static VALUE duckdb_result___to_hugeint_internal(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx) {
|
474
|
-
rubyDuckDBResult *ctx;
|
475
|
-
TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
|
476
|
-
|
477
|
-
return to_ruby_obj_hugeint(&(ctx->result), NUM2LL(col_idx), NUM2LL(row_idx));
|
478
|
-
}
|
479
|
-
|
480
|
-
static VALUE duckdb_result___to_decimal_internal(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx) {
|
481
|
-
rubyDuckDBResult *ctx;
|
482
|
-
TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
|
483
|
-
|
484
|
-
return to_ruby_obj_decimal(&(ctx->result), NUM2LL(col_idx), NUM2LL(row_idx));
|
485
|
-
}
|
486
|
-
|
487
|
-
static VALUE duckdb_result__to_float(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx) {
|
488
|
-
rubyDuckDBResult *ctx;
|
489
|
-
TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
|
490
|
-
|
491
|
-
return to_ruby_obj_float(&(ctx->result), NUM2LL(col_idx), NUM2LL(row_idx));
|
492
|
-
}
|
493
|
-
|
494
|
-
static VALUE duckdb_result__to_double(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx) {
|
495
|
-
rubyDuckDBResult *ctx;
|
496
|
-
TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
|
497
|
-
|
498
|
-
return to_ruby_obj_double(&(ctx->result), NUM2LL(col_idx), NUM2LL(row_idx));
|
499
|
-
}
|
500
|
-
|
501
|
-
static VALUE duckdb_result__to_string(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx) {
|
502
|
-
rubyDuckDBResult *ctx;
|
503
|
-
duckdb_string p;
|
504
|
-
VALUE obj;
|
505
|
-
|
506
|
-
#ifdef DUCKDB_API_NO_DEPRECATED
|
507
|
-
return Qnil;
|
508
|
-
#else
|
509
|
-
rb_warn("private method `_to_string` will be deprecated in the future. Set DuckDB::Result#use_chunk_each to true.");
|
510
|
-
TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
|
511
|
-
|
512
|
-
p = duckdb_value_string(&(ctx->result), NUM2LL(col_idx), NUM2LL(row_idx));
|
513
|
-
if (p.data) {
|
514
|
-
obj = rb_utf8_str_new(p.data, p.size);
|
515
|
-
duckdb_free(p.data);
|
516
|
-
return obj;
|
517
|
-
}
|
518
|
-
#endif
|
519
|
-
return Qnil;
|
520
|
-
}
|
521
|
-
|
522
|
-
static VALUE duckdb_result__to_string_internal(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx) {
|
523
|
-
rubyDuckDBResult *ctx;
|
524
|
-
duckdb_string p;
|
525
|
-
VALUE obj;
|
526
|
-
#ifdef DUCKDB_API_NO_DEPRECATED
|
527
|
-
// duckdb_value_string_internal will be deprecated in the future.
|
528
|
-
#else
|
529
|
-
rb_warn("private method `_to_string_internal` will be deprecated in the future. Set DuckDB::Result#use_chunk_each to true.");
|
530
|
-
TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
|
531
|
-
|
532
|
-
p = duckdb_value_string_internal(&(ctx->result), NUM2LL(col_idx), NUM2LL(row_idx));
|
533
|
-
if (p.data) {
|
534
|
-
obj = rb_utf8_str_new(p.data, p.size);
|
535
|
-
return obj;
|
536
|
-
}
|
537
|
-
#endif
|
538
|
-
return Qnil;
|
539
|
-
}
|
540
|
-
|
541
|
-
static VALUE duckdb_result__to_blob(VALUE oDuckDBResult, VALUE row_idx, VALUE col_idx) {
|
542
|
-
rubyDuckDBResult *ctx;
|
543
|
-
TypedData_Get_Struct(oDuckDBResult, rubyDuckDBResult, &result_data_type, ctx);
|
544
|
-
|
545
|
-
return to_ruby_obj_blob(&(ctx->result), NUM2LL(col_idx), NUM2LL(row_idx));
|
319
|
+
return INT2FIX(duckdb_result_statement_type(ctx->result));
|
546
320
|
}
|
547
321
|
|
548
322
|
static VALUE duckdb_result__enum_internal_type(VALUE oDuckDBResult, VALUE col_idx) {
|
@@ -596,27 +370,47 @@ VALUE rbduckdb_create_result(void) {
|
|
596
370
|
return allocate(cDuckDBResult);
|
597
371
|
}
|
598
372
|
|
599
|
-
static VALUE
|
600
|
-
|
373
|
+
static VALUE infinite_date_value(duckdb_date date) {
|
374
|
+
if (duckdb_is_finite_date(date) == false) {
|
375
|
+
return rb_funcall(mDuckDBConverter, id__to_infinity, 1,
|
376
|
+
INT2NUM(date.days)
|
377
|
+
);
|
378
|
+
}
|
379
|
+
return Qnil;
|
380
|
+
}
|
601
381
|
|
602
|
-
|
603
|
-
|
604
|
-
|
605
|
-
|
606
|
-
|
382
|
+
static VALUE vector_date(void *vector_data, idx_t row_idx) {
|
383
|
+
duckdb_date date = ((duckdb_date *) vector_data)[row_idx];
|
384
|
+
VALUE obj = infinite_date_value(date);
|
385
|
+
|
386
|
+
if (obj == Qnil) {
|
387
|
+
duckdb_date_struct date_st = duckdb_from_date(date);
|
388
|
+
obj = rb_funcall(mDuckDBConverter, id__to_date, 3,
|
389
|
+
INT2FIX(date_st.year),
|
390
|
+
INT2FIX(date_st.month),
|
391
|
+
INT2FIX(date_st.day)
|
392
|
+
);
|
393
|
+
}
|
394
|
+
return obj;
|
607
395
|
}
|
608
396
|
|
609
397
|
static VALUE vector_timestamp(void* vector_data, idx_t row_idx) {
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
398
|
+
duckdb_timestamp data = ((duckdb_timestamp *)vector_data)[row_idx];
|
399
|
+
VALUE obj = infinite_timestamp_value(data);
|
400
|
+
|
401
|
+
if (obj == Qnil) {
|
402
|
+
duckdb_timestamp_struct data_st = duckdb_from_timestamp(data);
|
403
|
+
return rb_funcall(mDuckDBConverter, id__to_time, 7,
|
404
|
+
INT2FIX(data_st.date.year),
|
405
|
+
INT2FIX(data_st.date.month),
|
406
|
+
INT2FIX(data_st.date.day),
|
407
|
+
INT2FIX(data_st.time.hour),
|
408
|
+
INT2FIX(data_st.time.min),
|
409
|
+
INT2FIX(data_st.time.sec),
|
410
|
+
INT2NUM(data_st.time.micros)
|
411
|
+
);
|
412
|
+
}
|
413
|
+
return obj;
|
620
414
|
}
|
621
415
|
|
622
416
|
static VALUE vector_time(void* vector_data, idx_t row_idx) {
|
@@ -711,6 +505,36 @@ static VALUE vector_decimal(duckdb_logical_type ty, void* vector_data, idx_t row
|
|
711
505
|
);
|
712
506
|
}
|
713
507
|
|
508
|
+
static VALUE infinite_timestamp_value(duckdb_timestamp timestamp) {
|
509
|
+
if (duckdb_is_finite_timestamp(timestamp) == false) {
|
510
|
+
return rb_funcall(mDuckDBConverter, id__to_infinity, 1,
|
511
|
+
LL2NUM(timestamp.micros)
|
512
|
+
);
|
513
|
+
}
|
514
|
+
return Qnil;
|
515
|
+
}
|
516
|
+
|
517
|
+
static VALUE vector_timestamp_s(void* vector_data, idx_t row_idx) {
|
518
|
+
duckdb_timestamp data = ((duckdb_timestamp *)vector_data)[row_idx];
|
519
|
+
return rb_funcall(mDuckDBConverter, id__to_time_from_duckdb_timestamp_s, 1,
|
520
|
+
LL2NUM(data.micros)
|
521
|
+
);
|
522
|
+
}
|
523
|
+
|
524
|
+
static VALUE vector_timestamp_ms(void* vector_data, idx_t row_idx) {
|
525
|
+
duckdb_timestamp data = ((duckdb_timestamp *)vector_data)[row_idx];
|
526
|
+
return rb_funcall(mDuckDBConverter, id__to_time_from_duckdb_timestamp_ms, 1,
|
527
|
+
LL2NUM(data.micros)
|
528
|
+
);
|
529
|
+
}
|
530
|
+
|
531
|
+
static VALUE vector_timestamp_ns(void* vector_data, idx_t row_idx) {
|
532
|
+
duckdb_timestamp data = ((duckdb_timestamp *)vector_data)[row_idx];
|
533
|
+
return rb_funcall(mDuckDBConverter, id__to_time_from_duckdb_timestamp_ns, 1,
|
534
|
+
LL2NUM(data.micros)
|
535
|
+
);
|
536
|
+
}
|
537
|
+
|
714
538
|
static VALUE vector_enum(duckdb_logical_type ty, void* vector_data, idx_t row_idx) {
|
715
539
|
duckdb_type type = duckdb_enum_internal_type(ty);
|
716
540
|
uint8_t index;
|
@@ -744,7 +568,7 @@ static VALUE vector_array(duckdb_logical_type ty, duckdb_vector vector, idx_t ro
|
|
744
568
|
|
745
569
|
ary = rb_ary_new2(size);
|
746
570
|
for (idx_t i = bgn; i < end; ++i) {
|
747
|
-
value =
|
571
|
+
value = vector_value_at(child, child_logical_type, i);
|
748
572
|
rb_ary_store(ary, i - bgn, value);
|
749
573
|
}
|
750
574
|
|
@@ -752,19 +576,19 @@ static VALUE vector_array(duckdb_logical_type ty, duckdb_vector vector, idx_t ro
|
|
752
576
|
return ary;
|
753
577
|
}
|
754
578
|
|
755
|
-
static VALUE
|
579
|
+
static VALUE vector_value_at(duckdb_vector vector, duckdb_logical_type element_type, idx_t index) {
|
756
580
|
uint64_t *validity;
|
757
581
|
duckdb_type type_id;
|
758
582
|
void* vector_data;
|
759
583
|
VALUE obj = Qnil;
|
760
584
|
|
761
|
-
validity = duckdb_vector_get_validity(
|
585
|
+
validity = duckdb_vector_get_validity(vector);
|
762
586
|
if (!duckdb_validity_row_is_valid(validity, index)) {
|
763
587
|
return Qnil;
|
764
588
|
}
|
765
589
|
|
766
590
|
type_id = duckdb_get_type_id(element_type);
|
767
|
-
vector_data = duckdb_vector_get_data(
|
591
|
+
vector_data = duckdb_vector_get_data(vector);
|
768
592
|
|
769
593
|
switch(type_id) {
|
770
594
|
case DUCKDB_TYPE_INVALID:
|
@@ -797,30 +621,30 @@ static VALUE vector_array_value_at(duckdb_vector array, duckdb_logical_type elem
|
|
797
621
|
case DUCKDB_TYPE_UBIGINT:
|
798
622
|
obj = ULL2NUM(((uint64_t *) vector_data)[index]);
|
799
623
|
break;
|
800
|
-
case DUCKDB_TYPE_HUGEINT:
|
801
|
-
obj = vector_hugeint(vector_data, index);
|
802
|
-
break;
|
803
|
-
case DUCKDB_TYPE_UHUGEINT:
|
804
|
-
obj = vector_uhugeint(vector_data, index);
|
805
|
-
break;
|
806
624
|
case DUCKDB_TYPE_FLOAT:
|
807
625
|
obj = DBL2NUM((((float *) vector_data)[index]));
|
808
626
|
break;
|
809
627
|
case DUCKDB_TYPE_DOUBLE:
|
810
628
|
obj = DBL2NUM((((double *) vector_data)[index]));
|
811
629
|
break;
|
812
|
-
case DUCKDB_TYPE_DATE:
|
813
|
-
obj = vector_date(vector_data, index);
|
814
|
-
break;
|
815
630
|
case DUCKDB_TYPE_TIMESTAMP:
|
816
631
|
obj = vector_timestamp(vector_data, index);
|
817
632
|
break;
|
633
|
+
case DUCKDB_TYPE_DATE:
|
634
|
+
obj = vector_date(vector_data, index);
|
635
|
+
break;
|
818
636
|
case DUCKDB_TYPE_TIME:
|
819
637
|
obj = vector_time(vector_data, index);
|
820
638
|
break;
|
821
639
|
case DUCKDB_TYPE_INTERVAL:
|
822
640
|
obj = vector_interval(vector_data, index);
|
823
641
|
break;
|
642
|
+
case DUCKDB_TYPE_HUGEINT:
|
643
|
+
obj = vector_hugeint(vector_data, index);
|
644
|
+
break;
|
645
|
+
case DUCKDB_TYPE_UHUGEINT:
|
646
|
+
obj = vector_uhugeint(vector_data, index);
|
647
|
+
break;
|
824
648
|
case DUCKDB_TYPE_VARCHAR:
|
825
649
|
obj = vector_varchar(vector_data, index);
|
826
650
|
break;
|
@@ -830,24 +654,45 @@ static VALUE vector_array_value_at(duckdb_vector array, duckdb_logical_type elem
|
|
830
654
|
case DUCKDB_TYPE_DECIMAL:
|
831
655
|
obj = vector_decimal(element_type, vector_data, index);
|
832
656
|
break;
|
657
|
+
case DUCKDB_TYPE_TIMESTAMP_S:
|
658
|
+
obj = vector_timestamp_s(vector_data, index);
|
659
|
+
break;
|
660
|
+
case DUCKDB_TYPE_TIMESTAMP_MS:
|
661
|
+
obj = vector_timestamp_ms(vector_data, index);
|
662
|
+
break;
|
663
|
+
case DUCKDB_TYPE_TIMESTAMP_NS:
|
664
|
+
obj = vector_timestamp_ns(vector_data, index);
|
665
|
+
break;
|
833
666
|
case DUCKDB_TYPE_ENUM:
|
834
667
|
obj = vector_enum(element_type, vector_data, index);
|
835
668
|
break;
|
836
|
-
case DUCKDB_TYPE_ARRAY:
|
837
|
-
obj = vector_array(element_type, array, index);
|
838
|
-
break;
|
839
669
|
case DUCKDB_TYPE_LIST:
|
840
|
-
obj = vector_list(element_type,
|
670
|
+
obj = vector_list(element_type, vector, vector_data, index);
|
671
|
+
break;
|
672
|
+
case DUCKDB_TYPE_STRUCT:
|
673
|
+
obj = vector_struct(element_type, vector, index);
|
841
674
|
break;
|
842
675
|
case DUCKDB_TYPE_MAP:
|
843
|
-
obj = vector_map(element_type, vector_data, index);
|
676
|
+
obj = vector_map(element_type, vector, vector_data, index);
|
844
677
|
break;
|
845
|
-
case
|
846
|
-
obj =
|
678
|
+
case DUCKDB_TYPE_ARRAY:
|
679
|
+
obj = vector_array(element_type, vector, index);
|
847
680
|
break;
|
848
681
|
case DUCKDB_TYPE_UUID:
|
849
682
|
obj = vector_uuid(vector_data, index);
|
850
683
|
break;
|
684
|
+
case DUCKDB_TYPE_UNION:
|
685
|
+
obj = vector_union(element_type, vector, vector_data, index);
|
686
|
+
break;
|
687
|
+
case DUCKDB_TYPE_BIT:
|
688
|
+
obj = vector_bit(vector_data, index);
|
689
|
+
break;
|
690
|
+
case DUCKDB_TYPE_TIME_TZ:
|
691
|
+
obj = vector_time_tz(vector_data, index);
|
692
|
+
break;
|
693
|
+
case DUCKDB_TYPE_TIMESTAMP_TZ:
|
694
|
+
obj = vector_timestamp_tz(vector_data, index);
|
695
|
+
break;
|
851
696
|
default:
|
852
697
|
rb_warn("Unknown type %d", type_id);
|
853
698
|
obj = Qnil;
|
@@ -871,26 +716,36 @@ static VALUE vector_list(duckdb_logical_type ty, duckdb_vector vector, void * ve
|
|
871
716
|
duckdb_vector child = duckdb_list_vector_get_child(vector);
|
872
717
|
|
873
718
|
for (i = bgn; i < end; ++i) {
|
874
|
-
value =
|
719
|
+
value = vector_value_at(child, child_logical_type, i);
|
875
720
|
rb_ary_store(ary, i - bgn, value);
|
876
721
|
}
|
877
722
|
duckdb_destroy_logical_type(&child_logical_type);
|
878
723
|
return ary;
|
879
724
|
}
|
880
725
|
|
881
|
-
static VALUE vector_map(duckdb_logical_type ty, duckdb_vector vector, idx_t row_idx) {
|
726
|
+
static VALUE vector_map(duckdb_logical_type ty, duckdb_vector vector, void* vector_data, idx_t row_idx) {
|
882
727
|
VALUE hash = rb_hash_new();
|
728
|
+
VALUE key = Qnil;
|
729
|
+
VALUE value = Qnil;
|
883
730
|
|
884
731
|
duckdb_logical_type key_logical_type = duckdb_map_type_key_type(ty);
|
885
732
|
duckdb_logical_type value_logical_type = duckdb_map_type_value_type(ty);
|
886
|
-
|
887
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
733
|
+
|
734
|
+
duckdb_list_entry list_entry = ((duckdb_list_entry *)vector_data)[row_idx];
|
735
|
+
|
736
|
+
idx_t bgn = list_entry.offset;
|
737
|
+
idx_t end = bgn + list_entry.length;
|
738
|
+
|
739
|
+
duckdb_vector child = duckdb_list_vector_get_child(vector);
|
740
|
+
duckdb_vector key_vector = duckdb_struct_vector_get_child(child, 0);
|
741
|
+
duckdb_vector value_vector = duckdb_struct_vector_get_child(child, 1);
|
742
|
+
|
743
|
+
for (idx_t i = bgn; i < end; ++i) {
|
744
|
+
key = vector_value_at(key_vector, key_logical_type, i);
|
745
|
+
value = vector_value_at(value_vector, value_logical_type, i);
|
746
|
+
rb_hash_aset(hash, key, value);
|
747
|
+
}
|
748
|
+
|
894
749
|
duckdb_destroy_logical_type(&key_logical_type);
|
895
750
|
duckdb_destroy_logical_type(&value_logical_type);
|
896
751
|
return hash;
|
@@ -900,6 +755,8 @@ static VALUE vector_struct(duckdb_logical_type ty, duckdb_vector vector, idx_t r
|
|
900
755
|
VALUE hash = rb_hash_new();
|
901
756
|
VALUE value = Qnil;
|
902
757
|
VALUE key = Qnil;
|
758
|
+
duckdb_vector child;
|
759
|
+
duckdb_logical_type child_type;
|
903
760
|
char *p;
|
904
761
|
|
905
762
|
idx_t child_count = duckdb_struct_type_child_count(ty);
|
@@ -907,13 +764,12 @@ static VALUE vector_struct(duckdb_logical_type ty, duckdb_vector vector, idx_t r
|
|
907
764
|
for (idx_t i = 0; i < child_count; ++i) {
|
908
765
|
p = duckdb_struct_type_child_name(ty, i);
|
909
766
|
if (p) {
|
910
|
-
key =
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
// duckdb_vector child_vector = duckdb_struct_vector_get_child(vector, i);
|
915
|
-
// VALUE value = vector_value(child_vector, i);
|
767
|
+
key = ID2SYM(rb_intern_const(p));
|
768
|
+
child = duckdb_struct_vector_get_child(vector, i);
|
769
|
+
child_type = duckdb_struct_type_child_type(ty, i);
|
770
|
+
value = vector_value_at(child, child_type, row_idx);
|
916
771
|
rb_hash_aset(hash, key, value);
|
772
|
+
duckdb_destroy_logical_type(&child_type);
|
917
773
|
duckdb_free(p);
|
918
774
|
}
|
919
775
|
}
|
@@ -921,6 +777,85 @@ static VALUE vector_struct(duckdb_logical_type ty, duckdb_vector vector, idx_t r
|
|
921
777
|
return hash;
|
922
778
|
}
|
923
779
|
|
780
|
+
static VALUE vector_union(duckdb_logical_type ty, duckdb_vector vector, void* vector_data, idx_t row_idx){
|
781
|
+
VALUE value = Qnil;
|
782
|
+
duckdb_vector type_vector = duckdb_struct_vector_get_child(vector, 0);
|
783
|
+
void *data = duckdb_vector_get_data(type_vector);
|
784
|
+
uint8_t index = ((int8_t *)data)[row_idx];
|
785
|
+
|
786
|
+
duckdb_logical_type child_type = duckdb_union_type_member_type(ty, index);
|
787
|
+
|
788
|
+
duckdb_vector vector_value = duckdb_struct_vector_get_child(vector, index + 1);
|
789
|
+
value = vector_value_at(vector_value, child_type, row_idx);
|
790
|
+
duckdb_destroy_logical_type(&child_type);
|
791
|
+
return value;
|
792
|
+
}
|
793
|
+
|
794
|
+
static VALUE str_concat_byte(VALUE str, unsigned char byte, int offset) {
|
795
|
+
char x[8];
|
796
|
+
char *p = x;
|
797
|
+
for (int j = 7; j >=0; j--) {
|
798
|
+
if (byte % 2 == 1) {
|
799
|
+
x[j] = '1';
|
800
|
+
} else {
|
801
|
+
x[j] = '0';
|
802
|
+
}
|
803
|
+
byte = (byte >> 1);
|
804
|
+
}
|
805
|
+
if (offset > 0 && offset < 8) {
|
806
|
+
p = x + offset;
|
807
|
+
}
|
808
|
+
return rb_str_cat(str, p, 8 - offset);
|
809
|
+
}
|
810
|
+
|
811
|
+
static VALUE bytes_to_string(char *bytes, uint32_t length, int offset) {
|
812
|
+
VALUE str = rb_str_new_literal("");
|
813
|
+
str = str_concat_byte(str, bytes[0], offset);
|
814
|
+
for (uint32_t i = 1; i < length; i++) {
|
815
|
+
str = str_concat_byte(str, bytes[i], 0);
|
816
|
+
}
|
817
|
+
return str;
|
818
|
+
}
|
819
|
+
|
820
|
+
static VALUE vector_bit(void* vector_data, idx_t row_idx) {
|
821
|
+
duckdb_string_t s = (((duckdb_string_t *)vector_data)[row_idx]);
|
822
|
+
char *p;
|
823
|
+
int offset;
|
824
|
+
uint32_t length;
|
825
|
+
VALUE str = Qnil;
|
826
|
+
|
827
|
+
if(duckdb_string_is_inlined(s)) {
|
828
|
+
length = s.value.inlined.length - 1;
|
829
|
+
p = &s.value.inlined.inlined[1];
|
830
|
+
offset = s.value.inlined.inlined[0];
|
831
|
+
str = bytes_to_string(p, length, offset);
|
832
|
+
} else {
|
833
|
+
length = s.value.pointer.length - 1;
|
834
|
+
p = &s.value.pointer.ptr[1];
|
835
|
+
offset = s.value.pointer.ptr[0];
|
836
|
+
str = bytes_to_string(p, length, offset);
|
837
|
+
}
|
838
|
+
return str;
|
839
|
+
}
|
840
|
+
|
841
|
+
static VALUE vector_time_tz(void* vector_data, idx_t row_idx) {
|
842
|
+
duckdb_time_tz_struct data = duckdb_from_time_tz(((duckdb_time_tz *)vector_data)[row_idx]);
|
843
|
+
return rb_funcall(mDuckDBConverter, id__to_time_from_duckdb_time_tz, 5,
|
844
|
+
INT2FIX(data.time.hour),
|
845
|
+
INT2FIX(data.time.min),
|
846
|
+
INT2FIX(data.time.sec),
|
847
|
+
INT2NUM(data.time.micros),
|
848
|
+
INT2NUM(data.offset)
|
849
|
+
);
|
850
|
+
}
|
851
|
+
|
852
|
+
static VALUE vector_timestamp_tz(void* vector_data, idx_t row_idx) {
|
853
|
+
duckdb_time_tz data = ((duckdb_time_tz *)vector_data)[row_idx];
|
854
|
+
return rb_funcall(mDuckDBConverter, id__to_time_from_duckdb_timestamp_tz, 1,
|
855
|
+
ULL2NUM(data.bits)
|
856
|
+
);
|
857
|
+
}
|
858
|
+
|
924
859
|
static VALUE vector_uuid(void* vector_data, idx_t row_idx) {
|
925
860
|
duckdb_hugeint hugeint = ((duckdb_hugeint *)vector_data)[row_idx];
|
926
861
|
return rb_funcall(mDuckDBConverter, id__to_uuid_from_vector, 2,
|
@@ -930,107 +865,12 @@ static VALUE vector_uuid(void* vector_data, idx_t row_idx) {
|
|
930
865
|
}
|
931
866
|
|
932
867
|
static VALUE vector_value(duckdb_vector vector, idx_t row_idx) {
|
933
|
-
uint64_t *validity;
|
934
868
|
duckdb_logical_type ty;
|
935
|
-
duckdb_type type_id;
|
936
|
-
void* vector_data;
|
937
869
|
VALUE obj = Qnil;
|
938
870
|
|
939
|
-
validity = duckdb_vector_get_validity(vector);
|
940
|
-
if (!duckdb_validity_row_is_valid(validity, row_idx)) {
|
941
|
-
return Qnil;
|
942
|
-
}
|
943
|
-
|
944
871
|
ty = duckdb_vector_get_column_type(vector);
|
945
|
-
type_id = duckdb_get_type_id(ty);
|
946
|
-
vector_data = duckdb_vector_get_data(vector);
|
947
872
|
|
948
|
-
|
949
|
-
case DUCKDB_TYPE_INVALID:
|
950
|
-
obj = Qnil;
|
951
|
-
break;
|
952
|
-
case DUCKDB_TYPE_BOOLEAN:
|
953
|
-
obj = (((bool*) vector_data)[row_idx]) ? Qtrue : Qfalse;
|
954
|
-
break;
|
955
|
-
case DUCKDB_TYPE_TINYINT:
|
956
|
-
obj = INT2FIX(((int8_t *) vector_data)[row_idx]);
|
957
|
-
break;
|
958
|
-
case DUCKDB_TYPE_SMALLINT:
|
959
|
-
obj = INT2FIX(((int16_t *) vector_data)[row_idx]);
|
960
|
-
break;
|
961
|
-
case DUCKDB_TYPE_INTEGER:
|
962
|
-
obj = INT2NUM(((int32_t *) vector_data)[row_idx]);
|
963
|
-
break;
|
964
|
-
case DUCKDB_TYPE_BIGINT:
|
965
|
-
obj = LL2NUM(((int64_t *) vector_data)[row_idx]);
|
966
|
-
break;
|
967
|
-
case DUCKDB_TYPE_UTINYINT:
|
968
|
-
obj = INT2FIX(((uint8_t *) vector_data)[row_idx]);
|
969
|
-
break;
|
970
|
-
case DUCKDB_TYPE_USMALLINT:
|
971
|
-
obj = INT2FIX(((uint16_t *) vector_data)[row_idx]);
|
972
|
-
break;
|
973
|
-
case DUCKDB_TYPE_UINTEGER:
|
974
|
-
obj = UINT2NUM(((uint32_t *) vector_data)[row_idx]);
|
975
|
-
break;
|
976
|
-
case DUCKDB_TYPE_UBIGINT:
|
977
|
-
obj = ULL2NUM(((uint64_t *) vector_data)[row_idx]);
|
978
|
-
break;
|
979
|
-
case DUCKDB_TYPE_HUGEINT:
|
980
|
-
obj = vector_hugeint(vector_data, row_idx);
|
981
|
-
break;
|
982
|
-
case DUCKDB_TYPE_UHUGEINT:
|
983
|
-
obj = vector_uhugeint(vector_data, row_idx);
|
984
|
-
break;
|
985
|
-
case DUCKDB_TYPE_FLOAT:
|
986
|
-
obj = DBL2NUM((((float *) vector_data)[row_idx]));
|
987
|
-
break;
|
988
|
-
case DUCKDB_TYPE_DOUBLE:
|
989
|
-
obj = DBL2NUM((((double *) vector_data)[row_idx]));
|
990
|
-
break;
|
991
|
-
case DUCKDB_TYPE_DATE:
|
992
|
-
obj = vector_date(vector_data, row_idx);
|
993
|
-
break;
|
994
|
-
case DUCKDB_TYPE_TIMESTAMP:
|
995
|
-
obj = vector_timestamp(vector_data, row_idx);
|
996
|
-
break;
|
997
|
-
case DUCKDB_TYPE_TIME:
|
998
|
-
obj = vector_time(vector_data, row_idx);
|
999
|
-
break;
|
1000
|
-
case DUCKDB_TYPE_INTERVAL:
|
1001
|
-
obj = vector_interval(vector_data, row_idx);
|
1002
|
-
break;
|
1003
|
-
case DUCKDB_TYPE_VARCHAR:
|
1004
|
-
obj = vector_varchar(vector_data, row_idx);
|
1005
|
-
break;
|
1006
|
-
case DUCKDB_TYPE_BLOB:
|
1007
|
-
obj = vector_blob(vector_data, row_idx);
|
1008
|
-
break;
|
1009
|
-
case DUCKDB_TYPE_DECIMAL:
|
1010
|
-
obj = vector_decimal(ty, vector_data, row_idx);
|
1011
|
-
break;
|
1012
|
-
case DUCKDB_TYPE_ENUM:
|
1013
|
-
obj = vector_enum(ty, vector_data, row_idx);
|
1014
|
-
break;
|
1015
|
-
case DUCKDB_TYPE_ARRAY:
|
1016
|
-
obj = vector_array(ty, vector, row_idx);
|
1017
|
-
break;
|
1018
|
-
case DUCKDB_TYPE_LIST:
|
1019
|
-
obj = vector_list(ty, vector, vector_data, row_idx);
|
1020
|
-
break;
|
1021
|
-
case DUCKDB_TYPE_MAP:
|
1022
|
-
obj = vector_map(ty, vector_data, row_idx);
|
1023
|
-
break;
|
1024
|
-
case DUCKDB_TYPE_STRUCT:
|
1025
|
-
obj = vector_struct(ty, vector_data, row_idx);
|
1026
|
-
break;
|
1027
|
-
case DUCKDB_TYPE_UUID:
|
1028
|
-
obj = vector_uuid(vector_data, row_idx);
|
1029
|
-
break;
|
1030
|
-
default:
|
1031
|
-
rb_warn("Unknown type %d", type_id);
|
1032
|
-
obj = Qnil;
|
1033
|
-
}
|
873
|
+
obj = vector_value_at(vector, ty, row_idx);
|
1034
874
|
|
1035
875
|
duckdb_destroy_logical_type(&ty);
|
1036
876
|
return obj;
|
@@ -1045,6 +885,12 @@ void rbduckdb_init_duckdb_result(void) {
|
|
1045
885
|
id__to_hugeint_from_vector = rb_intern("_to_hugeint_from_vector");
|
1046
886
|
id__to_decimal_from_hugeint = rb_intern("_to_decimal_from_hugeint");
|
1047
887
|
id__to_uuid_from_vector = rb_intern("_to_uuid_from_vector");
|
888
|
+
id__to_time_from_duckdb_timestamp_s = rb_intern("_to_time_from_duckdb_timestamp_s");
|
889
|
+
id__to_time_from_duckdb_timestamp_ms = rb_intern("_to_time_from_duckdb_timestamp_ms");
|
890
|
+
id__to_time_from_duckdb_timestamp_ns = rb_intern("_to_time_from_duckdb_timestamp_ns");
|
891
|
+
id__to_time_from_duckdb_time_tz = rb_intern("_to_time_from_duckdb_time_tz");
|
892
|
+
id__to_time_from_duckdb_timestamp_tz = rb_intern("_to_time_from_duckdb_timestamp_tz");
|
893
|
+
id__to_infinity = rb_intern("_to_infinity");
|
1048
894
|
|
1049
895
|
rb_define_alloc_func(cDuckDBResult, allocate);
|
1050
896
|
|
@@ -1056,20 +902,9 @@ void rbduckdb_init_duckdb_result(void) {
|
|
1056
902
|
rb_define_method(cDuckDBResult, "chunk_each", duckdb_result_chunk_each, 0);
|
1057
903
|
rb_define_private_method(cDuckDBResult, "_chunk_stream", duckdb_result__chunk_stream, 0);
|
1058
904
|
rb_define_private_method(cDuckDBResult, "_column_type", duckdb_result__column_type, 1);
|
905
|
+
rb_define_private_method(cDuckDBResult, "_return_type", duckdb_result__return_type, 0);
|
906
|
+
rb_define_private_method(cDuckDBResult, "_statement_type", duckdb_result__statement_type, 0);
|
1059
907
|
|
1060
|
-
rb_define_private_method(cDuckDBResult, "_null?", duckdb_result__is_null, 2); /* deprecated */
|
1061
|
-
rb_define_private_method(cDuckDBResult, "_to_boolean", duckdb_result__to_boolean, 2); /* deprecated */
|
1062
|
-
rb_define_private_method(cDuckDBResult, "_to_smallint", duckdb_result__to_smallint, 2); /* deprecated */
|
1063
|
-
rb_define_private_method(cDuckDBResult, "_to_utinyint", duckdb_result__to_utinyint, 2); /* deprecated */
|
1064
|
-
rb_define_private_method(cDuckDBResult, "_to_integer", duckdb_result__to_integer, 2); /* deprecated */
|
1065
|
-
rb_define_private_method(cDuckDBResult, "_to_bigint", duckdb_result__to_bigint, 2); /* deprecated */
|
1066
|
-
rb_define_private_method(cDuckDBResult, "__to_hugeint_internal", duckdb_result___to_hugeint_internal, 2); /* deprecated */
|
1067
|
-
rb_define_private_method(cDuckDBResult, "__to_decimal_internal", duckdb_result___to_decimal_internal, 2); /* deprecated */
|
1068
|
-
rb_define_private_method(cDuckDBResult, "_to_float", duckdb_result__to_float, 2); /* deprecated */
|
1069
|
-
rb_define_private_method(cDuckDBResult, "_to_double", duckdb_result__to_double, 2); /* deprecated */
|
1070
|
-
rb_define_private_method(cDuckDBResult, "_to_string", duckdb_result__to_string, 2); /* deprecated */
|
1071
|
-
rb_define_private_method(cDuckDBResult, "_to_string_internal", duckdb_result__to_string_internal, 2); /* deprecated */
|
1072
|
-
rb_define_private_method(cDuckDBResult, "_to_blob", duckdb_result__to_blob, 2); /* deprecated */
|
1073
908
|
rb_define_private_method(cDuckDBResult, "_enum_internal_type", duckdb_result__enum_internal_type, 1);
|
1074
909
|
rb_define_private_method(cDuckDBResult, "_enum_dictionary_size", duckdb_result__enum_dictionary_size, 1);
|
1075
910
|
rb_define_private_method(cDuckDBResult, "_enum_dictionary_value", duckdb_result__enum_dictionary_value, 2);
|