duckdb 0.3.2-dev874.0 → 0.3.2-dev898.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 +320 -43
- package/src/duckdb.hpp +2 -2
- package/src/parquet-amalgamation.cpp +31439 -31439
package/package.json
CHANGED
package/src/duckdb.cpp
CHANGED
|
@@ -32120,7 +32120,9 @@ enum class DatePartSpecifier : uint8_t {
|
|
|
32120
32120
|
DOY,
|
|
32121
32121
|
YEARWEEK,
|
|
32122
32122
|
ERA,
|
|
32123
|
-
|
|
32123
|
+
TIMEZONE,
|
|
32124
|
+
TIMEZONE_HOUR,
|
|
32125
|
+
TIMEZONE_MINUTE
|
|
32124
32126
|
};
|
|
32125
32127
|
|
|
32126
32128
|
DUCKDB_API bool TryGetDatePartSpecifier(const string &specifier, DatePartSpecifier &result);
|
|
@@ -75008,6 +75010,10 @@ struct EpochFun {
|
|
|
75008
75010
|
static void RegisterFunction(BuiltinFunctions &set);
|
|
75009
75011
|
};
|
|
75010
75012
|
|
|
75013
|
+
struct MakeDateFun {
|
|
75014
|
+
static void RegisterFunction(BuiltinFunctions &set);
|
|
75015
|
+
};
|
|
75016
|
+
|
|
75011
75017
|
struct StrfTimeFun {
|
|
75012
75018
|
static void RegisterFunction(BuiltinFunctions &set);
|
|
75013
75019
|
};
|
|
@@ -75549,7 +75555,7 @@ bool TryGetDatePartSpecifier(const string &specifier_p, DatePartSpecifier &resul
|
|
|
75549
75555
|
result = DatePartSpecifier::DECADE;
|
|
75550
75556
|
} else if (specifier == "century" || specifier == "centuries") {
|
|
75551
75557
|
result = DatePartSpecifier::CENTURY;
|
|
75552
|
-
} else if (specifier == "millennium" || specifier == "millennia") {
|
|
75558
|
+
} else if (specifier == "millennium" || specifier == "millennia" || specifier == "millenium") {
|
|
75553
75559
|
result = DatePartSpecifier::MILLENNIUM;
|
|
75554
75560
|
} else if (specifier == "microseconds" || specifier == "microsecond") {
|
|
75555
75561
|
result = DatePartSpecifier::MICROSECONDS;
|
|
@@ -75585,8 +75591,12 @@ bool TryGetDatePartSpecifier(const string &specifier_p, DatePartSpecifier &resul
|
|
|
75585
75591
|
result = DatePartSpecifier::YEARWEEK;
|
|
75586
75592
|
} else if (specifier == "era") {
|
|
75587
75593
|
result = DatePartSpecifier::ERA;
|
|
75588
|
-
} else if (specifier == "
|
|
75589
|
-
result = DatePartSpecifier::
|
|
75594
|
+
} else if (specifier == "timezone") {
|
|
75595
|
+
result = DatePartSpecifier::TIMEZONE;
|
|
75596
|
+
} else if (specifier == "timezone_hour") {
|
|
75597
|
+
result = DatePartSpecifier::TIMEZONE_HOUR;
|
|
75598
|
+
} else if (specifier == "timezone_minute") {
|
|
75599
|
+
result = DatePartSpecifier::TIMEZONE_MINUTE;
|
|
75590
75600
|
} else {
|
|
75591
75601
|
return false;
|
|
75592
75602
|
}
|
|
@@ -75635,7 +75645,9 @@ DatePartSpecifier GetDateTypePartSpecifier(const string &specifier, LogicalType
|
|
|
75635
75645
|
case DatePartSpecifier::MINUTE:
|
|
75636
75646
|
case DatePartSpecifier::HOUR:
|
|
75637
75647
|
case DatePartSpecifier::EPOCH:
|
|
75638
|
-
case DatePartSpecifier::
|
|
75648
|
+
case DatePartSpecifier::TIMEZONE:
|
|
75649
|
+
case DatePartSpecifier::TIMEZONE_HOUR:
|
|
75650
|
+
case DatePartSpecifier::TIMEZONE_MINUTE:
|
|
75639
75651
|
return part;
|
|
75640
75652
|
default:
|
|
75641
75653
|
break;
|
|
@@ -75760,9 +75772,15 @@ struct DatePart {
|
|
|
75760
75772
|
};
|
|
75761
75773
|
|
|
75762
75774
|
struct DecadeOperator {
|
|
75775
|
+
// From the PG docs: "The year field divided by 10"
|
|
75776
|
+
template <typename TR>
|
|
75777
|
+
static inline TR DecadeFromYear(TR yyyy) {
|
|
75778
|
+
return yyyy / 10;
|
|
75779
|
+
}
|
|
75780
|
+
|
|
75763
75781
|
template <class TA, class TR>
|
|
75764
75782
|
static inline TR Operation(TA input) {
|
|
75765
|
-
return YearOperator::Operation<TA, TR>(input)
|
|
75783
|
+
return DecadeFromYear(YearOperator::Operation<TA, TR>(input));
|
|
75766
75784
|
}
|
|
75767
75785
|
|
|
75768
75786
|
template <class T>
|
|
@@ -75774,9 +75792,25 @@ struct DatePart {
|
|
|
75774
75792
|
};
|
|
75775
75793
|
|
|
75776
75794
|
struct CenturyOperator {
|
|
75795
|
+
// From the PG docs:
|
|
75796
|
+
// "The first century starts at 0001-01-01 00:00:00 AD, although they did not know it at the time.
|
|
75797
|
+
// This definition applies to all Gregorian calendar countries.
|
|
75798
|
+
// There is no century number 0, you go from -1 century to 1 century.
|
|
75799
|
+
// If you disagree with this, please write your complaint to: Pope, Cathedral Saint-Peter of Roma, Vatican."
|
|
75800
|
+
// (To be fair, His Holiness had nothing to do with this -
|
|
75801
|
+
// it was the lack of zero in the counting systems of the time...)
|
|
75802
|
+
template <typename TR>
|
|
75803
|
+
static inline TR CenturyFromYear(TR yyyy) {
|
|
75804
|
+
if (yyyy > 0) {
|
|
75805
|
+
return ((yyyy - 1) / 100) + 1;
|
|
75806
|
+
} else {
|
|
75807
|
+
return (yyyy / 100) - 1;
|
|
75808
|
+
}
|
|
75809
|
+
}
|
|
75810
|
+
|
|
75777
75811
|
template <class TA, class TR>
|
|
75778
75812
|
static inline TR Operation(TA input) {
|
|
75779
|
-
return (
|
|
75813
|
+
return CenturyFromYear(YearOperator::Operation<TA, TR>(input));
|
|
75780
75814
|
}
|
|
75781
75815
|
|
|
75782
75816
|
template <class T>
|
|
@@ -75787,24 +75821,39 @@ struct DatePart {
|
|
|
75787
75821
|
}
|
|
75788
75822
|
};
|
|
75789
75823
|
|
|
75790
|
-
struct
|
|
75824
|
+
struct MillenniumOperator {
|
|
75825
|
+
// See the century comment
|
|
75826
|
+
template <typename TR>
|
|
75827
|
+
static inline TR MillenniumFromYear(TR yyyy) {
|
|
75828
|
+
if (yyyy > 0) {
|
|
75829
|
+
return ((yyyy - 1) / 1000) + 1;
|
|
75830
|
+
} else {
|
|
75831
|
+
return (yyyy / 1000) - 1;
|
|
75832
|
+
}
|
|
75833
|
+
}
|
|
75834
|
+
|
|
75791
75835
|
template <class TA, class TR>
|
|
75792
75836
|
static inline TR Operation(TA input) {
|
|
75793
|
-
return (
|
|
75837
|
+
return MillenniumFromYear<TR>(YearOperator::Operation<TA, TR>(input));
|
|
75794
75838
|
}
|
|
75795
75839
|
|
|
75796
75840
|
template <class T>
|
|
75797
75841
|
static unique_ptr<BaseStatistics> PropagateStatistics(ClientContext &context, BoundFunctionExpression &expr,
|
|
75798
75842
|
FunctionData *bind_data,
|
|
75799
75843
|
vector<unique_ptr<BaseStatistics>> &child_stats) {
|
|
75800
|
-
return PropagateDatePartStatistics<T,
|
|
75844
|
+
return PropagateDatePartStatistics<T, MillenniumOperator>(child_stats);
|
|
75801
75845
|
}
|
|
75802
75846
|
};
|
|
75803
75847
|
|
|
75804
75848
|
struct QuarterOperator {
|
|
75849
|
+
template <class TR>
|
|
75850
|
+
static inline TR QuarterFromMonth(TR mm) {
|
|
75851
|
+
return (mm - 1) / Interval::MONTHS_PER_QUARTER + 1;
|
|
75852
|
+
}
|
|
75853
|
+
|
|
75805
75854
|
template <class TA, class TR>
|
|
75806
75855
|
static inline TR Operation(TA input) {
|
|
75807
|
-
return (Date::ExtractMonth(input)
|
|
75856
|
+
return QuarterFromMonth(Date::ExtractMonth(input));
|
|
75808
75857
|
}
|
|
75809
75858
|
|
|
75810
75859
|
template <class T>
|
|
@@ -75817,11 +75866,16 @@ struct DatePart {
|
|
|
75817
75866
|
};
|
|
75818
75867
|
|
|
75819
75868
|
struct DayOfWeekOperator {
|
|
75820
|
-
template <class
|
|
75821
|
-
static inline TR
|
|
75869
|
+
template <class TR>
|
|
75870
|
+
static inline TR DayOfWeekFromISO(TR isodow) {
|
|
75822
75871
|
// day of the week (Sunday = 0, Saturday = 6)
|
|
75823
75872
|
// turn sunday into 0 by doing mod 7
|
|
75824
|
-
return
|
|
75873
|
+
return isodow % 7;
|
|
75874
|
+
}
|
|
75875
|
+
|
|
75876
|
+
template <class TA, class TR>
|
|
75877
|
+
static inline TR Operation(TA input) {
|
|
75878
|
+
return DayOfWeekFromISO(Date::ExtractISODayOfTheWeek(input));
|
|
75825
75879
|
}
|
|
75826
75880
|
|
|
75827
75881
|
template <class T>
|
|
@@ -75876,9 +75930,14 @@ struct DatePart {
|
|
|
75876
75930
|
};
|
|
75877
75931
|
|
|
75878
75932
|
struct YearWeekOperator {
|
|
75933
|
+
template <class TR>
|
|
75934
|
+
static inline TR YearWeekFromParts(TR yyyy, TR ww) {
|
|
75935
|
+
return yyyy * 100 + ((yyyy > 0) ? ww : -ww);
|
|
75936
|
+
}
|
|
75937
|
+
|
|
75879
75938
|
template <class TA, class TR>
|
|
75880
75939
|
static inline TR Operation(TA input) {
|
|
75881
|
-
return YearOperator::Operation<TA, TR>(input)
|
|
75940
|
+
return YearWeekFromParts(YearOperator::Operation<TA, TR>(input), WeekOperator::Operation<TA, TR>(input));
|
|
75882
75941
|
}
|
|
75883
75942
|
|
|
75884
75943
|
template <class T>
|
|
@@ -75974,9 +76033,14 @@ struct DatePart {
|
|
|
75974
76033
|
};
|
|
75975
76034
|
|
|
75976
76035
|
struct EraOperator {
|
|
76036
|
+
template <class TR>
|
|
76037
|
+
static inline TR EraFromYear(TR yyyy) {
|
|
76038
|
+
return yyyy > 0 ? 1 : 0;
|
|
76039
|
+
}
|
|
76040
|
+
|
|
75977
76041
|
template <class TA, class TR>
|
|
75978
76042
|
static inline TR Operation(TA input) {
|
|
75979
|
-
return Date::ExtractYear(input)
|
|
76043
|
+
return EraFromYear(Date::ExtractYear(input));
|
|
75980
76044
|
}
|
|
75981
76045
|
|
|
75982
76046
|
template <class T>
|
|
@@ -75987,7 +76051,7 @@ struct DatePart {
|
|
|
75987
76051
|
}
|
|
75988
76052
|
};
|
|
75989
76053
|
|
|
75990
|
-
struct
|
|
76054
|
+
struct TimezoneOperator {
|
|
75991
76055
|
template <class TA, class TR>
|
|
75992
76056
|
static inline TR Operation(TA input) {
|
|
75993
76057
|
// Regular timestamps are UTC.
|
|
@@ -76002,6 +76066,10 @@ struct DatePart {
|
|
|
76002
76066
|
}
|
|
76003
76067
|
};
|
|
76004
76068
|
|
|
76069
|
+
// These are all zero and have the same restrictions
|
|
76070
|
+
using TimezoneHourOperator = TimezoneOperator;
|
|
76071
|
+
using TimezoneMinuteOperator = TimezoneOperator;
|
|
76072
|
+
|
|
76005
76073
|
struct StructOperator {
|
|
76006
76074
|
using part_codes_t = vector<DatePartSpecifier>;
|
|
76007
76075
|
using part_mask_t = uint64_t;
|
|
@@ -76051,7 +76119,9 @@ struct DatePart {
|
|
|
76051
76119
|
case DatePartSpecifier::HOUR:
|
|
76052
76120
|
mask |= TIME;
|
|
76053
76121
|
break;
|
|
76054
|
-
case DatePartSpecifier::
|
|
76122
|
+
case DatePartSpecifier::TIMEZONE:
|
|
76123
|
+
case DatePartSpecifier::TIMEZONE_HOUR:
|
|
76124
|
+
case DatePartSpecifier::TIMEZONE_MINUTE:
|
|
76055
76125
|
mask |= ZONE;
|
|
76056
76126
|
break;
|
|
76057
76127
|
}
|
|
@@ -76083,19 +76153,19 @@ struct DatePart {
|
|
|
76083
76153
|
part_data[idx] = dd;
|
|
76084
76154
|
}
|
|
76085
76155
|
if ((part_data = HasPartValue(part_values, DatePartSpecifier::DECADE))) {
|
|
76086
|
-
part_data[idx] = yyyy
|
|
76156
|
+
part_data[idx] = DecadeOperator::DecadeFromYear(yyyy);
|
|
76087
76157
|
}
|
|
76088
76158
|
if ((part_data = HasPartValue(part_values, DatePartSpecifier::CENTURY))) {
|
|
76089
|
-
part_data[idx] = (yyyy
|
|
76159
|
+
part_data[idx] = CenturyOperator::CenturyFromYear(yyyy);
|
|
76090
76160
|
}
|
|
76091
76161
|
if ((part_data = HasPartValue(part_values, DatePartSpecifier::MILLENNIUM))) {
|
|
76092
|
-
part_data[idx] = (yyyy
|
|
76162
|
+
part_data[idx] = MillenniumOperator::MillenniumFromYear(yyyy);
|
|
76093
76163
|
}
|
|
76094
76164
|
if ((part_data = HasPartValue(part_values, DatePartSpecifier::QUARTER))) {
|
|
76095
|
-
part_data[idx] = (mm
|
|
76165
|
+
part_data[idx] = QuarterOperator::QuarterFromMonth(mm);
|
|
76096
76166
|
}
|
|
76097
76167
|
if ((part_data = HasPartValue(part_values, DatePartSpecifier::ERA))) {
|
|
76098
|
-
part_data[idx] = yyyy
|
|
76168
|
+
part_data[idx] = EraOperator::EraFromYear(yyyy);
|
|
76099
76169
|
}
|
|
76100
76170
|
}
|
|
76101
76171
|
|
|
@@ -76105,9 +76175,8 @@ struct DatePart {
|
|
|
76105
76175
|
if (mask & DOW) {
|
|
76106
76176
|
isodow = Date::ExtractISODayOfTheWeek(input);
|
|
76107
76177
|
ww = Date::ExtractISOWeekNumber(input);
|
|
76108
|
-
int32_t dow = isodow % 7;
|
|
76109
76178
|
if ((part_data = HasPartValue(part_values, DatePartSpecifier::DOW))) {
|
|
76110
|
-
part_data[idx] =
|
|
76179
|
+
part_data[idx] = DayOfWeekOperator::DayOfWeekFromISO(isodow);
|
|
76111
76180
|
}
|
|
76112
76181
|
if ((part_data = HasPartValue(part_values, DatePartSpecifier::ISODOW))) {
|
|
76113
76182
|
part_data[idx] = isodow;
|
|
@@ -76116,7 +76185,7 @@ struct DatePart {
|
|
|
76116
76185
|
part_data[idx] = ww;
|
|
76117
76186
|
}
|
|
76118
76187
|
if ((part_data = HasPartValue(part_values, DatePartSpecifier::YEARWEEK))) {
|
|
76119
|
-
part_data[idx] = yyyy
|
|
76188
|
+
part_data[idx] = YearWeekOperator::YearWeekFromParts(yyyy, ww);
|
|
76120
76189
|
}
|
|
76121
76190
|
}
|
|
76122
76191
|
|
|
@@ -76200,12 +76269,12 @@ int64_t DatePart::CenturyOperator::Operation(dtime_t input) {
|
|
|
76200
76269
|
}
|
|
76201
76270
|
|
|
76202
76271
|
template <>
|
|
76203
|
-
int64_t DatePart::
|
|
76272
|
+
int64_t DatePart::MillenniumOperator::Operation(interval_t input) {
|
|
76204
76273
|
return input.months / Interval::MONTHS_PER_MILLENIUM;
|
|
76205
76274
|
}
|
|
76206
76275
|
|
|
76207
76276
|
template <>
|
|
76208
|
-
int64_t DatePart::
|
|
76277
|
+
int64_t DatePart::MillenniumOperator::Operation(dtime_t input) {
|
|
76209
76278
|
throw NotImplementedException("\"time\" units \"millennium\" not recognized");
|
|
76210
76279
|
}
|
|
76211
76280
|
|
|
@@ -76422,17 +76491,17 @@ int64_t DatePart::EraOperator::Operation(dtime_t input) {
|
|
|
76422
76491
|
}
|
|
76423
76492
|
|
|
76424
76493
|
template <>
|
|
76425
|
-
int64_t DatePart::
|
|
76426
|
-
|
|
76494
|
+
int64_t DatePart::TimezoneOperator::Operation(date_t input) {
|
|
76495
|
+
throw NotImplementedException("\"date\" units \"timezone\" not recognized");
|
|
76427
76496
|
}
|
|
76428
76497
|
|
|
76429
76498
|
template <>
|
|
76430
|
-
int64_t DatePart::
|
|
76431
|
-
throw NotImplementedException("\"interval\" units \"
|
|
76499
|
+
int64_t DatePart::TimezoneOperator::Operation(interval_t input) {
|
|
76500
|
+
throw NotImplementedException("\"interval\" units \"timezone\" not recognized");
|
|
76432
76501
|
}
|
|
76433
76502
|
|
|
76434
76503
|
template <>
|
|
76435
|
-
int64_t DatePart::
|
|
76504
|
+
int64_t DatePart::TimezoneOperator::Operation(dtime_t input) {
|
|
76436
76505
|
return 0;
|
|
76437
76506
|
}
|
|
76438
76507
|
|
|
@@ -76467,7 +76536,13 @@ void DatePart::StructOperator::Operation(int64_t **part_values, const dtime_t &i
|
|
|
76467
76536
|
}
|
|
76468
76537
|
|
|
76469
76538
|
if (mask & ZONE) {
|
|
76470
|
-
if ((part_data = HasPartValue(part_values, DatePartSpecifier::
|
|
76539
|
+
if ((part_data = HasPartValue(part_values, DatePartSpecifier::TIMEZONE))) {
|
|
76540
|
+
part_data[idx] = 0;
|
|
76541
|
+
}
|
|
76542
|
+
if ((part_data = HasPartValue(part_values, DatePartSpecifier::TIMEZONE_HOUR))) {
|
|
76543
|
+
part_data[idx] = 0;
|
|
76544
|
+
}
|
|
76545
|
+
if ((part_data = HasPartValue(part_values, DatePartSpecifier::TIMEZONE_MINUTE))) {
|
|
76471
76546
|
part_data[idx] = 0;
|
|
76472
76547
|
}
|
|
76473
76548
|
}
|
|
@@ -76479,9 +76554,18 @@ void DatePart::StructOperator::Operation(int64_t **part_values, const timestamp_
|
|
|
76479
76554
|
date_t d;
|
|
76480
76555
|
dtime_t t;
|
|
76481
76556
|
Timestamp::Convert(input, d, t);
|
|
76482
|
-
|
|
76483
|
-
|
|
76484
|
-
|
|
76557
|
+
|
|
76558
|
+
// Both define epoch, and the correct value is the sum.
|
|
76559
|
+
// So mask it out and compute it separately.
|
|
76560
|
+
Operation(part_values, d, idx, mask & ~EPOCH);
|
|
76561
|
+
Operation(part_values, t, idx, mask & ~EPOCH);
|
|
76562
|
+
|
|
76563
|
+
if (mask & EPOCH) {
|
|
76564
|
+
auto part_data = HasPartValue(part_values, DatePartSpecifier::EPOCH);
|
|
76565
|
+
if (part_data) {
|
|
76566
|
+
part_data[idx] = EpochOperator::Operation<timestamp_t, int64_t>(input);
|
|
76567
|
+
}
|
|
76568
|
+
}
|
|
76485
76569
|
}
|
|
76486
76570
|
|
|
76487
76571
|
template <>
|
|
@@ -76553,7 +76637,7 @@ static int64_t ExtractElement(DatePartSpecifier type, T element) {
|
|
|
76553
76637
|
case DatePartSpecifier::CENTURY:
|
|
76554
76638
|
return DatePart::CenturyOperator::template Operation<T, int64_t>(element);
|
|
76555
76639
|
case DatePartSpecifier::MILLENNIUM:
|
|
76556
|
-
return DatePart::
|
|
76640
|
+
return DatePart::MillenniumOperator::template Operation<T, int64_t>(element);
|
|
76557
76641
|
case DatePartSpecifier::QUARTER:
|
|
76558
76642
|
return DatePart::QuarterOperator::template Operation<T, int64_t>(element);
|
|
76559
76643
|
case DatePartSpecifier::DOW:
|
|
@@ -76580,8 +76664,10 @@ static int64_t ExtractElement(DatePartSpecifier type, T element) {
|
|
|
76580
76664
|
return DatePart::HoursOperator::template Operation<T, int64_t>(element);
|
|
76581
76665
|
case DatePartSpecifier::ERA:
|
|
76582
76666
|
return DatePart::EraOperator::template Operation<T, int64_t>(element);
|
|
76583
|
-
case DatePartSpecifier::
|
|
76584
|
-
|
|
76667
|
+
case DatePartSpecifier::TIMEZONE:
|
|
76668
|
+
case DatePartSpecifier::TIMEZONE_HOUR:
|
|
76669
|
+
case DatePartSpecifier::TIMEZONE_MINUTE:
|
|
76670
|
+
return DatePart::TimezoneOperator::template Operation<T, int64_t>(element);
|
|
76585
76671
|
default:
|
|
76586
76672
|
throw NotImplementedException("Specifier type not implemented for DATEPART");
|
|
76587
76673
|
}
|
|
@@ -76741,14 +76827,14 @@ struct StructDatePart {
|
|
|
76741
76827
|
|
|
76742
76828
|
const auto count = args.size();
|
|
76743
76829
|
Vector &input = args.data[0];
|
|
76744
|
-
vector<int64_t *> part_values(int(DatePartSpecifier::
|
|
76830
|
+
vector<int64_t *> part_values(int(DatePartSpecifier::TIMEZONE_MINUTE) + 1, nullptr);
|
|
76745
76831
|
const auto part_mask = DatePart::StructOperator::GetMask(info.part_codes);
|
|
76746
76832
|
|
|
76747
76833
|
auto &child_entries = StructVector::GetEntries(result);
|
|
76748
76834
|
|
|
76749
76835
|
// The first computer of a part "owns" it
|
|
76750
76836
|
// and other requestors just reference the owner
|
|
76751
|
-
vector<size_t> owners(int(DatePartSpecifier::
|
|
76837
|
+
vector<size_t> owners(int(DatePartSpecifier::TIMEZONE_MINUTE) + 1, child_entries.size());
|
|
76752
76838
|
for (size_t col = 0; col < child_entries.size(); ++col) {
|
|
76753
76839
|
const auto part_index = size_t(info.part_codes[col]);
|
|
76754
76840
|
if (owners[part_index] == child_entries.size()) {
|
|
@@ -76847,13 +76933,16 @@ void DatePartFun::RegisterFunction(BuiltinFunctions &set) {
|
|
|
76847
76933
|
AddDatePartOperator<DatePart::DayOperator>(set, "day");
|
|
76848
76934
|
AddDatePartOperator<DatePart::DecadeOperator>(set, "decade");
|
|
76849
76935
|
AddDatePartOperator<DatePart::CenturyOperator>(set, "century");
|
|
76850
|
-
AddDatePartOperator<DatePart::
|
|
76936
|
+
AddDatePartOperator<DatePart::MillenniumOperator>(set, "millennium");
|
|
76851
76937
|
AddDatePartOperator<DatePart::QuarterOperator>(set, "quarter");
|
|
76852
76938
|
AddDatePartOperator<DatePart::DayOfWeekOperator>(set, "dayofweek");
|
|
76853
76939
|
AddDatePartOperator<DatePart::ISODayOfWeekOperator>(set, "isodow");
|
|
76854
76940
|
AddDatePartOperator<DatePart::DayOfYearOperator>(set, "dayofyear");
|
|
76855
76941
|
AddDatePartOperator<DatePart::WeekOperator>(set, "week");
|
|
76856
76942
|
AddDatePartOperator<DatePart::EraOperator>(set, "era");
|
|
76943
|
+
AddDatePartOperator<DatePart::TimezoneOperator>(set, "timezone");
|
|
76944
|
+
AddDatePartOperator<DatePart::TimezoneHourOperator>(set, "timezone_hour");
|
|
76945
|
+
AddDatePartOperator<DatePart::TimezoneMinuteOperator>(set, "timezone_minute");
|
|
76857
76946
|
AddTimePartOperator<DatePart::EpochOperator>(set, "epoch");
|
|
76858
76947
|
AddTimePartOperator<DatePart::MicrosecondsOperator>(set, "microsecond");
|
|
76859
76948
|
AddTimePartOperator<DatePart::MillisecondsOperator>(set, "millisecond");
|
|
@@ -77737,6 +77826,189 @@ void EpochFun::RegisterFunction(BuiltinFunctions &set) {
|
|
|
77737
77826
|
|
|
77738
77827
|
|
|
77739
77828
|
|
|
77829
|
+
//===----------------------------------------------------------------------===//
|
|
77830
|
+
// DuckDB
|
|
77831
|
+
//
|
|
77832
|
+
// duckdb/common/vector_operations/senary_executor.hpp
|
|
77833
|
+
//
|
|
77834
|
+
//
|
|
77835
|
+
//===----------------------------------------------------------------------===//
|
|
77836
|
+
|
|
77837
|
+
|
|
77838
|
+
|
|
77839
|
+
|
|
77840
|
+
|
|
77841
|
+
namespace duckdb {
|
|
77842
|
+
|
|
77843
|
+
struct SenaryExecutor {
|
|
77844
|
+
static const size_t NCOLS = 6;
|
|
77845
|
+
|
|
77846
|
+
template <class TA, class TB, class TC, class TD, class TE, class TF, class TR,
|
|
77847
|
+
class FUN = std::function<TR(TA, TB, TC, TD, TE, TF)>>
|
|
77848
|
+
static void Execute(DataChunk &input, Vector &result, FUN fun) {
|
|
77849
|
+
D_ASSERT(input.ColumnCount() >= NCOLS);
|
|
77850
|
+
const auto count = input.size();
|
|
77851
|
+
|
|
77852
|
+
bool all_constant = true;
|
|
77853
|
+
bool any_null = false;
|
|
77854
|
+
for (const auto &v : input.data) {
|
|
77855
|
+
if (v.GetVectorType() == VectorType::CONSTANT_VECTOR) {
|
|
77856
|
+
if (ConstantVector::IsNull(v)) {
|
|
77857
|
+
any_null = true;
|
|
77858
|
+
}
|
|
77859
|
+
} else {
|
|
77860
|
+
all_constant = false;
|
|
77861
|
+
break;
|
|
77862
|
+
}
|
|
77863
|
+
}
|
|
77864
|
+
|
|
77865
|
+
if (all_constant) {
|
|
77866
|
+
result.SetVectorType(VectorType::CONSTANT_VECTOR);
|
|
77867
|
+
if (any_null) {
|
|
77868
|
+
ConstantVector::SetNull(result, true);
|
|
77869
|
+
} else {
|
|
77870
|
+
auto adata = ConstantVector::GetData<TA>(input.data[0]);
|
|
77871
|
+
auto bdata = ConstantVector::GetData<TB>(input.data[1]);
|
|
77872
|
+
auto cdata = ConstantVector::GetData<TC>(input.data[2]);
|
|
77873
|
+
auto ddata = ConstantVector::GetData<TD>(input.data[3]);
|
|
77874
|
+
auto edata = ConstantVector::GetData<TE>(input.data[4]);
|
|
77875
|
+
auto fdata = ConstantVector::GetData<TF>(input.data[5]);
|
|
77876
|
+
auto result_data = ConstantVector::GetData<TR>(result);
|
|
77877
|
+
result_data[0] = fun(*adata, *bdata, *cdata, *ddata, *edata, *fdata);
|
|
77878
|
+
}
|
|
77879
|
+
} else {
|
|
77880
|
+
result.SetVectorType(VectorType::FLAT_VECTOR);
|
|
77881
|
+
auto result_data = FlatVector::GetData<TR>(result);
|
|
77882
|
+
auto &result_validity = FlatVector::Validity(result);
|
|
77883
|
+
|
|
77884
|
+
bool all_valid = true;
|
|
77885
|
+
vector<VectorData> vdata(NCOLS);
|
|
77886
|
+
for (size_t c = 0; c < NCOLS; ++c) {
|
|
77887
|
+
input.data[c].Orrify(count, vdata[c]);
|
|
77888
|
+
all_valid = all_valid && vdata[c].validity.AllValid();
|
|
77889
|
+
}
|
|
77890
|
+
|
|
77891
|
+
auto adata = (const TA *)(vdata[0].data);
|
|
77892
|
+
auto bdata = (const TB *)(vdata[1].data);
|
|
77893
|
+
auto cdata = (const TC *)(vdata[2].data);
|
|
77894
|
+
auto ddata = (const TD *)(vdata[3].data);
|
|
77895
|
+
auto edata = (const TE *)(vdata[4].data);
|
|
77896
|
+
auto fdata = (const TF *)(vdata[5].data);
|
|
77897
|
+
|
|
77898
|
+
vector<idx_t> idx(NCOLS);
|
|
77899
|
+
if (all_valid) {
|
|
77900
|
+
for (idx_t r = 0; r < count; ++r) {
|
|
77901
|
+
for (size_t c = 0; c < NCOLS; ++c) {
|
|
77902
|
+
idx[c] = vdata[c].sel->get_index(r);
|
|
77903
|
+
}
|
|
77904
|
+
result_data[r] =
|
|
77905
|
+
fun(adata[idx[0]], bdata[idx[1]], cdata[idx[2]], ddata[idx[3]], edata[idx[4]], fdata[idx[5]]);
|
|
77906
|
+
}
|
|
77907
|
+
} else {
|
|
77908
|
+
for (idx_t r = 0; r < count; ++r) {
|
|
77909
|
+
all_valid = true;
|
|
77910
|
+
for (size_t c = 0; c < NCOLS; ++c) {
|
|
77911
|
+
idx[c] = vdata[c].sel->get_index(r);
|
|
77912
|
+
if (!vdata[c].validity.RowIsValid(idx[c])) {
|
|
77913
|
+
result_validity.SetInvalid(r);
|
|
77914
|
+
all_valid = false;
|
|
77915
|
+
break;
|
|
77916
|
+
}
|
|
77917
|
+
}
|
|
77918
|
+
if (all_valid) {
|
|
77919
|
+
result_data[r] = fun(adata[idx[0]], bdata[idx[1]], cdata[idx[2]], ddata[idx[3]], edata[idx[4]],
|
|
77920
|
+
fdata[idx[5]]);
|
|
77921
|
+
}
|
|
77922
|
+
}
|
|
77923
|
+
}
|
|
77924
|
+
}
|
|
77925
|
+
}
|
|
77926
|
+
};
|
|
77927
|
+
|
|
77928
|
+
} // namespace duckdb
|
|
77929
|
+
|
|
77930
|
+
|
|
77931
|
+
namespace duckdb {
|
|
77932
|
+
|
|
77933
|
+
struct MakeDateOperator {
|
|
77934
|
+
template <typename YYYY, typename MM, typename DD, typename RESULT_TYPE>
|
|
77935
|
+
static RESULT_TYPE Operation(YYYY yyyy, MM mm, DD dd) {
|
|
77936
|
+
return Date::FromDate(yyyy, mm, dd);
|
|
77937
|
+
}
|
|
77938
|
+
};
|
|
77939
|
+
|
|
77940
|
+
template <typename T>
|
|
77941
|
+
static void ExecuteMakeDate(DataChunk &input, ExpressionState &state, Vector &result) {
|
|
77942
|
+
D_ASSERT(input.ColumnCount() == 3);
|
|
77943
|
+
auto &yyyy = input.data[0];
|
|
77944
|
+
auto &mm = input.data[1];
|
|
77945
|
+
auto &dd = input.data[2];
|
|
77946
|
+
|
|
77947
|
+
TernaryExecutor::Execute<T, T, T, date_t>(yyyy, mm, dd, result, input.size(),
|
|
77948
|
+
MakeDateOperator::Operation<T, T, T, date_t>);
|
|
77949
|
+
}
|
|
77950
|
+
|
|
77951
|
+
struct MakeTimeOperator {
|
|
77952
|
+
template <typename HH, typename MM, typename SS, typename RESULT_TYPE>
|
|
77953
|
+
static RESULT_TYPE Operation(HH hh, MM mm, SS ss) {
|
|
77954
|
+
int64_t secs = ss;
|
|
77955
|
+
int64_t micros = std::round((ss - secs) * Interval::MICROS_PER_SEC);
|
|
77956
|
+
return Time::FromTime(hh, mm, secs, micros);
|
|
77957
|
+
}
|
|
77958
|
+
};
|
|
77959
|
+
|
|
77960
|
+
template <typename T>
|
|
77961
|
+
static void ExecuteMakeTime(DataChunk &input, ExpressionState &state, Vector &result) {
|
|
77962
|
+
D_ASSERT(input.ColumnCount() == 3);
|
|
77963
|
+
auto &yyyy = input.data[0];
|
|
77964
|
+
auto &mm = input.data[1];
|
|
77965
|
+
auto &dd = input.data[2];
|
|
77966
|
+
|
|
77967
|
+
TernaryExecutor::Execute<T, T, double, dtime_t>(yyyy, mm, dd, result, input.size(),
|
|
77968
|
+
MakeTimeOperator::Operation<T, T, double, dtime_t>);
|
|
77969
|
+
}
|
|
77970
|
+
|
|
77971
|
+
struct MakeTimestampOperator {
|
|
77972
|
+
template <typename YYYY, typename MM, typename DD, typename HR, typename MN, typename SS, typename RESULT_TYPE>
|
|
77973
|
+
static RESULT_TYPE Operation(YYYY yyyy, MM mm, DD dd, HR hr, MN mn, SS ss) {
|
|
77974
|
+
const auto d = MakeDateOperator::Operation<YYYY, MM, DD, date_t>(yyyy, mm, dd);
|
|
77975
|
+
const auto t = MakeTimeOperator::Operation<HR, MN, SS, dtime_t>(hr, mn, ss);
|
|
77976
|
+
return Timestamp::FromDatetime(d, t);
|
|
77977
|
+
}
|
|
77978
|
+
};
|
|
77979
|
+
|
|
77980
|
+
template <typename T>
|
|
77981
|
+
static void ExecuteMakeTimestamp(DataChunk &input, ExpressionState &state, Vector &result) {
|
|
77982
|
+
D_ASSERT(input.ColumnCount() == 6);
|
|
77983
|
+
|
|
77984
|
+
auto func = MakeTimestampOperator::Operation<T, T, T, T, T, double, timestamp_t>;
|
|
77985
|
+
SenaryExecutor::Execute<T, T, T, T, T, double, timestamp_t>(input, result, func);
|
|
77986
|
+
}
|
|
77987
|
+
|
|
77988
|
+
void MakeDateFun::RegisterFunction(BuiltinFunctions &set) {
|
|
77989
|
+
ScalarFunctionSet make_date("make_date");
|
|
77990
|
+
make_date.AddFunction(ScalarFunction({LogicalType::BIGINT, LogicalType::BIGINT, LogicalType::BIGINT},
|
|
77991
|
+
LogicalType::DATE, ExecuteMakeDate<int64_t>));
|
|
77992
|
+
set.AddFunction(make_date);
|
|
77993
|
+
|
|
77994
|
+
ScalarFunctionSet make_time("make_time");
|
|
77995
|
+
make_time.AddFunction(ScalarFunction({LogicalType::BIGINT, LogicalType::BIGINT, LogicalType::DOUBLE},
|
|
77996
|
+
LogicalType::TIME, ExecuteMakeTime<int64_t>));
|
|
77997
|
+
set.AddFunction(make_time);
|
|
77998
|
+
|
|
77999
|
+
ScalarFunctionSet make_timestamp("make_timestamp");
|
|
78000
|
+
make_timestamp.AddFunction(ScalarFunction({LogicalType::BIGINT, LogicalType::BIGINT, LogicalType::BIGINT,
|
|
78001
|
+
LogicalType::BIGINT, LogicalType::BIGINT, LogicalType::DOUBLE},
|
|
78002
|
+
LogicalType::TIMESTAMP, ExecuteMakeTimestamp<int64_t>));
|
|
78003
|
+
set.AddFunction(make_timestamp);
|
|
78004
|
+
}
|
|
78005
|
+
|
|
78006
|
+
} // namespace duckdb
|
|
78007
|
+
|
|
78008
|
+
|
|
78009
|
+
|
|
78010
|
+
|
|
78011
|
+
|
|
77740
78012
|
|
|
77741
78013
|
|
|
77742
78014
|
|
|
@@ -79067,6 +79339,7 @@ void BuiltinFunctions::RegisterDateFunctions() {
|
|
|
79067
79339
|
Register<CurrentDateFun>();
|
|
79068
79340
|
Register<CurrentTimestampFun>();
|
|
79069
79341
|
Register<EpochFun>();
|
|
79342
|
+
Register<MakeDateFun>();
|
|
79070
79343
|
Register<StrfTimeFun>();
|
|
79071
79344
|
Register<StrpTimeFun>();
|
|
79072
79345
|
Register<ToIntervalFun>();
|
|
@@ -137063,6 +137336,10 @@ unique_ptr<ParsedExpression> Transformer::TransformFuncCall(duckdb_libpgquery::P
|
|
|
137063
137336
|
throw ParserException("ORDER BY is not implemented for window functions!");
|
|
137064
137337
|
}
|
|
137065
137338
|
|
|
137339
|
+
if (root->agg_filter) {
|
|
137340
|
+
throw ParserException("FILTER is not implemented for window functions!");
|
|
137341
|
+
}
|
|
137342
|
+
|
|
137066
137343
|
const auto win_fun_type = WindowToExpressionType(lowercase_name);
|
|
137067
137344
|
if (win_fun_type == ExpressionType::INVALID) {
|
|
137068
137345
|
throw InternalException("Unknown/unsupported window function");
|
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 "0.3.2-
|
|
14
|
+
#define DUCKDB_SOURCE_ID "e15519f1c"
|
|
15
|
+
#define DUCKDB_VERSION "0.3.2-dev898"
|
|
16
16
|
//===----------------------------------------------------------------------===//
|
|
17
17
|
// DuckDB
|
|
18
18
|
//
|