duckdb 0.3.3-dev432.0 → 0.3.3-dev452.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 +166 -10
- package/src/duckdb.hpp +28 -3
- package/src/parquet-amalgamation.cpp +35649 -35649
package/package.json
CHANGED
package/src/duckdb.cpp
CHANGED
|
@@ -44384,6 +44384,9 @@ static bool BlobCastSwitch(Vector &source, Vector &result, idx_t count, string *
|
|
|
44384
44384
|
// blob to varchar
|
|
44385
44385
|
VectorStringCast<string_t, duckdb::CastFromBlob>(source, result, count);
|
|
44386
44386
|
break;
|
|
44387
|
+
case LogicalTypeId::AGGREGATE_STATE:
|
|
44388
|
+
result.Reinterpret(source);
|
|
44389
|
+
break;
|
|
44387
44390
|
default:
|
|
44388
44391
|
return TryVectorNullCast(source, result, count, error_message);
|
|
44389
44392
|
}
|
|
@@ -44572,6 +44575,15 @@ static bool EnumCastSwitch(Vector &source, Vector &result, idx_t count, string *
|
|
|
44572
44575
|
return true;
|
|
44573
44576
|
}
|
|
44574
44577
|
|
|
44578
|
+
static bool AggregateStateToBlobCast(Vector &source, Vector &result, idx_t count, string *error_message, bool strict) {
|
|
44579
|
+
if (result.GetType().id() != LogicalTypeId::BLOB) {
|
|
44580
|
+
throw TypeMismatchException(source.GetType(), result.GetType(),
|
|
44581
|
+
"Cannot cast AGGREGATE_STATE to anything but BLOB");
|
|
44582
|
+
}
|
|
44583
|
+
result.Reinterpret(source);
|
|
44584
|
+
return true;
|
|
44585
|
+
}
|
|
44586
|
+
|
|
44575
44587
|
static bool StructCastSwitch(Vector &source, Vector &result, idx_t count, string *error_message) {
|
|
44576
44588
|
switch (result.GetType().id()) {
|
|
44577
44589
|
case LogicalTypeId::STRUCT:
|
|
@@ -44687,6 +44699,8 @@ bool VectorOperations::TryCast(Vector &source, Vector &result, idx_t count, stri
|
|
|
44687
44699
|
return ListCastSwitch(source, result, count, error_message);
|
|
44688
44700
|
case LogicalTypeId::ENUM:
|
|
44689
44701
|
return EnumCastSwitch(source, result, count, error_message, strict);
|
|
44702
|
+
case LogicalTypeId::AGGREGATE_STATE:
|
|
44703
|
+
return AggregateStateToBlobCast(source, result, count, error_message, strict);
|
|
44690
44704
|
default:
|
|
44691
44705
|
return TryVectorNullCast(source, result, count, error_message);
|
|
44692
44706
|
}
|
|
@@ -69315,6 +69329,10 @@ struct VarianceFun {
|
|
|
69315
69329
|
static void RegisterFunction(BuiltinFunctions &set);
|
|
69316
69330
|
};
|
|
69317
69331
|
|
|
69332
|
+
struct StandardErrorOfTheMeanFun {
|
|
69333
|
+
static void RegisterFunction(BuiltinFunctions &set);
|
|
69334
|
+
};
|
|
69335
|
+
|
|
69318
69336
|
} // namespace duckdb
|
|
69319
69337
|
|
|
69320
69338
|
//===----------------------------------------------------------------------===//
|
|
@@ -69909,6 +69927,20 @@ struct STDDevPopOperation : public STDDevBaseOperation {
|
|
|
69909
69927
|
}
|
|
69910
69928
|
}
|
|
69911
69929
|
};
|
|
69930
|
+
|
|
69931
|
+
struct StandardErrorOfTheMeanOperation : public STDDevBaseOperation {
|
|
69932
|
+
template <class T, class STATE>
|
|
69933
|
+
static void Finalize(Vector &result, FunctionData *, STATE *state, T *target, ValidityMask &mask, idx_t idx) {
|
|
69934
|
+
if (state->count == 0) {
|
|
69935
|
+
mask.SetInvalid(idx);
|
|
69936
|
+
} else {
|
|
69937
|
+
target[idx] = sqrt(state->dsquared / state->count) / sqrt((state->count));
|
|
69938
|
+
if (!Value::DoubleIsValid(target[idx])) {
|
|
69939
|
+
throw OutOfRangeException("SEM is out of range!");
|
|
69940
|
+
}
|
|
69941
|
+
}
|
|
69942
|
+
}
|
|
69943
|
+
};
|
|
69912
69944
|
} // namespace duckdb
|
|
69913
69945
|
|
|
69914
69946
|
//===----------------------------------------------------------------------===//
|
|
@@ -70070,6 +70102,13 @@ void VarianceFun::RegisterFunction(BuiltinFunctions &set) {
|
|
|
70070
70102
|
set.AddFunction(var_samp);
|
|
70071
70103
|
}
|
|
70072
70104
|
|
|
70105
|
+
void StandardErrorOfTheMeanFun::RegisterFunction(BuiltinFunctions &set) {
|
|
70106
|
+
AggregateFunctionSet sem("sem");
|
|
70107
|
+
sem.AddFunction(AggregateFunction::UnaryAggregate<StddevState, double, double, StandardErrorOfTheMeanOperation>(
|
|
70108
|
+
LogicalType::DOUBLE, LogicalType::DOUBLE));
|
|
70109
|
+
set.AddFunction(sem);
|
|
70110
|
+
}
|
|
70111
|
+
|
|
70073
70112
|
} // namespace duckdb
|
|
70074
70113
|
|
|
70075
70114
|
|
|
@@ -70087,7 +70126,7 @@ void BuiltinFunctions::RegisterAlgebraicAggregates() {
|
|
|
70087
70126
|
Register<VarPopFun>();
|
|
70088
70127
|
Register<VarSampFun>();
|
|
70089
70128
|
Register<VarianceFun>();
|
|
70090
|
-
|
|
70129
|
+
Register<StandardErrorOfTheMeanFun>();
|
|
70091
70130
|
Register<Corr>();
|
|
70092
70131
|
}
|
|
70093
70132
|
|
|
@@ -71244,7 +71283,7 @@ struct FirstFunctionString : public FirstFunctionBase {
|
|
|
71244
71283
|
if (!state->is_set || state->is_null) {
|
|
71245
71284
|
mask.SetInvalid(idx);
|
|
71246
71285
|
} else {
|
|
71247
|
-
target[idx] = StringVector::
|
|
71286
|
+
target[idx] = StringVector::AddStringOrBlob(result, state->value);
|
|
71248
71287
|
}
|
|
71249
71288
|
}
|
|
71250
71289
|
|
|
@@ -92902,9 +92941,13 @@ static void AggregateStateCombine(DataChunk &input, ExpressionState &state_p, Ve
|
|
|
92902
92941
|
|
|
92903
92942
|
D_ASSERT(input.data.size() == 2);
|
|
92904
92943
|
D_ASSERT(input.data[0].GetType().id() == LogicalTypeId::AGGREGATE_STATE);
|
|
92905
|
-
D_ASSERT(input.data[0].GetType() == input.data[1].GetType());
|
|
92906
92944
|
D_ASSERT(input.data[0].GetType() == result.GetType());
|
|
92907
92945
|
|
|
92946
|
+
if (input.data[0].GetType().InternalType() != input.data[1].GetType().InternalType()) {
|
|
92947
|
+
throw IOException("Aggregate state combine type mismatch, expect %s, got %s",
|
|
92948
|
+
input.data[0].GetType().ToString(), input.data[1].GetType().ToString());
|
|
92949
|
+
}
|
|
92950
|
+
|
|
92908
92951
|
VectorData state0_data, state1_data;
|
|
92909
92952
|
input.data[0].Orrify(input.size(), state0_data);
|
|
92910
92953
|
input.data[1].Orrify(input.size(), state1_data);
|
|
@@ -92935,8 +92978,10 @@ static void AggregateStateCombine(DataChunk &input, ExpressionState &state_p, Ve
|
|
|
92935
92978
|
}
|
|
92936
92979
|
|
|
92937
92980
|
// we actually have to combine
|
|
92938
|
-
|
|
92939
|
-
|
|
92981
|
+
if (state0.GetSize() != bind_data.state_size || state1.GetSize() != bind_data.state_size) {
|
|
92982
|
+
throw IOException("Aggregate state size mismatch, expect %llu, got %llu and %llu", bind_data.state_size,
|
|
92983
|
+
state0.GetSize(), state1.GetSize());
|
|
92984
|
+
}
|
|
92940
92985
|
|
|
92941
92986
|
memcpy(local_state.state_buffer0.get(), state0.GetDataUnsafe(), bind_data.state_size);
|
|
92942
92987
|
memcpy(local_state.state_buffer1.get(), state1.GetDataUnsafe(), bind_data.state_size);
|
|
@@ -92963,7 +93008,8 @@ static unique_ptr<FunctionData> BindAggregateState(ClientContext &context, Scala
|
|
|
92963
93008
|
throw BinderException("Can only FINALIZE aggregate state, not %s", arg_return_type.ToString());
|
|
92964
93009
|
}
|
|
92965
93010
|
// combine
|
|
92966
|
-
if (arguments.size() == 2 && arguments[0]->return_type != arguments[1]->return_type
|
|
93011
|
+
if (arguments.size() == 2 && arguments[0]->return_type != arguments[1]->return_type &&
|
|
93012
|
+
arguments[1]->return_type.id() != LogicalTypeId::BLOB) {
|
|
92967
93013
|
throw BinderException("Cannot COMBINE aggregate states from different functions, %s <> %s",
|
|
92968
93014
|
arguments[0]->return_type.ToString(), arguments[1]->return_type.ToString());
|
|
92969
93015
|
}
|
|
@@ -93069,7 +93115,7 @@ ScalarFunction ExportAggregateFunction::GetFinalize() {
|
|
|
93069
93115
|
}
|
|
93070
93116
|
|
|
93071
93117
|
ScalarFunction ExportAggregateFunction::GetCombine() {
|
|
93072
|
-
return ScalarFunction("combine", {LogicalTypeId::AGGREGATE_STATE, LogicalTypeId::
|
|
93118
|
+
return ScalarFunction("combine", {LogicalTypeId::AGGREGATE_STATE, LogicalTypeId::ANY},
|
|
93073
93119
|
LogicalTypeId::AGGREGATE_STATE, AggregateStateCombine, false, BindAggregateState, nullptr,
|
|
93074
93120
|
nullptr, InitCombineState);
|
|
93075
93121
|
}
|
|
@@ -100336,6 +100382,7 @@ void BaseAppender::Close() {
|
|
|
100336
100382
|
|
|
100337
100383
|
|
|
100338
100384
|
|
|
100385
|
+
|
|
100339
100386
|
#include <cstring>
|
|
100340
100387
|
#include <cassert>
|
|
100341
100388
|
|
|
@@ -100370,6 +100417,10 @@ duckdb_type ConvertCPPTypeToC(const LogicalType &type);
|
|
|
100370
100417
|
idx_t GetCTypeSize(duckdb_type type);
|
|
100371
100418
|
duckdb_state duckdb_translate_result(MaterializedQueryResult *result, duckdb_result *out);
|
|
100372
100419
|
|
|
100420
|
+
struct DuckDBColumnData {
|
|
100421
|
+
LogicalType type;
|
|
100422
|
+
};
|
|
100423
|
+
|
|
100373
100424
|
} // namespace duckdb
|
|
100374
100425
|
|
|
100375
100426
|
|
|
@@ -100915,6 +100966,8 @@ duckdb_type ConvertCPPTypeToC(const LogicalType &sql_type) {
|
|
|
100915
100966
|
return DUCKDB_TYPE_BLOB;
|
|
100916
100967
|
case LogicalTypeId::INTERVAL:
|
|
100917
100968
|
return DUCKDB_TYPE_INTERVAL;
|
|
100969
|
+
case LogicalTypeId::DECIMAL:
|
|
100970
|
+
return DUCKDB_TYPE_DECIMAL;
|
|
100918
100971
|
default: // LCOV_EXCL_START
|
|
100919
100972
|
D_ASSERT(0);
|
|
100920
100973
|
return DUCKDB_TYPE_INVALID;
|
|
@@ -100958,6 +101011,8 @@ idx_t GetCTypeSize(duckdb_type type) {
|
|
|
100958
101011
|
return sizeof(duckdb_blob);
|
|
100959
101012
|
case DUCKDB_TYPE_INTERVAL:
|
|
100960
101013
|
return sizeof(duckdb_interval);
|
|
101014
|
+
case DUCKDB_TYPE_DECIMAL:
|
|
101015
|
+
return sizeof(duckdb_hugeint);
|
|
100961
101016
|
default: // LCOV_EXCL_START
|
|
100962
101017
|
// unsupported type
|
|
100963
101018
|
D_ASSERT(0);
|
|
@@ -100977,6 +101032,8 @@ void duckdb_free(void *ptr) {
|
|
|
100977
101032
|
|
|
100978
101033
|
|
|
100979
101034
|
|
|
101035
|
+
|
|
101036
|
+
|
|
100980
101037
|
using duckdb::Hugeint;
|
|
100981
101038
|
using duckdb::hugeint_t;
|
|
100982
101039
|
using duckdb::Value;
|
|
@@ -101001,6 +101058,15 @@ duckdb_hugeint duckdb_double_to_hugeint(double val) {
|
|
|
101001
101058
|
return result;
|
|
101002
101059
|
}
|
|
101003
101060
|
|
|
101061
|
+
double duckdb_decimal_to_double(duckdb_decimal val) {
|
|
101062
|
+
double result;
|
|
101063
|
+
hugeint_t value;
|
|
101064
|
+
value.lower = val.value.lower;
|
|
101065
|
+
value.upper = val.value.upper;
|
|
101066
|
+
duckdb::TryCastFromDecimal::Operation<hugeint_t, double>(value, result, nullptr, val.width, val.scale);
|
|
101067
|
+
return result;
|
|
101068
|
+
}
|
|
101069
|
+
|
|
101004
101070
|
|
|
101005
101071
|
|
|
101006
101072
|
|
|
@@ -101238,6 +101304,9 @@ duckdb_state duckdb_translate_result(MaterializedQueryResult *result, duckdb_res
|
|
|
101238
101304
|
// zero initialize the columns (so we can cleanly delete it in case a malloc fails)
|
|
101239
101305
|
memset(out->__deprecated_columns, 0, sizeof(duckdb_column) * out->__deprecated_column_count);
|
|
101240
101306
|
for (idx_t i = 0; i < out->__deprecated_column_count; i++) {
|
|
101307
|
+
auto column_data = new DuckDBColumnData();
|
|
101308
|
+
column_data->type = result->types[i];
|
|
101309
|
+
out->__deprecated_columns[i].internal_data = column_data;
|
|
101241
101310
|
out->__deprecated_columns[i].__deprecated_type = ConvertCPPTypeToC(result->types[i]);
|
|
101242
101311
|
out->__deprecated_columns[i].__deprecated_name = strdup(result->names[i].c_str());
|
|
101243
101312
|
out->__deprecated_columns[i].__deprecated_nullmask =
|
|
@@ -101400,9 +101469,72 @@ duckdb_state duckdb_translate_result(MaterializedQueryResult *result, duckdb_res
|
|
|
101400
101469
|
}
|
|
101401
101470
|
break;
|
|
101402
101471
|
}
|
|
101472
|
+
case LogicalTypeId::DECIMAL: {
|
|
101473
|
+
// get data
|
|
101474
|
+
idx_t row = 0;
|
|
101475
|
+
auto target = (hugeint_t *)out->__deprecated_columns[col].__deprecated_data;
|
|
101476
|
+
switch (result->types[col].InternalType()) {
|
|
101477
|
+
case PhysicalType::INT16: {
|
|
101478
|
+
for (auto &chunk : result->collection.Chunks()) {
|
|
101479
|
+
auto source = FlatVector::GetData<int16_t>(chunk->data[col]);
|
|
101480
|
+
for (idx_t k = 0; k < chunk->size(); k++) {
|
|
101481
|
+
if (!FlatVector::IsNull(chunk->data[col], k)) {
|
|
101482
|
+
target[row].lower = source[k];
|
|
101483
|
+
target[row].upper = 0;
|
|
101484
|
+
}
|
|
101485
|
+
row++;
|
|
101486
|
+
}
|
|
101487
|
+
}
|
|
101488
|
+
break;
|
|
101489
|
+
}
|
|
101490
|
+
case PhysicalType::INT32: {
|
|
101491
|
+
for (auto &chunk : result->collection.Chunks()) {
|
|
101492
|
+
auto source = FlatVector::GetData<int32_t>(chunk->data[col]);
|
|
101493
|
+
for (idx_t k = 0; k < chunk->size(); k++) {
|
|
101494
|
+
if (!FlatVector::IsNull(chunk->data[col], k)) {
|
|
101495
|
+
target[row].lower = source[k];
|
|
101496
|
+
target[row].upper = 0;
|
|
101497
|
+
}
|
|
101498
|
+
row++;
|
|
101499
|
+
}
|
|
101500
|
+
}
|
|
101501
|
+
break;
|
|
101502
|
+
}
|
|
101503
|
+
case PhysicalType::INT64: {
|
|
101504
|
+
for (auto &chunk : result->collection.Chunks()) {
|
|
101505
|
+
auto source = FlatVector::GetData<int64_t>(chunk->data[col]);
|
|
101506
|
+
for (idx_t k = 0; k < chunk->size(); k++) {
|
|
101507
|
+
if (!FlatVector::IsNull(chunk->data[col], k)) {
|
|
101508
|
+
target[row].lower = source[k];
|
|
101509
|
+
target[row].upper = 0;
|
|
101510
|
+
}
|
|
101511
|
+
row++;
|
|
101512
|
+
}
|
|
101513
|
+
}
|
|
101514
|
+
break;
|
|
101515
|
+
}
|
|
101516
|
+
case PhysicalType::INT128: {
|
|
101517
|
+
for (auto &chunk : result->collection.Chunks()) {
|
|
101518
|
+
auto source = FlatVector::GetData<hugeint_t>(chunk->data[col]);
|
|
101519
|
+
for (idx_t k = 0; k < chunk->size(); k++) {
|
|
101520
|
+
if (!FlatVector::IsNull(chunk->data[col], k)) {
|
|
101521
|
+
target[row].lower = source[k].lower;
|
|
101522
|
+
target[row].upper = source[k].upper;
|
|
101523
|
+
}
|
|
101524
|
+
row++;
|
|
101525
|
+
}
|
|
101526
|
+
}
|
|
101527
|
+
break;
|
|
101528
|
+
}
|
|
101529
|
+
default:
|
|
101530
|
+
throw std::runtime_error("Unsupported physical type for Decimal" +
|
|
101531
|
+
TypeIdToString(result->types[col].InternalType()));
|
|
101532
|
+
}
|
|
101533
|
+
break;
|
|
101534
|
+
}
|
|
101403
101535
|
default: // LCOV_EXCL_START
|
|
101404
|
-
|
|
101405
|
-
|
|
101536
|
+
std::string err_msg = "Unsupported type for C API: " + result->types[col].ToString();
|
|
101537
|
+
out->__deprecated_error_message = strdup(err_msg.c_str());
|
|
101406
101538
|
return DuckDBError;
|
|
101407
101539
|
} // LCOV_EXCL_STOP
|
|
101408
101540
|
}
|
|
@@ -101438,6 +101570,10 @@ static void DuckdbDestroyColumn(duckdb_column column, idx_t count) {
|
|
|
101438
101570
|
if (column.__deprecated_name) {
|
|
101439
101571
|
duckdb_free(column.__deprecated_name);
|
|
101440
101572
|
}
|
|
101573
|
+
if (column.internal_data) {
|
|
101574
|
+
auto column_data = (duckdb::DuckDBColumnData *)column.internal_data;
|
|
101575
|
+
delete column_data;
|
|
101576
|
+
}
|
|
101441
101577
|
}
|
|
101442
101578
|
|
|
101443
101579
|
void duckdb_destroy_result(duckdb_result *result) {
|
|
@@ -101652,7 +101788,12 @@ using duckdb::UnsafeFetch;
|
|
|
101652
101788
|
template <class SOURCE_TYPE, class RESULT_TYPE, class OP>
|
|
101653
101789
|
RESULT_TYPE TryCastCInternal(duckdb_result *result, idx_t col, idx_t row) {
|
|
101654
101790
|
RESULT_TYPE result_value;
|
|
101655
|
-
|
|
101791
|
+
try {
|
|
101792
|
+
if (!OP::template Operation<SOURCE_TYPE, RESULT_TYPE>(UnsafeFetch<SOURCE_TYPE>(result, col, row),
|
|
101793
|
+
result_value)) {
|
|
101794
|
+
return FetchDefaultValue::Operation<RESULT_TYPE>();
|
|
101795
|
+
}
|
|
101796
|
+
} catch (...) {
|
|
101656
101797
|
return FetchDefaultValue::Operation<RESULT_TYPE>();
|
|
101657
101798
|
}
|
|
101658
101799
|
return result_value;
|
|
@@ -101704,6 +101845,8 @@ static RESULT_TYPE GetInternalCValue(duckdb_result *result, idx_t col, idx_t row
|
|
|
101704
101845
|
return TryCastCInternal<timestamp_t, RESULT_TYPE, OP>(result, col, row);
|
|
101705
101846
|
case DUCKDB_TYPE_HUGEINT:
|
|
101706
101847
|
return TryCastCInternal<hugeint_t, RESULT_TYPE, OP>(result, col, row);
|
|
101848
|
+
case DUCKDB_TYPE_DECIMAL:
|
|
101849
|
+
return TryCastCInternal<hugeint_t, RESULT_TYPE, OP>(result, col, row);
|
|
101707
101850
|
case DUCKDB_TYPE_INTERVAL:
|
|
101708
101851
|
return TryCastCInternal<interval_t, RESULT_TYPE, OP>(result, col, row);
|
|
101709
101852
|
case DUCKDB_TYPE_VARCHAR:
|
|
@@ -101740,6 +101883,18 @@ int64_t duckdb_value_int64(duckdb_result *result, idx_t col, idx_t row) {
|
|
|
101740
101883
|
return GetInternalCValue<int64_t>(result, col, row);
|
|
101741
101884
|
}
|
|
101742
101885
|
|
|
101886
|
+
duckdb_decimal duckdb_value_decimal(duckdb_result *result, idx_t col, idx_t row) {
|
|
101887
|
+
duckdb_decimal result_value;
|
|
101888
|
+
|
|
101889
|
+
auto column_data = (duckdb::DuckDBColumnData *)result->__deprecated_columns[col].internal_data;
|
|
101890
|
+
column_data->type.GetDecimalProperties(result_value.width, result_value.scale);
|
|
101891
|
+
|
|
101892
|
+
auto internal_value = GetInternalCValue<hugeint_t>(result, col, row);
|
|
101893
|
+
result_value.value.lower = internal_value.lower;
|
|
101894
|
+
result_value.value.upper = internal_value.upper;
|
|
101895
|
+
return result_value;
|
|
101896
|
+
}
|
|
101897
|
+
|
|
101743
101898
|
duckdb_hugeint duckdb_value_hugeint(duckdb_result *result, idx_t col, idx_t row) {
|
|
101744
101899
|
duckdb_hugeint result_value;
|
|
101745
101900
|
auto internal_value = GetInternalCValue<hugeint_t>(result, col, row);
|
|
@@ -101833,6 +101988,7 @@ bool duckdb_value_is_null(duckdb_result *result, idx_t col, idx_t row) {
|
|
|
101833
101988
|
return result->__deprecated_columns[col].__deprecated_nullmask[row];
|
|
101834
101989
|
}
|
|
101835
101990
|
|
|
101991
|
+
|
|
101836
101992
|
//===----------------------------------------------------------------------===//
|
|
101837
101993
|
// DuckDB
|
|
101838
101994
|
//
|
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 "079877f47"
|
|
15
|
+
#define DUCKDB_VERSION "v0.3.3-dev452"
|
|
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
|
//===--------------------------------------------------------------------===//
|