duckdb 0.3.2-dev362.0 → 0.3.2-dev396.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 +540 -42
- package/src/duckdb.hpp +67 -45
package/src/duckdb.hpp
CHANGED
|
@@ -10,8 +10,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
10
10
|
|
|
11
11
|
#pragma once
|
|
12
12
|
#define DUCKDB_AMALGAMATION 1
|
|
13
|
-
#define DUCKDB_SOURCE_ID "
|
|
14
|
-
#define DUCKDB_VERSION "0.3.2-
|
|
13
|
+
#define DUCKDB_SOURCE_ID "1c3a65a94"
|
|
14
|
+
#define DUCKDB_VERSION "0.3.2-dev396"
|
|
15
15
|
//===----------------------------------------------------------------------===//
|
|
16
16
|
// DuckDB
|
|
17
17
|
//
|
|
@@ -916,6 +916,9 @@ enum class LogicalTypeId : uint8_t {
|
|
|
916
916
|
USMALLINT = 29,
|
|
917
917
|
UINTEGER = 30,
|
|
918
918
|
UBIGINT = 31,
|
|
919
|
+
TIMESTAMP_TZ = 32,
|
|
920
|
+
DATE_TZ = 33,
|
|
921
|
+
TIME_TZ = 34,
|
|
919
922
|
|
|
920
923
|
|
|
921
924
|
HUGEINT = 50,
|
|
@@ -1016,6 +1019,9 @@ public:
|
|
|
1016
1019
|
static constexpr const LogicalTypeId TIMESTAMP_MS = LogicalTypeId::TIMESTAMP_MS;
|
|
1017
1020
|
static constexpr const LogicalTypeId TIMESTAMP_NS = LogicalTypeId::TIMESTAMP_NS;
|
|
1018
1021
|
static constexpr const LogicalTypeId TIME = LogicalTypeId::TIME;
|
|
1022
|
+
static constexpr const LogicalTypeId TIMESTAMP_TZ = LogicalTypeId::TIMESTAMP_TZ;
|
|
1023
|
+
static constexpr const LogicalTypeId DATE_TZ = LogicalTypeId::DATE_TZ;
|
|
1024
|
+
static constexpr const LogicalTypeId TIME_TZ = LogicalTypeId::TIME_TZ;
|
|
1019
1025
|
static constexpr const LogicalTypeId VARCHAR = LogicalTypeId::VARCHAR;
|
|
1020
1026
|
static constexpr const LogicalTypeId ANY = LogicalTypeId::ANY;
|
|
1021
1027
|
static constexpr const LogicalTypeId BLOB = LogicalTypeId::BLOB;
|
|
@@ -2231,14 +2237,14 @@ struct TemplatedValidityData {
|
|
|
2231
2237
|
static constexpr const V MAX_ENTRY = ~V(0);
|
|
2232
2238
|
|
|
2233
2239
|
public:
|
|
2234
|
-
|
|
2240
|
+
inline explicit TemplatedValidityData(idx_t count) {
|
|
2235
2241
|
auto entry_count = EntryCount(count);
|
|
2236
2242
|
owned_data = unique_ptr<V[]>(new V[entry_count]);
|
|
2237
2243
|
for (idx_t entry_idx = 0; entry_idx < entry_count; entry_idx++) {
|
|
2238
2244
|
owned_data[entry_idx] = MAX_ENTRY;
|
|
2239
2245
|
}
|
|
2240
2246
|
}
|
|
2241
|
-
|
|
2247
|
+
inline TemplatedValidityData(const V *validity_mask, idx_t count) {
|
|
2242
2248
|
D_ASSERT(validity_mask);
|
|
2243
2249
|
auto entry_count = EntryCount(count);
|
|
2244
2250
|
owned_data = unique_ptr<V[]>(new V[entry_count]);
|
|
@@ -2250,7 +2256,7 @@ public:
|
|
|
2250
2256
|
unique_ptr<V[]> owned_data;
|
|
2251
2257
|
|
|
2252
2258
|
public:
|
|
2253
|
-
|
|
2259
|
+
static inline idx_t EntryCount(idx_t count) {
|
|
2254
2260
|
return (count + (BITS_PER_VALUE - 1)) / BITS_PER_VALUE;
|
|
2255
2261
|
}
|
|
2256
2262
|
};
|
|
@@ -2274,24 +2280,24 @@ public:
|
|
|
2274
2280
|
static constexpr const int STANDARD_MASK_SIZE = STANDARD_ENTRY_COUNT * sizeof(validity_t);
|
|
2275
2281
|
|
|
2276
2282
|
public:
|
|
2277
|
-
|
|
2283
|
+
inline TemplatedValidityMask() : validity_mask(nullptr) {
|
|
2278
2284
|
}
|
|
2279
|
-
|
|
2285
|
+
inline explicit TemplatedValidityMask(idx_t max_count) {
|
|
2280
2286
|
Initialize(max_count);
|
|
2281
2287
|
}
|
|
2282
|
-
|
|
2288
|
+
inline explicit TemplatedValidityMask(V *ptr) : validity_mask(ptr) {
|
|
2283
2289
|
}
|
|
2284
|
-
|
|
2290
|
+
inline TemplatedValidityMask(const TemplatedValidityMask &original, idx_t count) {
|
|
2285
2291
|
Copy(original, count);
|
|
2286
2292
|
}
|
|
2287
2293
|
|
|
2288
|
-
|
|
2294
|
+
static inline idx_t ValidityMaskSize(idx_t count = STANDARD_VECTOR_SIZE) {
|
|
2289
2295
|
return ValidityBuffer::EntryCount(count) * sizeof(V);
|
|
2290
2296
|
}
|
|
2291
|
-
|
|
2297
|
+
inline bool AllValid() const {
|
|
2292
2298
|
return !validity_mask;
|
|
2293
2299
|
}
|
|
2294
|
-
|
|
2300
|
+
inline bool CheckAllValid(idx_t count) const {
|
|
2295
2301
|
if (AllValid()) {
|
|
2296
2302
|
return true;
|
|
2297
2303
|
}
|
|
@@ -2303,7 +2309,7 @@ public:
|
|
|
2303
2309
|
return valid_count == entry_count;
|
|
2304
2310
|
}
|
|
2305
2311
|
|
|
2306
|
-
|
|
2312
|
+
inline bool CheckAllValid(idx_t to, idx_t from) const {
|
|
2307
2313
|
if (AllValid()) {
|
|
2308
2314
|
return true;
|
|
2309
2315
|
}
|
|
@@ -2315,40 +2321,40 @@ public:
|
|
|
2315
2321
|
return true;
|
|
2316
2322
|
}
|
|
2317
2323
|
|
|
2318
|
-
|
|
2324
|
+
inline V *GetData() const {
|
|
2319
2325
|
return validity_mask;
|
|
2320
2326
|
}
|
|
2321
|
-
|
|
2327
|
+
inline void Reset() {
|
|
2322
2328
|
validity_mask = nullptr;
|
|
2323
2329
|
validity_data.reset();
|
|
2324
2330
|
}
|
|
2325
2331
|
|
|
2326
|
-
|
|
2332
|
+
static inline idx_t EntryCount(idx_t count) {
|
|
2327
2333
|
return ValidityBuffer::EntryCount(count);
|
|
2328
2334
|
}
|
|
2329
|
-
|
|
2335
|
+
inline V GetValidityEntry(idx_t entry_idx) const {
|
|
2330
2336
|
if (!validity_mask) {
|
|
2331
2337
|
return ValidityBuffer::MAX_ENTRY;
|
|
2332
2338
|
}
|
|
2333
2339
|
return validity_mask[entry_idx];
|
|
2334
2340
|
}
|
|
2335
|
-
|
|
2341
|
+
static inline bool AllValid(V entry) {
|
|
2336
2342
|
return entry == ValidityBuffer::MAX_ENTRY;
|
|
2337
2343
|
}
|
|
2338
|
-
|
|
2344
|
+
static inline bool NoneValid(V entry) {
|
|
2339
2345
|
return entry == 0;
|
|
2340
2346
|
}
|
|
2341
|
-
|
|
2347
|
+
static inline bool RowIsValid(V entry, idx_t idx_in_entry) {
|
|
2342
2348
|
return entry & (V(1) << V(idx_in_entry));
|
|
2343
2349
|
}
|
|
2344
|
-
|
|
2350
|
+
static inline void GetEntryIndex(idx_t row_idx, idx_t &entry_idx, idx_t &idx_in_entry) {
|
|
2345
2351
|
entry_idx = row_idx / BITS_PER_VALUE;
|
|
2346
2352
|
idx_in_entry = row_idx % BITS_PER_VALUE;
|
|
2347
2353
|
}
|
|
2348
2354
|
|
|
2349
2355
|
//! RowIsValidUnsafe should only be used if AllValid() is false: it achieves the same as RowIsValid but skips a
|
|
2350
2356
|
//! not-null check
|
|
2351
|
-
|
|
2357
|
+
inline bool RowIsValidUnsafe(idx_t row_idx) const {
|
|
2352
2358
|
D_ASSERT(validity_mask);
|
|
2353
2359
|
idx_t entry_idx, idx_in_entry;
|
|
2354
2360
|
GetEntryIndex(row_idx, entry_idx, idx_in_entry);
|
|
@@ -2357,7 +2363,7 @@ public:
|
|
|
2357
2363
|
}
|
|
2358
2364
|
|
|
2359
2365
|
//! Returns true if a row is valid (i.e. not null), false otherwise
|
|
2360
|
-
|
|
2366
|
+
inline bool RowIsValid(idx_t row_idx) const {
|
|
2361
2367
|
if (!validity_mask) {
|
|
2362
2368
|
return true;
|
|
2363
2369
|
}
|
|
@@ -2365,7 +2371,7 @@ public:
|
|
|
2365
2371
|
}
|
|
2366
2372
|
|
|
2367
2373
|
//! Same as SetValid, but skips a null check on validity_mask
|
|
2368
|
-
|
|
2374
|
+
inline void SetValidUnsafe(idx_t row_idx) {
|
|
2369
2375
|
D_ASSERT(validity_mask);
|
|
2370
2376
|
idx_t entry_idx, idx_in_entry;
|
|
2371
2377
|
GetEntryIndex(row_idx, entry_idx, idx_in_entry);
|
|
@@ -2373,7 +2379,7 @@ public:
|
|
|
2373
2379
|
}
|
|
2374
2380
|
|
|
2375
2381
|
//! Marks the entry at the specified row index as valid (i.e. not-null)
|
|
2376
|
-
|
|
2382
|
+
inline void SetValid(idx_t row_idx) {
|
|
2377
2383
|
if (!validity_mask) {
|
|
2378
2384
|
// if AllValid() we don't need to do anything
|
|
2379
2385
|
// the row is already valid
|
|
@@ -2383,20 +2389,20 @@ public:
|
|
|
2383
2389
|
}
|
|
2384
2390
|
|
|
2385
2391
|
//! Marks the bit at the specified entry as invalid (i.e. null)
|
|
2386
|
-
|
|
2392
|
+
inline void SetInvalidUnsafe(idx_t entry_idx, idx_t idx_in_entry) {
|
|
2387
2393
|
D_ASSERT(validity_mask);
|
|
2388
2394
|
validity_mask[entry_idx] &= ~(V(1) << V(idx_in_entry));
|
|
2389
2395
|
}
|
|
2390
2396
|
|
|
2391
2397
|
//! Marks the bit at the specified row index as invalid (i.e. null)
|
|
2392
|
-
|
|
2398
|
+
inline void SetInvalidUnsafe(idx_t row_idx) {
|
|
2393
2399
|
idx_t entry_idx, idx_in_entry;
|
|
2394
2400
|
GetEntryIndex(row_idx, entry_idx, idx_in_entry);
|
|
2395
2401
|
SetInvalidUnsafe(entry_idx, idx_in_entry);
|
|
2396
2402
|
}
|
|
2397
2403
|
|
|
2398
2404
|
//! Marks the entry at the specified row index as invalid (i.e. null)
|
|
2399
|
-
|
|
2405
|
+
inline void SetInvalid(idx_t row_idx) {
|
|
2400
2406
|
if (!validity_mask) {
|
|
2401
2407
|
D_ASSERT(row_idx <= STANDARD_VECTOR_SIZE);
|
|
2402
2408
|
Initialize(STANDARD_VECTOR_SIZE);
|
|
@@ -2405,7 +2411,7 @@ public:
|
|
|
2405
2411
|
}
|
|
2406
2412
|
|
|
2407
2413
|
//! Mark the entry at the specified index as either valid or invalid (non-null or null)
|
|
2408
|
-
|
|
2414
|
+
inline void Set(idx_t row_idx, bool valid) {
|
|
2409
2415
|
if (valid) {
|
|
2410
2416
|
SetValid(row_idx);
|
|
2411
2417
|
} else {
|
|
@@ -2414,14 +2420,14 @@ public:
|
|
|
2414
2420
|
}
|
|
2415
2421
|
|
|
2416
2422
|
//! Ensure the validity mask is writable, allocating space if it is not initialized
|
|
2417
|
-
|
|
2423
|
+
inline void EnsureWritable() {
|
|
2418
2424
|
if (!validity_mask) {
|
|
2419
2425
|
Initialize();
|
|
2420
2426
|
}
|
|
2421
2427
|
}
|
|
2422
2428
|
|
|
2423
2429
|
//! Marks "count" entries in the validity mask as invalid (null)
|
|
2424
|
-
|
|
2430
|
+
inline void SetAllInvalid(idx_t count) {
|
|
2425
2431
|
EnsureWritable();
|
|
2426
2432
|
for (idx_t i = 0; i < ValidityBuffer::EntryCount(count); i++) {
|
|
2427
2433
|
validity_mask[i] = 0;
|
|
@@ -2429,14 +2435,14 @@ public:
|
|
|
2429
2435
|
}
|
|
2430
2436
|
|
|
2431
2437
|
//! Marks "count" entries in the validity mask as valid (not null)
|
|
2432
|
-
|
|
2438
|
+
inline void SetAllValid(idx_t count) {
|
|
2433
2439
|
EnsureWritable();
|
|
2434
2440
|
for (idx_t i = 0; i < ValidityBuffer::EntryCount(count); i++) {
|
|
2435
2441
|
validity_mask[i] = ValidityBuffer::MAX_ENTRY;
|
|
2436
2442
|
}
|
|
2437
2443
|
}
|
|
2438
2444
|
|
|
2439
|
-
|
|
2445
|
+
inline bool IsMaskSet() const {
|
|
2440
2446
|
if (validity_mask) {
|
|
2441
2447
|
return true;
|
|
2442
2448
|
}
|
|
@@ -2444,19 +2450,19 @@ public:
|
|
|
2444
2450
|
}
|
|
2445
2451
|
|
|
2446
2452
|
public:
|
|
2447
|
-
|
|
2453
|
+
inline void Initialize(validity_t *validity) {
|
|
2448
2454
|
validity_data.reset();
|
|
2449
2455
|
validity_mask = validity;
|
|
2450
2456
|
}
|
|
2451
|
-
|
|
2457
|
+
inline void Initialize(const TemplatedValidityMask &other) {
|
|
2452
2458
|
validity_mask = other.validity_mask;
|
|
2453
2459
|
validity_data = other.validity_data;
|
|
2454
2460
|
}
|
|
2455
|
-
|
|
2461
|
+
inline void Initialize(idx_t count = STANDARD_VECTOR_SIZE) {
|
|
2456
2462
|
validity_data = make_buffer<ValidityBuffer>(count);
|
|
2457
2463
|
validity_mask = validity_data->owned_data.get();
|
|
2458
2464
|
}
|
|
2459
|
-
|
|
2465
|
+
inline void Copy(const TemplatedValidityMask &other, idx_t count) {
|
|
2460
2466
|
if (other.AllValid()) {
|
|
2461
2467
|
validity_data = nullptr;
|
|
2462
2468
|
validity_mask = nullptr;
|
|
@@ -2473,13 +2479,13 @@ protected:
|
|
|
2473
2479
|
|
|
2474
2480
|
struct ValidityMask : public TemplatedValidityMask<validity_t> {
|
|
2475
2481
|
public:
|
|
2476
|
-
|
|
2482
|
+
inline ValidityMask() : TemplatedValidityMask(nullptr) {
|
|
2477
2483
|
}
|
|
2478
|
-
|
|
2484
|
+
inline explicit ValidityMask(idx_t max_count) : TemplatedValidityMask(max_count) {
|
|
2479
2485
|
}
|
|
2480
|
-
|
|
2486
|
+
inline explicit ValidityMask(validity_t *ptr) : TemplatedValidityMask(ptr) {
|
|
2481
2487
|
}
|
|
2482
|
-
|
|
2488
|
+
inline ValidityMask(const ValidityMask &original, idx_t count) : TemplatedValidityMask(original, count) {
|
|
2483
2489
|
}
|
|
2484
2490
|
|
|
2485
2491
|
public:
|
|
@@ -2579,10 +2585,12 @@ public:
|
|
|
2579
2585
|
DUCKDB_API static Value POINTER(uintptr_t value);
|
|
2580
2586
|
//! Create a date Value from a specified date
|
|
2581
2587
|
DUCKDB_API static Value DATE(date_t date);
|
|
2588
|
+
DUCKDB_API static Value DATETZ(date_t date);
|
|
2582
2589
|
//! Create a date Value from a specified date
|
|
2583
2590
|
DUCKDB_API static Value DATE(int32_t year, int32_t month, int32_t day);
|
|
2584
2591
|
//! Create a time Value from a specified time
|
|
2585
2592
|
DUCKDB_API static Value TIME(dtime_t time);
|
|
2593
|
+
DUCKDB_API static Value TIMETZ(dtime_t time);
|
|
2586
2594
|
//! Create a time Value from a specified time
|
|
2587
2595
|
DUCKDB_API static Value TIME(int32_t hour, int32_t min, int32_t sec, int32_t micros);
|
|
2588
2596
|
//! Create a timestamp Value from a specified date/time combination
|
|
@@ -2592,6 +2600,7 @@ public:
|
|
|
2592
2600
|
DUCKDB_API static Value TimestampNs(timestamp_t timestamp);
|
|
2593
2601
|
DUCKDB_API static Value TimestampMs(timestamp_t timestamp);
|
|
2594
2602
|
DUCKDB_API static Value TimestampSec(timestamp_t timestamp);
|
|
2603
|
+
DUCKDB_API static Value TIMESTAMPTZ(timestamp_t timestamp);
|
|
2595
2604
|
//! Create a timestamp Value from a specified timestamp in separate values
|
|
2596
2605
|
DUCKDB_API static Value TIMESTAMP(int32_t year, int32_t month, int32_t day, int32_t hour, int32_t min, int32_t sec,
|
|
2597
2606
|
int32_t micros);
|
|
@@ -3660,10 +3669,10 @@ public:
|
|
|
3660
3669
|
vector<Vector> data;
|
|
3661
3670
|
|
|
3662
3671
|
public:
|
|
3663
|
-
|
|
3672
|
+
inline idx_t size() const { // NOLINT
|
|
3664
3673
|
return count;
|
|
3665
3674
|
}
|
|
3666
|
-
|
|
3675
|
+
inline idx_t ColumnCount() const {
|
|
3667
3676
|
return data.size();
|
|
3668
3677
|
}
|
|
3669
3678
|
inline void SetCardinality(idx_t count_p) {
|
|
@@ -6019,7 +6028,7 @@ public:
|
|
|
6019
6028
|
static string ToString(const interval_t &val);
|
|
6020
6029
|
|
|
6021
6030
|
//! Convert milliseconds to a normalised interval
|
|
6022
|
-
static interval_t FromMicro(int64_t micros);
|
|
6031
|
+
DUCKDB_API static interval_t FromMicro(int64_t micros);
|
|
6023
6032
|
|
|
6024
6033
|
//! Get Interval in milliseconds
|
|
6025
6034
|
static int64_t GetMilli(const interval_t &val);
|
|
@@ -7471,6 +7480,11 @@ public:
|
|
|
7471
7480
|
T *GetEntry(ClientContext &context, const string &schema_name, const string &name, bool if_exists = false,
|
|
7472
7481
|
QueryErrorContext error_context = QueryErrorContext());
|
|
7473
7482
|
|
|
7483
|
+
//! Append a scalar or aggregate function to the catalog
|
|
7484
|
+
DUCKDB_API CatalogEntry *AddFunction(ClientContext &context, CreateFunctionInfo *info);
|
|
7485
|
+
//! Append a scalar or aggregate function to the catalog
|
|
7486
|
+
DUCKDB_API CatalogEntry *AddFunction(ClientContext &context, SchemaCatalogEntry *schema, CreateFunctionInfo *info);
|
|
7487
|
+
|
|
7474
7488
|
//! Alter an existing entry in the catalog.
|
|
7475
7489
|
DUCKDB_API void Alter(ClientContext &context, AlterInfo *info);
|
|
7476
7490
|
|
|
@@ -8566,7 +8580,7 @@ private:
|
|
|
8566
8580
|
}
|
|
8567
8581
|
|
|
8568
8582
|
template <typename T>
|
|
8569
|
-
static bool TypesMatch(LogicalType sql_type) {
|
|
8583
|
+
static bool TypesMatch(const LogicalType &sql_type) {
|
|
8570
8584
|
switch (sql_type.id()) {
|
|
8571
8585
|
case LogicalTypeId::BOOLEAN:
|
|
8572
8586
|
return std::is_same<T, bool>();
|
|
@@ -8579,13 +8593,16 @@ private:
|
|
|
8579
8593
|
case LogicalTypeId::BIGINT:
|
|
8580
8594
|
return std::is_same<T, int64_t>();
|
|
8581
8595
|
case LogicalTypeId::DATE:
|
|
8596
|
+
case LogicalTypeId::DATE_TZ:
|
|
8582
8597
|
return std::is_same<T, date_t>();
|
|
8583
8598
|
case LogicalTypeId::TIME:
|
|
8599
|
+
case LogicalTypeId::TIME_TZ:
|
|
8584
8600
|
return std::is_same<T, dtime_t>();
|
|
8585
8601
|
case LogicalTypeId::TIMESTAMP:
|
|
8586
8602
|
case LogicalTypeId::TIMESTAMP_MS:
|
|
8587
8603
|
case LogicalTypeId::TIMESTAMP_NS:
|
|
8588
8604
|
case LogicalTypeId::TIMESTAMP_SEC:
|
|
8605
|
+
case LogicalTypeId::TIMESTAMP_TZ:
|
|
8589
8606
|
return std::is_same<T, timestamp_t>();
|
|
8590
8607
|
case LogicalTypeId::FLOAT:
|
|
8591
8608
|
return std::is_same<T, float>();
|
|
@@ -11869,6 +11886,8 @@ public:
|
|
|
11869
11886
|
|
|
11870
11887
|
//! Convert a time object to a string in the format "hh:mm:ss"
|
|
11871
11888
|
DUCKDB_API static string ToString(dtime_t time);
|
|
11889
|
+
//! Convert a UTC offset to ±HH[:MM]
|
|
11890
|
+
DUCKDB_API static string ToUTCOffset(int hour_offset, int minute_offset);
|
|
11872
11891
|
|
|
11873
11892
|
DUCKDB_API static dtime_t FromTime(int32_t hour, int32_t minute, int32_t second, int32_t microseconds = 0);
|
|
11874
11893
|
|
|
@@ -12579,6 +12598,9 @@ private:
|
|
|
12579
12598
|
//! Drops an entry from the schema
|
|
12580
12599
|
void DropEntry(ClientContext &context, DropInfo *info);
|
|
12581
12600
|
|
|
12601
|
+
//! Append a scalar or aggregate function within the given schema
|
|
12602
|
+
CatalogEntry *AddFunction(ClientContext &context, CreateFunctionInfo *info);
|
|
12603
|
+
|
|
12582
12604
|
//! Alters a catalog entry
|
|
12583
12605
|
void Alter(ClientContext &context, AlterInfo *info);
|
|
12584
12606
|
|