duckdb 0.6.2-dev1092.0 → 0.6.2-dev1097.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/src/function/scalar/math/numeric.cpp +19 -0
- package/src/duckdb/src/function/scalar/math_functions.cpp +1 -0
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/common/vector_operations/generic_executor.hpp +139 -0
- package/src/duckdb/src/include/duckdb/function/scalar/math_functions.hpp +4 -0
package/package.json
CHANGED
|
@@ -846,6 +846,25 @@ void IsNanFun::RegisterFunction(BuiltinFunctions &set) {
|
|
|
846
846
|
set.AddFunction(funcs);
|
|
847
847
|
}
|
|
848
848
|
|
|
849
|
+
//===--------------------------------------------------------------------===//
|
|
850
|
+
// signbit
|
|
851
|
+
//===--------------------------------------------------------------------===//
|
|
852
|
+
struct SignBitOperator {
|
|
853
|
+
template <class TA, class TR>
|
|
854
|
+
static inline TR Operation(TA input) {
|
|
855
|
+
return std::signbit(input);
|
|
856
|
+
}
|
|
857
|
+
};
|
|
858
|
+
|
|
859
|
+
void SignBitFun::RegisterFunction(BuiltinFunctions &set) {
|
|
860
|
+
ScalarFunctionSet funcs("signbit");
|
|
861
|
+
funcs.AddFunction(ScalarFunction({LogicalType::FLOAT}, LogicalType::BOOLEAN,
|
|
862
|
+
ScalarFunction::UnaryFunction<float, bool, SignBitOperator>));
|
|
863
|
+
funcs.AddFunction(ScalarFunction({LogicalType::DOUBLE}, LogicalType::BOOLEAN,
|
|
864
|
+
ScalarFunction::UnaryFunction<double, bool, SignBitOperator>));
|
|
865
|
+
set.AddFunction(funcs);
|
|
866
|
+
}
|
|
867
|
+
|
|
849
868
|
//===--------------------------------------------------------------------===//
|
|
850
869
|
// isinf
|
|
851
870
|
//===--------------------------------------------------------------------===//
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#ifndef DUCKDB_VERSION
|
|
2
|
-
#define DUCKDB_VERSION "0.6.2-
|
|
2
|
+
#define DUCKDB_VERSION "0.6.2-dev1097"
|
|
3
3
|
#endif
|
|
4
4
|
#ifndef DUCKDB_SOURCE_ID
|
|
5
|
-
#define DUCKDB_SOURCE_ID "
|
|
5
|
+
#define DUCKDB_SOURCE_ID "9e64704159"
|
|
6
6
|
#endif
|
|
7
7
|
#include "duckdb/function/table/system_functions.hpp"
|
|
8
8
|
#include "duckdb/main/database.hpp"
|
|
@@ -164,6 +164,56 @@ struct StructTypeTernary {
|
|
|
164
164
|
}
|
|
165
165
|
};
|
|
166
166
|
|
|
167
|
+
template <class A_TYPE, class B_TYPE, class C_TYPE, class D_TYPE>
|
|
168
|
+
struct StructTypeQuaternary {
|
|
169
|
+
A_TYPE a_val;
|
|
170
|
+
B_TYPE b_val;
|
|
171
|
+
C_TYPE c_val;
|
|
172
|
+
D_TYPE d_val;
|
|
173
|
+
|
|
174
|
+
using STRUCT_STATE = StructTypeState<4>;
|
|
175
|
+
|
|
176
|
+
static bool ConstructType(STRUCT_STATE &state, idx_t i,
|
|
177
|
+
StructTypeQuaternary<A_TYPE, B_TYPE, C_TYPE, D_TYPE> &result) {
|
|
178
|
+
auto &a_data = state.child_data[0];
|
|
179
|
+
auto &b_data = state.child_data[1];
|
|
180
|
+
auto &c_data = state.child_data[2];
|
|
181
|
+
auto &d_data = state.child_data[3];
|
|
182
|
+
|
|
183
|
+
auto a_idx = a_data.sel->get_index(i);
|
|
184
|
+
auto b_idx = b_data.sel->get_index(i);
|
|
185
|
+
auto c_idx = c_data.sel->get_index(i);
|
|
186
|
+
auto d_idx = d_data.sel->get_index(i);
|
|
187
|
+
if (!a_data.validity.RowIsValid(a_idx) || !b_data.validity.RowIsValid(b_idx) ||
|
|
188
|
+
!c_data.validity.RowIsValid(c_idx) || !d_data.validity.RowIsValid(d_idx)) {
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
auto a_ptr = (A_TYPE *)a_data.data;
|
|
192
|
+
auto b_ptr = (B_TYPE *)b_data.data;
|
|
193
|
+
auto c_ptr = (C_TYPE *)c_data.data;
|
|
194
|
+
auto d_ptr = (D_TYPE *)d_data.data;
|
|
195
|
+
result.a_val = a_ptr[a_idx];
|
|
196
|
+
result.b_val = b_ptr[b_idx];
|
|
197
|
+
result.c_val = c_ptr[c_idx];
|
|
198
|
+
result.d_val = d_ptr[d_idx];
|
|
199
|
+
return true;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
static void AssignResult(Vector &result, idx_t i, StructTypeQuaternary<A_TYPE, B_TYPE, C_TYPE, D_TYPE> value) {
|
|
203
|
+
auto &entries = StructVector::GetEntries(result);
|
|
204
|
+
|
|
205
|
+
auto a_data = FlatVector::GetData<A_TYPE>(*entries[0]);
|
|
206
|
+
auto b_data = FlatVector::GetData<B_TYPE>(*entries[1]);
|
|
207
|
+
auto c_data = FlatVector::GetData<C_TYPE>(*entries[2]);
|
|
208
|
+
auto d_data = FlatVector::GetData<D_TYPE>(*entries[3]);
|
|
209
|
+
|
|
210
|
+
a_data[i] = value.a_val;
|
|
211
|
+
b_data[i] = value.b_val;
|
|
212
|
+
c_data[i] = value.c_val;
|
|
213
|
+
d_data[i] = value.d_val;
|
|
214
|
+
}
|
|
215
|
+
};
|
|
216
|
+
|
|
167
217
|
//! The GenericExecutor can handle struct types in addition to primitive types
|
|
168
218
|
struct GenericExecutor {
|
|
169
219
|
private:
|
|
@@ -222,6 +272,85 @@ private:
|
|
|
222
272
|
}
|
|
223
273
|
}
|
|
224
274
|
|
|
275
|
+
template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE, class FUNC>
|
|
276
|
+
static void ExecuteTernaryInternal(Vector &a, Vector &b, Vector &c, Vector &result, idx_t count, FUNC &fun) {
|
|
277
|
+
auto constant =
|
|
278
|
+
a.GetVectorType() == VectorType::CONSTANT_VECTOR && b.GetVectorType() == VectorType::CONSTANT_VECTOR;
|
|
279
|
+
|
|
280
|
+
typename A_TYPE::STRUCT_STATE a_state;
|
|
281
|
+
typename B_TYPE::STRUCT_STATE b_state;
|
|
282
|
+
typename C_TYPE::STRUCT_STATE c_state;
|
|
283
|
+
|
|
284
|
+
a_state.PrepareVector(a, count);
|
|
285
|
+
b_state.PrepareVector(b, count);
|
|
286
|
+
c_state.PrepareVector(c, count);
|
|
287
|
+
|
|
288
|
+
for (idx_t i = 0; i < (constant ? 1 : count); i++) {
|
|
289
|
+
auto a_idx = a_state.main_data.sel->get_index(i);
|
|
290
|
+
auto b_idx = a_state.main_data.sel->get_index(i);
|
|
291
|
+
auto c_idx = a_state.main_data.sel->get_index(i);
|
|
292
|
+
if (!a_state.main_data.validity.RowIsValid(a_idx) || !b_state.main_data.validity.RowIsValid(b_idx) ||
|
|
293
|
+
!c_state.main_data.validity.RowIsValid(c_idx)) {
|
|
294
|
+
FlatVector::SetNull(result, i, true);
|
|
295
|
+
continue;
|
|
296
|
+
}
|
|
297
|
+
A_TYPE a_val;
|
|
298
|
+
B_TYPE b_val;
|
|
299
|
+
C_TYPE c_val;
|
|
300
|
+
if (!A_TYPE::ConstructType(a_state, i, a_val) || !B_TYPE::ConstructType(b_state, i, b_val) ||
|
|
301
|
+
!C_TYPE::ConstructType(c_state, i, c_val)) {
|
|
302
|
+
FlatVector::SetNull(result, i, true);
|
|
303
|
+
continue;
|
|
304
|
+
}
|
|
305
|
+
RESULT_TYPE::AssignResult(result, i, fun(a_val, b_val, c_val));
|
|
306
|
+
}
|
|
307
|
+
if (constant) {
|
|
308
|
+
result.SetVectorType(VectorType::CONSTANT_VECTOR);
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
template <class A_TYPE, class B_TYPE, class C_TYPE, class D_TYPE, class RESULT_TYPE, class FUNC>
|
|
313
|
+
static void ExecuteQuaternaryInternal(Vector &a, Vector &b, Vector &c, Vector &d, Vector &result, idx_t count,
|
|
314
|
+
FUNC &fun) {
|
|
315
|
+
auto constant =
|
|
316
|
+
a.GetVectorType() == VectorType::CONSTANT_VECTOR && b.GetVectorType() == VectorType::CONSTANT_VECTOR;
|
|
317
|
+
|
|
318
|
+
typename A_TYPE::STRUCT_STATE a_state;
|
|
319
|
+
typename B_TYPE::STRUCT_STATE b_state;
|
|
320
|
+
typename C_TYPE::STRUCT_STATE c_state;
|
|
321
|
+
typename D_TYPE::STRUCT_STATE d_state;
|
|
322
|
+
|
|
323
|
+
a_state.PrepareVector(a, count);
|
|
324
|
+
b_state.PrepareVector(b, count);
|
|
325
|
+
c_state.PrepareVector(c, count);
|
|
326
|
+
d_state.PrepareVector(d, count);
|
|
327
|
+
|
|
328
|
+
for (idx_t i = 0; i < (constant ? 1 : count); i++) {
|
|
329
|
+
auto a_idx = a_state.main_data.sel->get_index(i);
|
|
330
|
+
auto b_idx = a_state.main_data.sel->get_index(i);
|
|
331
|
+
auto c_idx = a_state.main_data.sel->get_index(i);
|
|
332
|
+
auto d_idx = a_state.main_data.sel->get_index(i);
|
|
333
|
+
if (!a_state.main_data.validity.RowIsValid(a_idx) || !b_state.main_data.validity.RowIsValid(b_idx) ||
|
|
334
|
+
!c_state.main_data.validity.RowIsValid(c_idx) || !d_state.main_data.validity.RowIsValid(d_idx)) {
|
|
335
|
+
FlatVector::SetNull(result, i, true);
|
|
336
|
+
continue;
|
|
337
|
+
}
|
|
338
|
+
A_TYPE a_val;
|
|
339
|
+
B_TYPE b_val;
|
|
340
|
+
C_TYPE c_val;
|
|
341
|
+
D_TYPE d_val;
|
|
342
|
+
if (!A_TYPE::ConstructType(a_state, i, a_val) || !B_TYPE::ConstructType(b_state, i, b_val) ||
|
|
343
|
+
!C_TYPE::ConstructType(c_state, i, c_val) || !D_TYPE::ConstructType(d_state, i, d_val)) {
|
|
344
|
+
FlatVector::SetNull(result, i, true);
|
|
345
|
+
continue;
|
|
346
|
+
}
|
|
347
|
+
RESULT_TYPE::AssignResult(result, i, fun(a_val, b_val, c_val, d_val));
|
|
348
|
+
}
|
|
349
|
+
if (constant) {
|
|
350
|
+
result.SetVectorType(VectorType::CONSTANT_VECTOR);
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
|
|
225
354
|
public:
|
|
226
355
|
template <class A_TYPE, class RESULT_TYPE, class FUNC = std::function<RESULT_TYPE(A_TYPE)>>
|
|
227
356
|
static void ExecuteUnary(Vector &input, Vector &result, idx_t count, FUNC fun) {
|
|
@@ -231,6 +360,16 @@ public:
|
|
|
231
360
|
static void ExecuteBinary(Vector &a, Vector &b, Vector &result, idx_t count, FUNC fun) {
|
|
232
361
|
ExecuteBinaryInternal<A_TYPE, B_TYPE, RESULT_TYPE, FUNC>(a, b, result, count, fun);
|
|
233
362
|
}
|
|
363
|
+
template <class A_TYPE, class B_TYPE, class C_TYPE, class RESULT_TYPE,
|
|
364
|
+
class FUNC = std::function<RESULT_TYPE(A_TYPE)>>
|
|
365
|
+
static void ExecuteTernary(Vector &a, Vector &b, Vector &c, Vector &result, idx_t count, FUNC fun) {
|
|
366
|
+
ExecuteTernaryInternal<A_TYPE, B_TYPE, C_TYPE, RESULT_TYPE, FUNC>(a, b, c, result, count, fun);
|
|
367
|
+
}
|
|
368
|
+
template <class A_TYPE, class B_TYPE, class C_TYPE, class D_TYPE, class RESULT_TYPE,
|
|
369
|
+
class FUNC = std::function<RESULT_TYPE(A_TYPE)>>
|
|
370
|
+
static void ExecuteQuaternary(Vector &a, Vector &b, Vector &c, Vector &d, Vector &result, idx_t count, FUNC fun) {
|
|
371
|
+
ExecuteQuaternaryInternal<A_TYPE, B_TYPE, C_TYPE, D_TYPE, RESULT_TYPE, FUNC>(a, b, c, d, result, count, fun);
|
|
372
|
+
}
|
|
234
373
|
};
|
|
235
374
|
|
|
236
375
|
} // namespace duckdb
|
|
@@ -110,6 +110,10 @@ struct IsNanFun {
|
|
|
110
110
|
static void RegisterFunction(BuiltinFunctions &set);
|
|
111
111
|
};
|
|
112
112
|
|
|
113
|
+
struct SignBitFun {
|
|
114
|
+
static void RegisterFunction(BuiltinFunctions &set);
|
|
115
|
+
};
|
|
116
|
+
|
|
113
117
|
struct IsInfiniteFun {
|
|
114
118
|
static void RegisterFunction(BuiltinFunctions &set);
|
|
115
119
|
};
|