duckdb 0.6.2-dev901.0 → 0.6.2-dev908.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
CHANGED
|
@@ -58,7 +58,7 @@ int Comparators::CompareVal(const data_ptr_t l_ptr, const data_ptr_t r_ptr, cons
|
|
|
58
58
|
case PhysicalType::STRUCT: {
|
|
59
59
|
auto l_nested_ptr = Load<data_ptr_t>(l_ptr);
|
|
60
60
|
auto r_nested_ptr = Load<data_ptr_t>(r_ptr);
|
|
61
|
-
return CompareValAndAdvance(l_nested_ptr, r_nested_ptr, type);
|
|
61
|
+
return CompareValAndAdvance(l_nested_ptr, r_nested_ptr, type, true);
|
|
62
62
|
}
|
|
63
63
|
default:
|
|
64
64
|
throw NotImplementedException("Unimplemented CompareVal for type %s", type.ToString());
|
|
@@ -113,7 +113,7 @@ int Comparators::TemplatedCompareVal(const data_ptr_t &left_ptr, const data_ptr_
|
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
int Comparators::CompareValAndAdvance(data_ptr_t &l_ptr, data_ptr_t &r_ptr, const LogicalType &type) {
|
|
116
|
+
int Comparators::CompareValAndAdvance(data_ptr_t &l_ptr, data_ptr_t &r_ptr, const LogicalType &type, bool valid) {
|
|
117
117
|
switch (type.InternalType()) {
|
|
118
118
|
case PhysicalType::BOOL:
|
|
119
119
|
case PhysicalType::INT8:
|
|
@@ -141,11 +141,11 @@ int Comparators::CompareValAndAdvance(data_ptr_t &l_ptr, data_ptr_t &r_ptr, cons
|
|
|
141
141
|
case PhysicalType::INTERVAL:
|
|
142
142
|
return TemplatedCompareAndAdvance<interval_t>(l_ptr, r_ptr);
|
|
143
143
|
case PhysicalType::VARCHAR:
|
|
144
|
-
return CompareStringAndAdvance(l_ptr, r_ptr);
|
|
144
|
+
return CompareStringAndAdvance(l_ptr, r_ptr, valid);
|
|
145
145
|
case PhysicalType::LIST:
|
|
146
|
-
return CompareListAndAdvance(l_ptr, r_ptr, ListType::GetChildType(type));
|
|
146
|
+
return CompareListAndAdvance(l_ptr, r_ptr, ListType::GetChildType(type), valid);
|
|
147
147
|
case PhysicalType::STRUCT:
|
|
148
|
-
return CompareStructAndAdvance(l_ptr, r_ptr, StructType::GetChildTypes(type));
|
|
148
|
+
return CompareStructAndAdvance(l_ptr, r_ptr, StructType::GetChildTypes(type), valid);
|
|
149
149
|
default:
|
|
150
150
|
throw NotImplementedException("Unimplemented CompareValAndAdvance for type %s", type.ToString());
|
|
151
151
|
}
|
|
@@ -159,7 +159,10 @@ int Comparators::TemplatedCompareAndAdvance(data_ptr_t &left_ptr, data_ptr_t &ri
|
|
|
159
159
|
return result;
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
-
int Comparators::CompareStringAndAdvance(data_ptr_t &left_ptr, data_ptr_t &right_ptr) {
|
|
162
|
+
int Comparators::CompareStringAndAdvance(data_ptr_t &left_ptr, data_ptr_t &right_ptr, bool valid) {
|
|
163
|
+
if (!valid) {
|
|
164
|
+
return 0;
|
|
165
|
+
}
|
|
163
166
|
// Construct the string_t
|
|
164
167
|
uint32_t left_string_size = Load<uint32_t>(left_ptr);
|
|
165
168
|
uint32_t right_string_size = Load<uint32_t>(right_ptr);
|
|
@@ -174,7 +177,7 @@ int Comparators::CompareStringAndAdvance(data_ptr_t &left_ptr, data_ptr_t &right
|
|
|
174
177
|
}
|
|
175
178
|
|
|
176
179
|
int Comparators::CompareStructAndAdvance(data_ptr_t &left_ptr, data_ptr_t &right_ptr,
|
|
177
|
-
const child_list_t<LogicalType> &types) {
|
|
180
|
+
const child_list_t<LogicalType> &types, bool valid) {
|
|
178
181
|
idx_t count = types.size();
|
|
179
182
|
// Load validity masks
|
|
180
183
|
ValidityBytes left_validity(left_ptr);
|
|
@@ -193,8 +196,8 @@ int Comparators::CompareStructAndAdvance(data_ptr_t &left_ptr, data_ptr_t &right
|
|
|
193
196
|
left_valid = left_validity.RowIsValid(left_validity.GetValidityEntry(entry_idx), idx_in_entry);
|
|
194
197
|
right_valid = right_validity.RowIsValid(right_validity.GetValidityEntry(entry_idx), idx_in_entry);
|
|
195
198
|
auto &type = types[i].second;
|
|
196
|
-
if ((left_valid
|
|
197
|
-
comp_res = CompareValAndAdvance(left_ptr, right_ptr, types[i].second);
|
|
199
|
+
if ((left_valid == right_valid) || TypeIsConstantSize(type.InternalType())) {
|
|
200
|
+
comp_res = CompareValAndAdvance(left_ptr, right_ptr, types[i].second, left_valid && valid);
|
|
198
201
|
}
|
|
199
202
|
if (!left_valid && !right_valid) {
|
|
200
203
|
comp_res = 0;
|
|
@@ -210,7 +213,11 @@ int Comparators::CompareStructAndAdvance(data_ptr_t &left_ptr, data_ptr_t &right
|
|
|
210
213
|
return comp_res;
|
|
211
214
|
}
|
|
212
215
|
|
|
213
|
-
int Comparators::CompareListAndAdvance(data_ptr_t &left_ptr, data_ptr_t &right_ptr, const LogicalType &type
|
|
216
|
+
int Comparators::CompareListAndAdvance(data_ptr_t &left_ptr, data_ptr_t &right_ptr, const LogicalType &type,
|
|
217
|
+
bool valid) {
|
|
218
|
+
if (!valid) {
|
|
219
|
+
return 0;
|
|
220
|
+
}
|
|
214
221
|
// Load list lengths
|
|
215
222
|
auto left_len = Load<idx_t>(left_ptr);
|
|
216
223
|
auto right_len = Load<idx_t>(right_ptr);
|
|
@@ -284,13 +291,14 @@ int Comparators::CompareListAndAdvance(data_ptr_t &left_ptr, data_ptr_t &right_p
|
|
|
284
291
|
if (left_valid && right_valid) {
|
|
285
292
|
switch (type.InternalType()) {
|
|
286
293
|
case PhysicalType::LIST:
|
|
287
|
-
comp_res = CompareListAndAdvance(left_ptr, right_ptr, ListType::GetChildType(type));
|
|
294
|
+
comp_res = CompareListAndAdvance(left_ptr, right_ptr, ListType::GetChildType(type), left_valid);
|
|
288
295
|
break;
|
|
289
296
|
case PhysicalType::VARCHAR:
|
|
290
|
-
comp_res = CompareStringAndAdvance(left_ptr, right_ptr);
|
|
297
|
+
comp_res = CompareStringAndAdvance(left_ptr, right_ptr, left_valid);
|
|
291
298
|
break;
|
|
292
299
|
case PhysicalType::STRUCT:
|
|
293
|
-
comp_res =
|
|
300
|
+
comp_res =
|
|
301
|
+
CompareStructAndAdvance(left_ptr, right_ptr, StructType::GetChildTypes(type), left_valid);
|
|
294
302
|
break;
|
|
295
303
|
default:
|
|
296
304
|
throw NotImplementedException("CompareListAndAdvance for variable-size type %s", type.ToString());
|
|
@@ -502,32 +502,51 @@ int32_t Date::ExtractISODayOfTheWeek(date_t date) {
|
|
|
502
502
|
}
|
|
503
503
|
}
|
|
504
504
|
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
// if fourth is wednesday, second is the first day
|
|
514
|
-
// if fourth is thursday, first is the first day
|
|
515
|
-
// if fourth is friday - sunday, day is in the previous year
|
|
516
|
-
// (day is 0-based, weekday is 1-based)
|
|
517
|
-
const auto first_day_of_the_first_isoweek = 4 - weekday_of_the_fourth;
|
|
518
|
-
if (day_of_the_year < first_day_of_the_first_isoweek) {
|
|
519
|
-
// day is part of last year (13th month)
|
|
520
|
-
--year;
|
|
521
|
-
return GetISOYearWeek(year, 12, day);
|
|
522
|
-
} else {
|
|
523
|
-
return ((day_of_the_year - first_day_of_the_first_isoweek) / 7) + 1;
|
|
505
|
+
template <typename T>
|
|
506
|
+
static T PythonDivMod(const T &x, const T &y, T &r) {
|
|
507
|
+
// D_ASSERT(y > 0);
|
|
508
|
+
T quo = x / y;
|
|
509
|
+
r = x - quo * y;
|
|
510
|
+
if (r < 0) {
|
|
511
|
+
--quo;
|
|
512
|
+
r += y;
|
|
524
513
|
}
|
|
514
|
+
// D_ASSERT(0 <= r && r < y);
|
|
515
|
+
return quo;
|
|
525
516
|
}
|
|
526
517
|
|
|
527
|
-
|
|
518
|
+
static date_t GetISOWeekOne(int32_t year) {
|
|
519
|
+
const auto first_day = Date::FromDate(year, 1, 1); /* ord of 1/1 */
|
|
520
|
+
/* 0 if 1/1 is a Monday, 1 if a Tue, etc. */
|
|
521
|
+
const auto first_weekday = Date::ExtractISODayOfTheWeek(first_day) - 1;
|
|
522
|
+
/* ordinal of closest Monday at or before 1/1 */
|
|
523
|
+
auto week1_monday = first_day - first_weekday;
|
|
524
|
+
|
|
525
|
+
if (first_weekday > 3) { /* if 1/1 was Fri, Sat, Sun */
|
|
526
|
+
week1_monday += 7;
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
return week1_monday;
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
static int32_t GetISOYearWeek(const date_t date, int32_t &year) {
|
|
528
533
|
int32_t month, day;
|
|
529
534
|
Date::Convert(date, year, month, day);
|
|
530
|
-
|
|
535
|
+
auto week1_monday = GetISOWeekOne(year);
|
|
536
|
+
auto week = PythonDivMod((date.days - week1_monday.days), 7, day);
|
|
537
|
+
if (week < 0) {
|
|
538
|
+
week1_monday = GetISOWeekOne(--year);
|
|
539
|
+
week = PythonDivMod((date.days - week1_monday.days), 7, day);
|
|
540
|
+
} else if (week >= 52 && date >= GetISOWeekOne(year + 1)) {
|
|
541
|
+
++year;
|
|
542
|
+
week = 0;
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
return week + 1;
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
void Date::ExtractISOYearWeek(date_t date, int32_t &year, int32_t &week) {
|
|
549
|
+
week = GetISOYearWeek(date, year);
|
|
531
550
|
}
|
|
532
551
|
|
|
533
552
|
int32_t Date::ExtractISOWeekNumber(date_t date) {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#ifndef DUCKDB_VERSION
|
|
2
|
-
#define DUCKDB_VERSION "0.6.2-
|
|
2
|
+
#define DUCKDB_VERSION "0.6.2-dev908"
|
|
3
3
|
#endif
|
|
4
4
|
#ifndef DUCKDB_SOURCE_ID
|
|
5
|
-
#define DUCKDB_SOURCE_ID "
|
|
5
|
+
#define DUCKDB_SOURCE_ID "c3791b63d0"
|
|
6
6
|
#endif
|
|
7
7
|
#include "duckdb/function/table/system_functions.hpp"
|
|
8
8
|
#include "duckdb/main/database.hpp"
|
|
@@ -38,17 +38,17 @@ private:
|
|
|
38
38
|
static int TemplatedCompareVal(const data_ptr_t &left_ptr, const data_ptr_t &right_ptr);
|
|
39
39
|
|
|
40
40
|
//! Compare two values at the pointers (can be recursive if nested type)
|
|
41
|
-
static int CompareValAndAdvance(data_ptr_t &l_ptr, data_ptr_t &r_ptr, const LogicalType &type);
|
|
41
|
+
static int CompareValAndAdvance(data_ptr_t &l_ptr, data_ptr_t &r_ptr, const LogicalType &type, bool valid);
|
|
42
42
|
//! Compares two fixed-size values at the given pointers
|
|
43
43
|
template <class T>
|
|
44
44
|
static int TemplatedCompareAndAdvance(data_ptr_t &left_ptr, data_ptr_t &right_ptr);
|
|
45
45
|
//! Compares two string values at the given pointers
|
|
46
|
-
static int CompareStringAndAdvance(data_ptr_t &left_ptr, data_ptr_t &right_ptr);
|
|
46
|
+
static int CompareStringAndAdvance(data_ptr_t &left_ptr, data_ptr_t &right_ptr, bool valid);
|
|
47
47
|
//! Compares two struct values at the given pointers (recursive)
|
|
48
48
|
static int CompareStructAndAdvance(data_ptr_t &left_ptr, data_ptr_t &right_ptr,
|
|
49
|
-
const child_list_t<LogicalType> &types);
|
|
49
|
+
const child_list_t<LogicalType> &types, bool valid);
|
|
50
50
|
//! Compare two list values at the pointers (can be recursive if nested type)
|
|
51
|
-
static int CompareListAndAdvance(data_ptr_t &left_ptr, data_ptr_t &right_ptr, const LogicalType &type);
|
|
51
|
+
static int CompareListAndAdvance(data_ptr_t &left_ptr, data_ptr_t &right_ptr, const LogicalType &type, bool valid);
|
|
52
52
|
//! Compares a list of fixed-size values
|
|
53
53
|
template <class T>
|
|
54
54
|
static int TemplatedCompareListLoop(data_ptr_t &left_ptr, data_ptr_t &right_ptr, const ValidityBytes &left_validity,
|