duckdb 0.3.3-dev432.0 → 0.3.3-dev440.0
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.
- package/package.json +1 -1
- package/src/duckdb.cpp +113 -3
- package/src/duckdb.hpp +28 -3
- package/src/parquet-amalgamation.cpp +36571 -36571
package/package.json
CHANGED
package/src/duckdb.cpp
CHANGED
|
@@ -100336,6 +100336,7 @@ void BaseAppender::Close() {
|
|
|
100336
100336
|
|
|
100337
100337
|
|
|
100338
100338
|
|
|
100339
|
+
|
|
100339
100340
|
#include <cstring>
|
|
100340
100341
|
#include <cassert>
|
|
100341
100342
|
|
|
@@ -100370,6 +100371,10 @@ duckdb_type ConvertCPPTypeToC(const LogicalType &type);
|
|
|
100370
100371
|
idx_t GetCTypeSize(duckdb_type type);
|
|
100371
100372
|
duckdb_state duckdb_translate_result(MaterializedQueryResult *result, duckdb_result *out);
|
|
100372
100373
|
|
|
100374
|
+
struct DuckDBColumnData {
|
|
100375
|
+
LogicalType type;
|
|
100376
|
+
};
|
|
100377
|
+
|
|
100373
100378
|
} // namespace duckdb
|
|
100374
100379
|
|
|
100375
100380
|
|
|
@@ -100915,6 +100920,8 @@ duckdb_type ConvertCPPTypeToC(const LogicalType &sql_type) {
|
|
|
100915
100920
|
return DUCKDB_TYPE_BLOB;
|
|
100916
100921
|
case LogicalTypeId::INTERVAL:
|
|
100917
100922
|
return DUCKDB_TYPE_INTERVAL;
|
|
100923
|
+
case LogicalTypeId::DECIMAL:
|
|
100924
|
+
return DUCKDB_TYPE_DECIMAL;
|
|
100918
100925
|
default: // LCOV_EXCL_START
|
|
100919
100926
|
D_ASSERT(0);
|
|
100920
100927
|
return DUCKDB_TYPE_INVALID;
|
|
@@ -100958,6 +100965,8 @@ idx_t GetCTypeSize(duckdb_type type) {
|
|
|
100958
100965
|
return sizeof(duckdb_blob);
|
|
100959
100966
|
case DUCKDB_TYPE_INTERVAL:
|
|
100960
100967
|
return sizeof(duckdb_interval);
|
|
100968
|
+
case DUCKDB_TYPE_DECIMAL:
|
|
100969
|
+
return sizeof(duckdb_hugeint);
|
|
100961
100970
|
default: // LCOV_EXCL_START
|
|
100962
100971
|
// unsupported type
|
|
100963
100972
|
D_ASSERT(0);
|
|
@@ -100977,6 +100986,8 @@ void duckdb_free(void *ptr) {
|
|
|
100977
100986
|
|
|
100978
100987
|
|
|
100979
100988
|
|
|
100989
|
+
|
|
100990
|
+
|
|
100980
100991
|
using duckdb::Hugeint;
|
|
100981
100992
|
using duckdb::hugeint_t;
|
|
100982
100993
|
using duckdb::Value;
|
|
@@ -101001,6 +101012,15 @@ duckdb_hugeint duckdb_double_to_hugeint(double val) {
|
|
|
101001
101012
|
return result;
|
|
101002
101013
|
}
|
|
101003
101014
|
|
|
101015
|
+
double duckdb_decimal_to_double(duckdb_decimal val) {
|
|
101016
|
+
double result;
|
|
101017
|
+
hugeint_t value;
|
|
101018
|
+
value.lower = val.value.lower;
|
|
101019
|
+
value.upper = val.value.upper;
|
|
101020
|
+
duckdb::TryCastFromDecimal::Operation<hugeint_t, double>(value, result, nullptr, val.width, val.scale);
|
|
101021
|
+
return result;
|
|
101022
|
+
}
|
|
101023
|
+
|
|
101004
101024
|
|
|
101005
101025
|
|
|
101006
101026
|
|
|
@@ -101238,6 +101258,9 @@ duckdb_state duckdb_translate_result(MaterializedQueryResult *result, duckdb_res
|
|
|
101238
101258
|
// zero initialize the columns (so we can cleanly delete it in case a malloc fails)
|
|
101239
101259
|
memset(out->__deprecated_columns, 0, sizeof(duckdb_column) * out->__deprecated_column_count);
|
|
101240
101260
|
for (idx_t i = 0; i < out->__deprecated_column_count; i++) {
|
|
101261
|
+
auto column_data = new DuckDBColumnData();
|
|
101262
|
+
column_data->type = result->types[i];
|
|
101263
|
+
out->__deprecated_columns[i].internal_data = column_data;
|
|
101241
101264
|
out->__deprecated_columns[i].__deprecated_type = ConvertCPPTypeToC(result->types[i]);
|
|
101242
101265
|
out->__deprecated_columns[i].__deprecated_name = strdup(result->names[i].c_str());
|
|
101243
101266
|
out->__deprecated_columns[i].__deprecated_nullmask =
|
|
@@ -101400,9 +101423,72 @@ duckdb_state duckdb_translate_result(MaterializedQueryResult *result, duckdb_res
|
|
|
101400
101423
|
}
|
|
101401
101424
|
break;
|
|
101402
101425
|
}
|
|
101426
|
+
case LogicalTypeId::DECIMAL: {
|
|
101427
|
+
// get data
|
|
101428
|
+
idx_t row = 0;
|
|
101429
|
+
auto target = (hugeint_t *)out->__deprecated_columns[col].__deprecated_data;
|
|
101430
|
+
switch (result->types[col].InternalType()) {
|
|
101431
|
+
case PhysicalType::INT16: {
|
|
101432
|
+
for (auto &chunk : result->collection.Chunks()) {
|
|
101433
|
+
auto source = FlatVector::GetData<int16_t>(chunk->data[col]);
|
|
101434
|
+
for (idx_t k = 0; k < chunk->size(); k++) {
|
|
101435
|
+
if (!FlatVector::IsNull(chunk->data[col], k)) {
|
|
101436
|
+
target[row].lower = source[k];
|
|
101437
|
+
target[row].upper = 0;
|
|
101438
|
+
}
|
|
101439
|
+
row++;
|
|
101440
|
+
}
|
|
101441
|
+
}
|
|
101442
|
+
break;
|
|
101443
|
+
}
|
|
101444
|
+
case PhysicalType::INT32: {
|
|
101445
|
+
for (auto &chunk : result->collection.Chunks()) {
|
|
101446
|
+
auto source = FlatVector::GetData<int32_t>(chunk->data[col]);
|
|
101447
|
+
for (idx_t k = 0; k < chunk->size(); k++) {
|
|
101448
|
+
if (!FlatVector::IsNull(chunk->data[col], k)) {
|
|
101449
|
+
target[row].lower = source[k];
|
|
101450
|
+
target[row].upper = 0;
|
|
101451
|
+
}
|
|
101452
|
+
row++;
|
|
101453
|
+
}
|
|
101454
|
+
}
|
|
101455
|
+
break;
|
|
101456
|
+
}
|
|
101457
|
+
case PhysicalType::INT64: {
|
|
101458
|
+
for (auto &chunk : result->collection.Chunks()) {
|
|
101459
|
+
auto source = FlatVector::GetData<int64_t>(chunk->data[col]);
|
|
101460
|
+
for (idx_t k = 0; k < chunk->size(); k++) {
|
|
101461
|
+
if (!FlatVector::IsNull(chunk->data[col], k)) {
|
|
101462
|
+
target[row].lower = source[k];
|
|
101463
|
+
target[row].upper = 0;
|
|
101464
|
+
}
|
|
101465
|
+
row++;
|
|
101466
|
+
}
|
|
101467
|
+
}
|
|
101468
|
+
break;
|
|
101469
|
+
}
|
|
101470
|
+
case PhysicalType::INT128: {
|
|
101471
|
+
for (auto &chunk : result->collection.Chunks()) {
|
|
101472
|
+
auto source = FlatVector::GetData<hugeint_t>(chunk->data[col]);
|
|
101473
|
+
for (idx_t k = 0; k < chunk->size(); k++) {
|
|
101474
|
+
if (!FlatVector::IsNull(chunk->data[col], k)) {
|
|
101475
|
+
target[row].lower = source[k].lower;
|
|
101476
|
+
target[row].upper = source[k].upper;
|
|
101477
|
+
}
|
|
101478
|
+
row++;
|
|
101479
|
+
}
|
|
101480
|
+
}
|
|
101481
|
+
break;
|
|
101482
|
+
}
|
|
101483
|
+
default:
|
|
101484
|
+
throw std::runtime_error("Unsupported physical type for Decimal" +
|
|
101485
|
+
TypeIdToString(result->types[col].InternalType()));
|
|
101486
|
+
}
|
|
101487
|
+
break;
|
|
101488
|
+
}
|
|
101403
101489
|
default: // LCOV_EXCL_START
|
|
101404
|
-
|
|
101405
|
-
|
|
101490
|
+
std::string err_msg = "Unsupported type for C API: " + result->types[col].ToString();
|
|
101491
|
+
out->__deprecated_error_message = strdup(err_msg.c_str());
|
|
101406
101492
|
return DuckDBError;
|
|
101407
101493
|
} // LCOV_EXCL_STOP
|
|
101408
101494
|
}
|
|
@@ -101438,6 +101524,10 @@ static void DuckdbDestroyColumn(duckdb_column column, idx_t count) {
|
|
|
101438
101524
|
if (column.__deprecated_name) {
|
|
101439
101525
|
duckdb_free(column.__deprecated_name);
|
|
101440
101526
|
}
|
|
101527
|
+
if (column.internal_data) {
|
|
101528
|
+
auto column_data = (duckdb::DuckDBColumnData *)column.internal_data;
|
|
101529
|
+
delete column_data;
|
|
101530
|
+
}
|
|
101441
101531
|
}
|
|
101442
101532
|
|
|
101443
101533
|
void duckdb_destroy_result(duckdb_result *result) {
|
|
@@ -101652,7 +101742,12 @@ using duckdb::UnsafeFetch;
|
|
|
101652
101742
|
template <class SOURCE_TYPE, class RESULT_TYPE, class OP>
|
|
101653
101743
|
RESULT_TYPE TryCastCInternal(duckdb_result *result, idx_t col, idx_t row) {
|
|
101654
101744
|
RESULT_TYPE result_value;
|
|
101655
|
-
|
|
101745
|
+
try {
|
|
101746
|
+
if (!OP::template Operation<SOURCE_TYPE, RESULT_TYPE>(UnsafeFetch<SOURCE_TYPE>(result, col, row),
|
|
101747
|
+
result_value)) {
|
|
101748
|
+
return FetchDefaultValue::Operation<RESULT_TYPE>();
|
|
101749
|
+
}
|
|
101750
|
+
} catch (...) {
|
|
101656
101751
|
return FetchDefaultValue::Operation<RESULT_TYPE>();
|
|
101657
101752
|
}
|
|
101658
101753
|
return result_value;
|
|
@@ -101704,6 +101799,8 @@ static RESULT_TYPE GetInternalCValue(duckdb_result *result, idx_t col, idx_t row
|
|
|
101704
101799
|
return TryCastCInternal<timestamp_t, RESULT_TYPE, OP>(result, col, row);
|
|
101705
101800
|
case DUCKDB_TYPE_HUGEINT:
|
|
101706
101801
|
return TryCastCInternal<hugeint_t, RESULT_TYPE, OP>(result, col, row);
|
|
101802
|
+
case DUCKDB_TYPE_DECIMAL:
|
|
101803
|
+
return TryCastCInternal<hugeint_t, RESULT_TYPE, OP>(result, col, row);
|
|
101707
101804
|
case DUCKDB_TYPE_INTERVAL:
|
|
101708
101805
|
return TryCastCInternal<interval_t, RESULT_TYPE, OP>(result, col, row);
|
|
101709
101806
|
case DUCKDB_TYPE_VARCHAR:
|
|
@@ -101740,6 +101837,18 @@ int64_t duckdb_value_int64(duckdb_result *result, idx_t col, idx_t row) {
|
|
|
101740
101837
|
return GetInternalCValue<int64_t>(result, col, row);
|
|
101741
101838
|
}
|
|
101742
101839
|
|
|
101840
|
+
duckdb_decimal duckdb_value_decimal(duckdb_result *result, idx_t col, idx_t row) {
|
|
101841
|
+
duckdb_decimal result_value;
|
|
101842
|
+
|
|
101843
|
+
auto column_data = (duckdb::DuckDBColumnData *)result->__deprecated_columns[col].internal_data;
|
|
101844
|
+
column_data->type.GetDecimalProperties(result_value.width, result_value.scale);
|
|
101845
|
+
|
|
101846
|
+
auto internal_value = GetInternalCValue<hugeint_t>(result, col, row);
|
|
101847
|
+
result_value.value.lower = internal_value.lower;
|
|
101848
|
+
result_value.value.upper = internal_value.upper;
|
|
101849
|
+
return result_value;
|
|
101850
|
+
}
|
|
101851
|
+
|
|
101743
101852
|
duckdb_hugeint duckdb_value_hugeint(duckdb_result *result, idx_t col, idx_t row) {
|
|
101744
101853
|
duckdb_hugeint result_value;
|
|
101745
101854
|
auto internal_value = GetInternalCValue<hugeint_t>(result, col, row);
|
|
@@ -101833,6 +101942,7 @@ bool duckdb_value_is_null(duckdb_result *result, idx_t col, idx_t row) {
|
|
|
101833
101942
|
return result->__deprecated_columns[col].__deprecated_nullmask[row];
|
|
101834
101943
|
}
|
|
101835
101944
|
|
|
101945
|
+
|
|
101836
101946
|
//===----------------------------------------------------------------------===//
|
|
101837
101947
|
// DuckDB
|
|
101838
101948
|
//
|
package/src/duckdb.hpp
CHANGED
|
@@ -11,8 +11,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
11
11
|
#pragma once
|
|
12
12
|
#define DUCKDB_AMALGAMATION 1
|
|
13
13
|
#define DUCKDB_AMALGAMATION_EXTENDED 1
|
|
14
|
-
#define DUCKDB_SOURCE_ID "
|
|
15
|
-
#define DUCKDB_VERSION "v0.3.3-
|
|
14
|
+
#define DUCKDB_SOURCE_ID "f7a783d93"
|
|
15
|
+
#define DUCKDB_VERSION "v0.3.3-dev440"
|
|
16
16
|
//===----------------------------------------------------------------------===//
|
|
17
17
|
// DuckDB
|
|
18
18
|
//
|
|
@@ -12070,7 +12070,9 @@ typedef enum DUCKDB_TYPE {
|
|
|
12070
12070
|
// const char*
|
|
12071
12071
|
DUCKDB_TYPE_VARCHAR,
|
|
12072
12072
|
// duckdb_blob
|
|
12073
|
-
DUCKDB_TYPE_BLOB
|
|
12073
|
+
DUCKDB_TYPE_BLOB,
|
|
12074
|
+
// decimal
|
|
12075
|
+
DUCKDB_TYPE_DECIMAL
|
|
12074
12076
|
} duckdb_type;
|
|
12075
12077
|
|
|
12076
12078
|
//! Days are stored as days since 1970-01-01
|
|
@@ -12123,6 +12125,13 @@ typedef struct {
|
|
|
12123
12125
|
int64_t upper;
|
|
12124
12126
|
} duckdb_hugeint;
|
|
12125
12127
|
|
|
12128
|
+
typedef struct {
|
|
12129
|
+
uint8_t width;
|
|
12130
|
+
uint8_t scale;
|
|
12131
|
+
|
|
12132
|
+
duckdb_hugeint value;
|
|
12133
|
+
} duckdb_decimal;
|
|
12134
|
+
|
|
12126
12135
|
typedef struct {
|
|
12127
12136
|
void *data;
|
|
12128
12137
|
idx_t size;
|
|
@@ -12457,6 +12466,11 @@ DUCKDB_API int64_t duckdb_value_int64(duckdb_result *result, idx_t col, idx_t ro
|
|
|
12457
12466
|
*/
|
|
12458
12467
|
DUCKDB_API duckdb_hugeint duckdb_value_hugeint(duckdb_result *result, idx_t col, idx_t row);
|
|
12459
12468
|
|
|
12469
|
+
/*!
|
|
12470
|
+
* returns: The duckdb_decimal value at the specified location, or 0 if the value cannot be converted.
|
|
12471
|
+
*/
|
|
12472
|
+
DUCKDB_API duckdb_decimal duckdb_value_decimal(duckdb_result *result, idx_t col, idx_t row);
|
|
12473
|
+
|
|
12460
12474
|
/*!
|
|
12461
12475
|
* returns: The uint8_t value at the specified location, or 0 if the value cannot be converted.
|
|
12462
12476
|
*/
|
|
@@ -12623,6 +12637,17 @@ If the conversion fails because the double value is too big the result will be 0
|
|
|
12623
12637
|
*/
|
|
12624
12638
|
DUCKDB_API duckdb_hugeint duckdb_double_to_hugeint(double val);
|
|
12625
12639
|
|
|
12640
|
+
//===--------------------------------------------------------------------===//
|
|
12641
|
+
// Decimal Helpers
|
|
12642
|
+
//===--------------------------------------------------------------------===//
|
|
12643
|
+
/*!
|
|
12644
|
+
Converts a duckdb_decimal object (as obtained from a `DUCKDB_TYPE_DECIMAL` column) into a double.
|
|
12645
|
+
|
|
12646
|
+
* val: The decimal value.
|
|
12647
|
+
* returns: The converted `double` element.
|
|
12648
|
+
*/
|
|
12649
|
+
DUCKDB_API double duckdb_decimal_to_double(duckdb_decimal val);
|
|
12650
|
+
|
|
12626
12651
|
//===--------------------------------------------------------------------===//
|
|
12627
12652
|
// Prepared Statements
|
|
12628
12653
|
//===--------------------------------------------------------------------===//
|