duckdb 0.3.5-dev1362.0 → 0.3.5-dev1364.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
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "duckdb",
3
3
  "main": "./lib/duckdb.js",
4
- "version": "0.3.5-dev1362.0",
4
+ "version": "0.3.5-dev1364.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -91585,6 +91585,7 @@ void DateSubFun::RegisterFunction(BuiltinFunctions &set) {
91585
91585
 
91586
91586
 
91587
91587
 
91588
+
91588
91589
  namespace duckdb {
91589
91590
 
91590
91591
  struct DateTrunc {
@@ -91602,32 +91603,28 @@ struct DateTrunc {
91602
91603
  struct MillenniumOperator {
91603
91604
  template <class TA, class TR>
91604
91605
  static inline TR Operation(TA input) {
91605
- date_t date = Timestamp::GetDate(input);
91606
- return Timestamp::FromDatetime(Date::FromDate((Date::ExtractYear(date) / 1000) * 1000, 1, 1), dtime_t(0));
91606
+ return Date::FromDate((Date::ExtractYear(input) / 1000) * 1000, 1, 1);
91607
91607
  }
91608
91608
  };
91609
91609
 
91610
91610
  struct CenturyOperator {
91611
91611
  template <class TA, class TR>
91612
91612
  static inline TR Operation(TA input) {
91613
- date_t date = Timestamp::GetDate(input);
91614
- return Timestamp::FromDatetime(Date::FromDate((Date::ExtractYear(date) / 100) * 100, 1, 1), dtime_t(0));
91613
+ return Date::FromDate((Date::ExtractYear(input) / 100) * 100, 1, 1);
91615
91614
  }
91616
91615
  };
91617
91616
 
91618
91617
  struct DecadeOperator {
91619
91618
  template <class TA, class TR>
91620
91619
  static inline TR Operation(TA input) {
91621
- date_t date = Timestamp::GetDate(input);
91622
- return Timestamp::FromDatetime(Date::FromDate((Date::ExtractYear(date) / 10) * 10, 1, 1), dtime_t(0));
91620
+ return Date::FromDate((Date::ExtractYear(input) / 10) * 10, 1, 1);
91623
91621
  }
91624
91622
  };
91625
91623
 
91626
91624
  struct YearOperator {
91627
91625
  template <class TA, class TR>
91628
91626
  static inline TR Operation(TA input) {
91629
- date_t date = Timestamp::GetDate(input);
91630
- return Timestamp::FromDatetime(Date::FromDate(Date::ExtractYear(date), 1, 1), dtime_t(0));
91627
+ return Date::FromDate(Date::ExtractYear(input), 1, 1);
91631
91628
  }
91632
91629
  };
91633
91630
 
@@ -91635,27 +91632,23 @@ struct DateTrunc {
91635
91632
  template <class TA, class TR>
91636
91633
  static inline TR Operation(TA input) {
91637
91634
  int32_t yyyy, mm, dd;
91638
- Date::Convert(Timestamp::GetDate(input), yyyy, mm, dd);
91635
+ Date::Convert(input, yyyy, mm, dd);
91639
91636
  mm = 1 + (((mm - 1) / 3) * 3);
91640
- return Timestamp::FromDatetime(Date::FromDate(yyyy, mm, 1), dtime_t(0));
91637
+ return Date::FromDate(yyyy, mm, 1);
91641
91638
  }
91642
91639
  };
91643
91640
 
91644
91641
  struct MonthOperator {
91645
91642
  template <class TA, class TR>
91646
91643
  static inline TR Operation(TA input) {
91647
- date_t date = Timestamp::GetDate(input);
91648
- return Timestamp::FromDatetime(Date::FromDate(Date::ExtractYear(date), Date::ExtractMonth(date), 1),
91649
- dtime_t(0));
91644
+ return Date::FromDate(Date::ExtractYear(input), Date::ExtractMonth(input), 1);
91650
91645
  }
91651
91646
  };
91652
91647
 
91653
91648
  struct WeekOperator {
91654
91649
  template <class TA, class TR>
91655
91650
  static inline TR Operation(TA input) {
91656
- date_t date = Timestamp::GetDate(input);
91657
-
91658
- return Timestamp::FromDatetime(Date::GetMondayOfCurrentWeek(date), dtime_t(0));
91651
+ return Date::GetMondayOfCurrentWeek(input);
91659
91652
  }
91660
91653
  };
91661
91654
 
@@ -91665,15 +91658,14 @@ struct DateTrunc {
91665
91658
  date_t date = Date::GetMondayOfCurrentWeek(input);
91666
91659
  date.days -= (Date::ExtractISOWeekNumber(date) - 1) * Interval::DAYS_PER_WEEK;
91667
91660
 
91668
- return Timestamp::FromDatetime(date, dtime_t(0));
91661
+ return date;
91669
91662
  }
91670
91663
  };
91671
91664
 
91672
91665
  struct DayOperator {
91673
91666
  template <class TA, class TR>
91674
91667
  static inline TR Operation(TA input) {
91675
- date_t date = Timestamp::GetDate(input);
91676
- return Timestamp::FromDatetime(date, dtime_t(0));
91668
+ return input;
91677
91669
  }
91678
91670
  };
91679
91671
 
@@ -91735,39 +91727,119 @@ struct DateTrunc {
91735
91727
  };
91736
91728
 
91737
91729
  // DATE specialisations
91730
+ template <>
91731
+ date_t DateTrunc::MillenniumOperator::Operation(timestamp_t input) {
91732
+ return MillenniumOperator::Operation<date_t, date_t>(Timestamp::GetDate(input));
91733
+ }
91734
+
91738
91735
  template <>
91739
91736
  timestamp_t DateTrunc::MillenniumOperator::Operation(date_t input) {
91740
- return MillenniumOperator::Operation<timestamp_t, timestamp_t>(Timestamp::FromDatetime(input, dtime_t(0)));
91737
+ return Timestamp::FromDatetime(MillenniumOperator::Operation<date_t, date_t>(input), dtime_t(0));
91738
+ }
91739
+
91740
+ template <>
91741
+ timestamp_t DateTrunc::MillenniumOperator::Operation(timestamp_t input) {
91742
+ return MillenniumOperator::Operation<date_t, timestamp_t>(Timestamp::GetDate(input));
91743
+ }
91744
+
91745
+ template <>
91746
+ date_t DateTrunc::CenturyOperator::Operation(timestamp_t input) {
91747
+ return CenturyOperator::Operation<date_t, date_t>(Timestamp::GetDate(input));
91741
91748
  }
91742
91749
 
91743
91750
  template <>
91744
91751
  timestamp_t DateTrunc::CenturyOperator::Operation(date_t input) {
91745
- return CenturyOperator::Operation<timestamp_t, timestamp_t>(Timestamp::FromDatetime(input, dtime_t(0)));
91752
+ return Timestamp::FromDatetime(CenturyOperator::Operation<date_t, date_t>(input), dtime_t(0));
91753
+ }
91754
+
91755
+ template <>
91756
+ timestamp_t DateTrunc::CenturyOperator::Operation(timestamp_t input) {
91757
+ return CenturyOperator::Operation<date_t, timestamp_t>(Timestamp::GetDate(input));
91758
+ }
91759
+
91760
+ template <>
91761
+ date_t DateTrunc::DecadeOperator::Operation(timestamp_t input) {
91762
+ return DecadeOperator::Operation<date_t, date_t>(Timestamp::GetDate(input));
91746
91763
  }
91747
91764
 
91748
91765
  template <>
91749
91766
  timestamp_t DateTrunc::DecadeOperator::Operation(date_t input) {
91750
- return DecadeOperator::Operation<timestamp_t, timestamp_t>(Timestamp::FromDatetime(input, dtime_t(0)));
91767
+ return Timestamp::FromDatetime(DecadeOperator::Operation<date_t, date_t>(input), dtime_t(0));
91768
+ }
91769
+
91770
+ template <>
91771
+ timestamp_t DateTrunc::DecadeOperator::Operation(timestamp_t input) {
91772
+ return DecadeOperator::Operation<date_t, timestamp_t>(Timestamp::GetDate(input));
91773
+ }
91774
+
91775
+ template <>
91776
+ date_t DateTrunc::YearOperator::Operation(timestamp_t input) {
91777
+ return YearOperator::Operation<date_t, date_t>(Timestamp::GetDate(input));
91751
91778
  }
91752
91779
 
91753
91780
  template <>
91754
91781
  timestamp_t DateTrunc::YearOperator::Operation(date_t input) {
91755
- return YearOperator::Operation<timestamp_t, timestamp_t>(Timestamp::FromDatetime(input, dtime_t(0)));
91782
+ return Timestamp::FromDatetime(YearOperator::Operation<date_t, date_t>(input), dtime_t(0));
91783
+ }
91784
+
91785
+ template <>
91786
+ timestamp_t DateTrunc::YearOperator::Operation(timestamp_t input) {
91787
+ return YearOperator::Operation<date_t, timestamp_t>(Timestamp::GetDate(input));
91788
+ }
91789
+
91790
+ template <>
91791
+ date_t DateTrunc::QuarterOperator::Operation(timestamp_t input) {
91792
+ return QuarterOperator::Operation<date_t, date_t>(Timestamp::GetDate(input));
91756
91793
  }
91757
91794
 
91758
91795
  template <>
91759
91796
  timestamp_t DateTrunc::QuarterOperator::Operation(date_t input) {
91760
- return QuarterOperator::Operation<timestamp_t, timestamp_t>(Timestamp::FromDatetime(input, dtime_t(0)));
91797
+ return Timestamp::FromDatetime(QuarterOperator::Operation<date_t, date_t>(input), dtime_t(0));
91798
+ }
91799
+
91800
+ template <>
91801
+ timestamp_t DateTrunc::QuarterOperator::Operation(timestamp_t input) {
91802
+ return QuarterOperator::Operation<date_t, timestamp_t>(Timestamp::GetDate(input));
91803
+ }
91804
+
91805
+ template <>
91806
+ date_t DateTrunc::MonthOperator::Operation(timestamp_t input) {
91807
+ return MonthOperator::Operation<date_t, date_t>(Timestamp::GetDate(input));
91761
91808
  }
91762
91809
 
91763
91810
  template <>
91764
91811
  timestamp_t DateTrunc::MonthOperator::Operation(date_t input) {
91765
- return MonthOperator::Operation<timestamp_t, timestamp_t>(Timestamp::FromDatetime(input, dtime_t(0)));
91812
+ return Timestamp::FromDatetime(MonthOperator::Operation<date_t, date_t>(input), dtime_t(0));
91813
+ }
91814
+
91815
+ template <>
91816
+ timestamp_t DateTrunc::MonthOperator::Operation(timestamp_t input) {
91817
+ return MonthOperator::Operation<date_t, timestamp_t>(Timestamp::GetDate(input));
91818
+ }
91819
+
91820
+ template <>
91821
+ date_t DateTrunc::WeekOperator::Operation(timestamp_t input) {
91822
+ return WeekOperator::Operation<date_t, date_t>(Timestamp::GetDate(input));
91766
91823
  }
91767
91824
 
91768
91825
  template <>
91769
91826
  timestamp_t DateTrunc::WeekOperator::Operation(date_t input) {
91770
- return WeekOperator::Operation<timestamp_t, timestamp_t>(Timestamp::FromDatetime(input, dtime_t(0)));
91827
+ return Timestamp::FromDatetime(WeekOperator::Operation<date_t, date_t>(input), dtime_t(0));
91828
+ }
91829
+
91830
+ template <>
91831
+ timestamp_t DateTrunc::WeekOperator::Operation(timestamp_t input) {
91832
+ return WeekOperator::Operation<date_t, timestamp_t>(Timestamp::GetDate(input));
91833
+ }
91834
+
91835
+ template <>
91836
+ date_t DateTrunc::ISOYearOperator::Operation(timestamp_t input) {
91837
+ return ISOYearOperator::Operation<date_t, date_t>(Timestamp::GetDate(input));
91838
+ }
91839
+
91840
+ template <>
91841
+ timestamp_t DateTrunc::ISOYearOperator::Operation(date_t input) {
91842
+ return Timestamp::FromDatetime(ISOYearOperator::Operation<date_t, date_t>(input), dtime_t(0));
91771
91843
  }
91772
91844
 
91773
91845
  template <>
@@ -91775,9 +91847,24 @@ timestamp_t DateTrunc::ISOYearOperator::Operation(timestamp_t input) {
91775
91847
  return ISOYearOperator::Operation<date_t, timestamp_t>(Timestamp::GetDate(input));
91776
91848
  }
91777
91849
 
91850
+ template <>
91851
+ date_t DateTrunc::DayOperator::Operation(timestamp_t input) {
91852
+ return DayOperator::Operation<date_t, date_t>(Timestamp::GetDate(input));
91853
+ }
91854
+
91778
91855
  template <>
91779
91856
  timestamp_t DateTrunc::DayOperator::Operation(date_t input) {
91780
- return Timestamp::FromDatetime(input, dtime_t(0));
91857
+ return Timestamp::FromDatetime(DayOperator::Operation<date_t, date_t>(input), dtime_t(0));
91858
+ }
91859
+
91860
+ template <>
91861
+ timestamp_t DateTrunc::DayOperator::Operation(timestamp_t input) {
91862
+ return DayOperator::Operation<date_t, timestamp_t>(Timestamp::GetDate(input));
91863
+ }
91864
+
91865
+ template <>
91866
+ date_t DateTrunc::HourOperator::Operation(date_t input) {
91867
+ return DayOperator::Operation<date_t, date_t>(input);
91781
91868
  }
91782
91869
 
91783
91870
  template <>
@@ -91785,26 +91872,71 @@ timestamp_t DateTrunc::HourOperator::Operation(date_t input) {
91785
91872
  return DayOperator::Operation<date_t, timestamp_t>(input);
91786
91873
  }
91787
91874
 
91875
+ template <>
91876
+ date_t DateTrunc::HourOperator::Operation(timestamp_t input) {
91877
+ return Timestamp::GetDate(HourOperator::Operation<timestamp_t, timestamp_t>(input));
91878
+ }
91879
+
91880
+ template <>
91881
+ date_t DateTrunc::MinuteOperator::Operation(date_t input) {
91882
+ return DayOperator::Operation<date_t, date_t>(input);
91883
+ }
91884
+
91788
91885
  template <>
91789
91886
  timestamp_t DateTrunc::MinuteOperator::Operation(date_t input) {
91790
91887
  return DayOperator::Operation<date_t, timestamp_t>(input);
91791
91888
  }
91792
91889
 
91890
+ template <>
91891
+ date_t DateTrunc::MinuteOperator::Operation(timestamp_t input) {
91892
+ return Timestamp::GetDate(HourOperator::Operation<timestamp_t, timestamp_t>(input));
91893
+ }
91894
+
91895
+ template <>
91896
+ date_t DateTrunc::SecondOperator::Operation(date_t input) {
91897
+ return DayOperator::Operation<date_t, date_t>(input);
91898
+ }
91899
+
91793
91900
  template <>
91794
91901
  timestamp_t DateTrunc::SecondOperator::Operation(date_t input) {
91795
91902
  return DayOperator::Operation<date_t, timestamp_t>(input);
91796
91903
  }
91797
91904
 
91905
+ template <>
91906
+ date_t DateTrunc::SecondOperator::Operation(timestamp_t input) {
91907
+ return Timestamp::GetDate(DayOperator::Operation<timestamp_t, timestamp_t>(input));
91908
+ }
91909
+
91910
+ template <>
91911
+ date_t DateTrunc::MillisecondOperator::Operation(date_t input) {
91912
+ return DayOperator::Operation<date_t, date_t>(input);
91913
+ }
91914
+
91798
91915
  template <>
91799
91916
  timestamp_t DateTrunc::MillisecondOperator::Operation(date_t input) {
91800
91917
  return DayOperator::Operation<date_t, timestamp_t>(input);
91801
91918
  }
91802
91919
 
91920
+ template <>
91921
+ date_t DateTrunc::MillisecondOperator::Operation(timestamp_t input) {
91922
+ return Timestamp::GetDate(MillisecondOperator::Operation<timestamp_t, timestamp_t>(input));
91923
+ }
91924
+
91925
+ template <>
91926
+ date_t DateTrunc::MicrosecondOperator::Operation(date_t input) {
91927
+ return DayOperator::Operation<date_t, date_t>(input);
91928
+ }
91929
+
91803
91930
  template <>
91804
91931
  timestamp_t DateTrunc::MicrosecondOperator::Operation(date_t input) {
91805
91932
  return DayOperator::Operation<date_t, timestamp_t>(input);
91806
91933
  }
91807
91934
 
91935
+ template <>
91936
+ date_t DateTrunc::MicrosecondOperator::Operation(timestamp_t input) {
91937
+ return Timestamp::GetDate(MicrosecondOperator::Operation<timestamp_t, timestamp_t>(input));
91938
+ }
91939
+
91808
91940
  // INTERVAL specialisations
91809
91941
  template <>
91810
91942
  interval_t DateTrunc::MillenniumOperator::Operation(interval_t input) {
@@ -92028,12 +92160,58 @@ static void DateTruncFunction(DataChunk &args, ExpressionState &state, Vector &r
92028
92160
  }
92029
92161
  }
92030
92162
 
92163
+ static unique_ptr<FunctionData> DateTruncBind(ClientContext &context, ScalarFunction &bound_function,
92164
+ vector<unique_ptr<Expression>> &arguments) {
92165
+ if (!arguments[0]->IsFoldable()) {
92166
+ return nullptr;
92167
+ }
92168
+
92169
+ // Rebind to return a date if we are truncating that far
92170
+ Value part_value = ExpressionExecutor::EvaluateScalar(*arguments[0]);
92171
+ if (part_value.IsNull()) {
92172
+ return nullptr;
92173
+ }
92174
+ const auto part_name = part_value.ToString();
92175
+ const auto part_code = GetDatePartSpecifier(part_name);
92176
+ switch (part_code) {
92177
+ case DatePartSpecifier::MILLENNIUM:
92178
+ case DatePartSpecifier::CENTURY:
92179
+ case DatePartSpecifier::DECADE:
92180
+ case DatePartSpecifier::YEAR:
92181
+ case DatePartSpecifier::QUARTER:
92182
+ case DatePartSpecifier::MONTH:
92183
+ case DatePartSpecifier::WEEK:
92184
+ case DatePartSpecifier::YEARWEEK:
92185
+ case DatePartSpecifier::ISOYEAR:
92186
+ case DatePartSpecifier::DAY:
92187
+ case DatePartSpecifier::DOW:
92188
+ case DatePartSpecifier::ISODOW:
92189
+ case DatePartSpecifier::DOY:
92190
+ switch (arguments[1]->return_type.id()) {
92191
+ case LogicalType::TIMESTAMP:
92192
+ bound_function.function = DateTruncFunction<timestamp_t, date_t>;
92193
+ break;
92194
+ case LogicalType::DATE:
92195
+ bound_function.function = DateTruncFunction<date_t, date_t>;
92196
+ break;
92197
+ default:
92198
+ break;
92199
+ }
92200
+ bound_function.return_type = LogicalType::DATE;
92201
+ break;
92202
+ default:
92203
+ break;
92204
+ }
92205
+
92206
+ return nullptr;
92207
+ }
92208
+
92031
92209
  void DateTruncFun::RegisterFunction(BuiltinFunctions &set) {
92032
92210
  ScalarFunctionSet date_trunc("date_trunc");
92033
92211
  date_trunc.AddFunction(ScalarFunction({LogicalType::VARCHAR, LogicalType::TIMESTAMP}, LogicalType::TIMESTAMP,
92034
- DateTruncFunction<timestamp_t, timestamp_t>));
92212
+ DateTruncFunction<timestamp_t, timestamp_t>, false, false, DateTruncBind));
92035
92213
  date_trunc.AddFunction(ScalarFunction({LogicalType::VARCHAR, LogicalType::DATE}, LogicalType::TIMESTAMP,
92036
- DateTruncFunction<date_t, timestamp_t>));
92214
+ DateTruncFunction<date_t, timestamp_t>, false, false, DateTruncBind));
92037
92215
  date_trunc.AddFunction(ScalarFunction({LogicalType::VARCHAR, LogicalType::INTERVAL}, LogicalType::INTERVAL,
92038
92216
  DateTruncFunction<interval_t, interval_t>));
92039
92217
  set.AddFunction(date_trunc);
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 "c46211d64"
15
- #define DUCKDB_VERSION "v0.3.5-dev1362"
14
+ #define DUCKDB_SOURCE_ID "aa105267d"
15
+ #define DUCKDB_VERSION "v0.3.5-dev1364"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //