duckdb 0.3.2-dev872.0 → 0.3.2-dev890.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.2-dev872.0",
4
+ "version": "0.3.2-dev890.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -32120,7 +32120,9 @@ enum class DatePartSpecifier : uint8_t {
32120
32120
  DOY,
32121
32121
  YEARWEEK,
32122
32122
  ERA,
32123
- OFFSET
32123
+ TIMEZONE,
32124
+ TIMEZONE_HOUR,
32125
+ TIMEZONE_MINUTE
32124
32126
  };
32125
32127
 
32126
32128
  DUCKDB_API bool TryGetDatePartSpecifier(const string &specifier, DatePartSpecifier &result);
@@ -75549,7 +75551,7 @@ bool TryGetDatePartSpecifier(const string &specifier_p, DatePartSpecifier &resul
75549
75551
  result = DatePartSpecifier::DECADE;
75550
75552
  } else if (specifier == "century" || specifier == "centuries") {
75551
75553
  result = DatePartSpecifier::CENTURY;
75552
- } else if (specifier == "millennium" || specifier == "millennia") {
75554
+ } else if (specifier == "millennium" || specifier == "millennia" || specifier == "millenium") {
75553
75555
  result = DatePartSpecifier::MILLENNIUM;
75554
75556
  } else if (specifier == "microseconds" || specifier == "microsecond") {
75555
75557
  result = DatePartSpecifier::MICROSECONDS;
@@ -75585,8 +75587,12 @@ bool TryGetDatePartSpecifier(const string &specifier_p, DatePartSpecifier &resul
75585
75587
  result = DatePartSpecifier::YEARWEEK;
75586
75588
  } else if (specifier == "era") {
75587
75589
  result = DatePartSpecifier::ERA;
75588
- } else if (specifier == "offset") {
75589
- result = DatePartSpecifier::OFFSET;
75590
+ } else if (specifier == "timezone") {
75591
+ result = DatePartSpecifier::TIMEZONE;
75592
+ } else if (specifier == "timezone_hour") {
75593
+ result = DatePartSpecifier::TIMEZONE_HOUR;
75594
+ } else if (specifier == "timezone_minute") {
75595
+ result = DatePartSpecifier::TIMEZONE_MINUTE;
75590
75596
  } else {
75591
75597
  return false;
75592
75598
  }
@@ -75635,7 +75641,9 @@ DatePartSpecifier GetDateTypePartSpecifier(const string &specifier, LogicalType
75635
75641
  case DatePartSpecifier::MINUTE:
75636
75642
  case DatePartSpecifier::HOUR:
75637
75643
  case DatePartSpecifier::EPOCH:
75638
- case DatePartSpecifier::OFFSET:
75644
+ case DatePartSpecifier::TIMEZONE:
75645
+ case DatePartSpecifier::TIMEZONE_HOUR:
75646
+ case DatePartSpecifier::TIMEZONE_MINUTE:
75639
75647
  return part;
75640
75648
  default:
75641
75649
  break;
@@ -75760,9 +75768,15 @@ struct DatePart {
75760
75768
  };
75761
75769
 
75762
75770
  struct DecadeOperator {
75771
+ // From the PG docs: "The year field divided by 10"
75772
+ template <typename TR>
75773
+ static inline TR DecadeFromYear(TR yyyy) {
75774
+ return yyyy / 10;
75775
+ }
75776
+
75763
75777
  template <class TA, class TR>
75764
75778
  static inline TR Operation(TA input) {
75765
- return YearOperator::Operation<TA, TR>(input) / 10;
75779
+ return DecadeFromYear(YearOperator::Operation<TA, TR>(input));
75766
75780
  }
75767
75781
 
75768
75782
  template <class T>
@@ -75774,9 +75788,25 @@ struct DatePart {
75774
75788
  };
75775
75789
 
75776
75790
  struct CenturyOperator {
75791
+ // From the PG docs:
75792
+ // "The first century starts at 0001-01-01 00:00:00 AD, although they did not know it at the time.
75793
+ // This definition applies to all Gregorian calendar countries.
75794
+ // There is no century number 0, you go from -1 century to 1 century.
75795
+ // If you disagree with this, please write your complaint to: Pope, Cathedral Saint-Peter of Roma, Vatican."
75796
+ // (To be fair, His Holiness had nothing to do with this -
75797
+ // it was the lack of zero in the counting systems of the time...)
75798
+ template <typename TR>
75799
+ static inline TR CenturyFromYear(TR yyyy) {
75800
+ if (yyyy > 0) {
75801
+ return ((yyyy - 1) / 100) + 1;
75802
+ } else {
75803
+ return (yyyy / 100) - 1;
75804
+ }
75805
+ }
75806
+
75777
75807
  template <class TA, class TR>
75778
75808
  static inline TR Operation(TA input) {
75779
- return ((YearOperator::Operation<TA, TR>(input) - 1) / 100) + 1;
75809
+ return CenturyFromYear(YearOperator::Operation<TA, TR>(input));
75780
75810
  }
75781
75811
 
75782
75812
  template <class T>
@@ -75787,24 +75817,39 @@ struct DatePart {
75787
75817
  }
75788
75818
  };
75789
75819
 
75790
- struct MilleniumOperator {
75820
+ struct MillenniumOperator {
75821
+ // See the century comment
75822
+ template <typename TR>
75823
+ static inline TR MillenniumFromYear(TR yyyy) {
75824
+ if (yyyy > 0) {
75825
+ return ((yyyy - 1) / 1000) + 1;
75826
+ } else {
75827
+ return (yyyy / 1000) - 1;
75828
+ }
75829
+ }
75830
+
75791
75831
  template <class TA, class TR>
75792
75832
  static inline TR Operation(TA input) {
75793
- return ((YearOperator::Operation<TA, TR>(input) - 1) / 1000) + 1;
75833
+ return MillenniumFromYear<TR>(YearOperator::Operation<TA, TR>(input));
75794
75834
  }
75795
75835
 
75796
75836
  template <class T>
75797
75837
  static unique_ptr<BaseStatistics> PropagateStatistics(ClientContext &context, BoundFunctionExpression &expr,
75798
75838
  FunctionData *bind_data,
75799
75839
  vector<unique_ptr<BaseStatistics>> &child_stats) {
75800
- return PropagateDatePartStatistics<T, MilleniumOperator>(child_stats);
75840
+ return PropagateDatePartStatistics<T, MillenniumOperator>(child_stats);
75801
75841
  }
75802
75842
  };
75803
75843
 
75804
75844
  struct QuarterOperator {
75845
+ template <class TR>
75846
+ static inline TR QuarterFromMonth(TR mm) {
75847
+ return (mm - 1) / Interval::MONTHS_PER_QUARTER + 1;
75848
+ }
75849
+
75805
75850
  template <class TA, class TR>
75806
75851
  static inline TR Operation(TA input) {
75807
- return (Date::ExtractMonth(input) - 1) / Interval::MONTHS_PER_QUARTER + 1;
75852
+ return QuarterFromMonth(Date::ExtractMonth(input));
75808
75853
  }
75809
75854
 
75810
75855
  template <class T>
@@ -75817,11 +75862,16 @@ struct DatePart {
75817
75862
  };
75818
75863
 
75819
75864
  struct DayOfWeekOperator {
75820
- template <class TA, class TR>
75821
- static inline TR Operation(TA input) {
75865
+ template <class TR>
75866
+ static inline TR DayOfWeekFromISO(TR isodow) {
75822
75867
  // day of the week (Sunday = 0, Saturday = 6)
75823
75868
  // turn sunday into 0 by doing mod 7
75824
- return Date::ExtractISODayOfTheWeek(input) % 7;
75869
+ return isodow % 7;
75870
+ }
75871
+
75872
+ template <class TA, class TR>
75873
+ static inline TR Operation(TA input) {
75874
+ return DayOfWeekFromISO(Date::ExtractISODayOfTheWeek(input));
75825
75875
  }
75826
75876
 
75827
75877
  template <class T>
@@ -75876,9 +75926,14 @@ struct DatePart {
75876
75926
  };
75877
75927
 
75878
75928
  struct YearWeekOperator {
75929
+ template <class TR>
75930
+ static inline TR YearWeekFromParts(TR yyyy, TR ww) {
75931
+ return yyyy * 100 + ((yyyy > 0) ? ww : -ww);
75932
+ }
75933
+
75879
75934
  template <class TA, class TR>
75880
75935
  static inline TR Operation(TA input) {
75881
- return YearOperator::Operation<TA, TR>(input) * 100 + WeekOperator::Operation<TA, TR>(input);
75936
+ return YearWeekFromParts(YearOperator::Operation<TA, TR>(input), WeekOperator::Operation<TA, TR>(input));
75882
75937
  }
75883
75938
 
75884
75939
  template <class T>
@@ -75974,9 +76029,14 @@ struct DatePart {
75974
76029
  };
75975
76030
 
75976
76031
  struct EraOperator {
76032
+ template <class TR>
76033
+ static inline TR EraFromYear(TR yyyy) {
76034
+ return yyyy > 0 ? 1 : 0;
76035
+ }
76036
+
75977
76037
  template <class TA, class TR>
75978
76038
  static inline TR Operation(TA input) {
75979
- return Date::ExtractYear(input) > 0 ? 1 : 0;
76039
+ return EraFromYear(Date::ExtractYear(input));
75980
76040
  }
75981
76041
 
75982
76042
  template <class T>
@@ -75987,7 +76047,7 @@ struct DatePart {
75987
76047
  }
75988
76048
  };
75989
76049
 
75990
- struct OffsetOperator {
76050
+ struct TimezoneOperator {
75991
76051
  template <class TA, class TR>
75992
76052
  static inline TR Operation(TA input) {
75993
76053
  // Regular timestamps are UTC.
@@ -76002,6 +76062,10 @@ struct DatePart {
76002
76062
  }
76003
76063
  };
76004
76064
 
76065
+ // These are all zero and have the same restrictions
76066
+ using TimezoneHourOperator = TimezoneOperator;
76067
+ using TimezoneMinuteOperator = TimezoneOperator;
76068
+
76005
76069
  struct StructOperator {
76006
76070
  using part_codes_t = vector<DatePartSpecifier>;
76007
76071
  using part_mask_t = uint64_t;
@@ -76051,7 +76115,9 @@ struct DatePart {
76051
76115
  case DatePartSpecifier::HOUR:
76052
76116
  mask |= TIME;
76053
76117
  break;
76054
- case DatePartSpecifier::OFFSET:
76118
+ case DatePartSpecifier::TIMEZONE:
76119
+ case DatePartSpecifier::TIMEZONE_HOUR:
76120
+ case DatePartSpecifier::TIMEZONE_MINUTE:
76055
76121
  mask |= ZONE;
76056
76122
  break;
76057
76123
  }
@@ -76083,19 +76149,19 @@ struct DatePart {
76083
76149
  part_data[idx] = dd;
76084
76150
  }
76085
76151
  if ((part_data = HasPartValue(part_values, DatePartSpecifier::DECADE))) {
76086
- part_data[idx] = yyyy / 10;
76152
+ part_data[idx] = DecadeOperator::DecadeFromYear(yyyy);
76087
76153
  }
76088
76154
  if ((part_data = HasPartValue(part_values, DatePartSpecifier::CENTURY))) {
76089
- part_data[idx] = (yyyy - 1) / 100 + 1;
76155
+ part_data[idx] = CenturyOperator::CenturyFromYear(yyyy);
76090
76156
  }
76091
76157
  if ((part_data = HasPartValue(part_values, DatePartSpecifier::MILLENNIUM))) {
76092
- part_data[idx] = (yyyy - 1) / 1000 + 1;
76158
+ part_data[idx] = MillenniumOperator::MillenniumFromYear(yyyy);
76093
76159
  }
76094
76160
  if ((part_data = HasPartValue(part_values, DatePartSpecifier::QUARTER))) {
76095
- part_data[idx] = (mm - 1) / Interval::MONTHS_PER_QUARTER + 1;
76161
+ part_data[idx] = QuarterOperator::QuarterFromMonth(mm);
76096
76162
  }
76097
76163
  if ((part_data = HasPartValue(part_values, DatePartSpecifier::ERA))) {
76098
- part_data[idx] = yyyy > 0 ? 1 : 0;
76164
+ part_data[idx] = EraOperator::EraFromYear(yyyy);
76099
76165
  }
76100
76166
  }
76101
76167
 
@@ -76105,9 +76171,8 @@ struct DatePart {
76105
76171
  if (mask & DOW) {
76106
76172
  isodow = Date::ExtractISODayOfTheWeek(input);
76107
76173
  ww = Date::ExtractISOWeekNumber(input);
76108
- int32_t dow = isodow % 7;
76109
76174
  if ((part_data = HasPartValue(part_values, DatePartSpecifier::DOW))) {
76110
- part_data[idx] = dow;
76175
+ part_data[idx] = DayOfWeekOperator::DayOfWeekFromISO(isodow);
76111
76176
  }
76112
76177
  if ((part_data = HasPartValue(part_values, DatePartSpecifier::ISODOW))) {
76113
76178
  part_data[idx] = isodow;
@@ -76116,7 +76181,7 @@ struct DatePart {
76116
76181
  part_data[idx] = ww;
76117
76182
  }
76118
76183
  if ((part_data = HasPartValue(part_values, DatePartSpecifier::YEARWEEK))) {
76119
- part_data[idx] = yyyy * 100 + ww;
76184
+ part_data[idx] = YearWeekOperator::YearWeekFromParts(yyyy, ww);
76120
76185
  }
76121
76186
  }
76122
76187
 
@@ -76200,12 +76265,12 @@ int64_t DatePart::CenturyOperator::Operation(dtime_t input) {
76200
76265
  }
76201
76266
 
76202
76267
  template <>
76203
- int64_t DatePart::MilleniumOperator::Operation(interval_t input) {
76268
+ int64_t DatePart::MillenniumOperator::Operation(interval_t input) {
76204
76269
  return input.months / Interval::MONTHS_PER_MILLENIUM;
76205
76270
  }
76206
76271
 
76207
76272
  template <>
76208
- int64_t DatePart::MilleniumOperator::Operation(dtime_t input) {
76273
+ int64_t DatePart::MillenniumOperator::Operation(dtime_t input) {
76209
76274
  throw NotImplementedException("\"time\" units \"millennium\" not recognized");
76210
76275
  }
76211
76276
 
@@ -76422,17 +76487,17 @@ int64_t DatePart::EraOperator::Operation(dtime_t input) {
76422
76487
  }
76423
76488
 
76424
76489
  template <>
76425
- int64_t DatePart::OffsetOperator::Operation(timestamp_t input) {
76426
- return 0;
76490
+ int64_t DatePart::TimezoneOperator::Operation(date_t input) {
76491
+ throw NotImplementedException("\"date\" units \"timezone\" not recognized");
76427
76492
  }
76428
76493
 
76429
76494
  template <>
76430
- int64_t DatePart::OffsetOperator::Operation(interval_t input) {
76431
- throw NotImplementedException("\"interval\" units \"offset\" not recognized");
76495
+ int64_t DatePart::TimezoneOperator::Operation(interval_t input) {
76496
+ throw NotImplementedException("\"interval\" units \"timezone\" not recognized");
76432
76497
  }
76433
76498
 
76434
76499
  template <>
76435
- int64_t DatePart::OffsetOperator::Operation(dtime_t input) {
76500
+ int64_t DatePart::TimezoneOperator::Operation(dtime_t input) {
76436
76501
  return 0;
76437
76502
  }
76438
76503
 
@@ -76467,7 +76532,13 @@ void DatePart::StructOperator::Operation(int64_t **part_values, const dtime_t &i
76467
76532
  }
76468
76533
 
76469
76534
  if (mask & ZONE) {
76470
- if ((part_data = HasPartValue(part_values, DatePartSpecifier::OFFSET))) {
76535
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::TIMEZONE))) {
76536
+ part_data[idx] = 0;
76537
+ }
76538
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::TIMEZONE_HOUR))) {
76539
+ part_data[idx] = 0;
76540
+ }
76541
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::TIMEZONE_MINUTE))) {
76471
76542
  part_data[idx] = 0;
76472
76543
  }
76473
76544
  }
@@ -76479,9 +76550,18 @@ void DatePart::StructOperator::Operation(int64_t **part_values, const timestamp_
76479
76550
  date_t d;
76480
76551
  dtime_t t;
76481
76552
  Timestamp::Convert(input, d, t);
76482
- // Time first because they both define epoch.
76483
- Operation(part_values, t, idx, mask);
76484
- Operation(part_values, d, idx, mask);
76553
+
76554
+ // Both define epoch, and the correct value is the sum.
76555
+ // So mask it out and compute it separately.
76556
+ Operation(part_values, d, idx, mask & ~EPOCH);
76557
+ Operation(part_values, t, idx, mask & ~EPOCH);
76558
+
76559
+ if (mask & EPOCH) {
76560
+ auto part_data = HasPartValue(part_values, DatePartSpecifier::EPOCH);
76561
+ if (part_data) {
76562
+ part_data[idx] = EpochOperator::Operation<timestamp_t, int64_t>(input);
76563
+ }
76564
+ }
76485
76565
  }
76486
76566
 
76487
76567
  template <>
@@ -76553,7 +76633,7 @@ static int64_t ExtractElement(DatePartSpecifier type, T element) {
76553
76633
  case DatePartSpecifier::CENTURY:
76554
76634
  return DatePart::CenturyOperator::template Operation<T, int64_t>(element);
76555
76635
  case DatePartSpecifier::MILLENNIUM:
76556
- return DatePart::MilleniumOperator::template Operation<T, int64_t>(element);
76636
+ return DatePart::MillenniumOperator::template Operation<T, int64_t>(element);
76557
76637
  case DatePartSpecifier::QUARTER:
76558
76638
  return DatePart::QuarterOperator::template Operation<T, int64_t>(element);
76559
76639
  case DatePartSpecifier::DOW:
@@ -76580,8 +76660,10 @@ static int64_t ExtractElement(DatePartSpecifier type, T element) {
76580
76660
  return DatePart::HoursOperator::template Operation<T, int64_t>(element);
76581
76661
  case DatePartSpecifier::ERA:
76582
76662
  return DatePart::EraOperator::template Operation<T, int64_t>(element);
76583
- case DatePartSpecifier::OFFSET:
76584
- return DatePart::OffsetOperator::template Operation<T, int64_t>(element);
76663
+ case DatePartSpecifier::TIMEZONE:
76664
+ case DatePartSpecifier::TIMEZONE_HOUR:
76665
+ case DatePartSpecifier::TIMEZONE_MINUTE:
76666
+ return DatePart::TimezoneOperator::template Operation<T, int64_t>(element);
76585
76667
  default:
76586
76668
  throw NotImplementedException("Specifier type not implemented for DATEPART");
76587
76669
  }
@@ -76741,14 +76823,14 @@ struct StructDatePart {
76741
76823
 
76742
76824
  const auto count = args.size();
76743
76825
  Vector &input = args.data[0];
76744
- vector<int64_t *> part_values(int(DatePartSpecifier::OFFSET) + 1, nullptr);
76826
+ vector<int64_t *> part_values(int(DatePartSpecifier::TIMEZONE_MINUTE) + 1, nullptr);
76745
76827
  const auto part_mask = DatePart::StructOperator::GetMask(info.part_codes);
76746
76828
 
76747
76829
  auto &child_entries = StructVector::GetEntries(result);
76748
76830
 
76749
76831
  // The first computer of a part "owns" it
76750
76832
  // and other requestors just reference the owner
76751
- vector<size_t> owners(int(DatePartSpecifier::OFFSET) + 1, child_entries.size());
76833
+ vector<size_t> owners(int(DatePartSpecifier::TIMEZONE_MINUTE) + 1, child_entries.size());
76752
76834
  for (size_t col = 0; col < child_entries.size(); ++col) {
76753
76835
  const auto part_index = size_t(info.part_codes[col]);
76754
76836
  if (owners[part_index] == child_entries.size()) {
@@ -76847,13 +76929,16 @@ void DatePartFun::RegisterFunction(BuiltinFunctions &set) {
76847
76929
  AddDatePartOperator<DatePart::DayOperator>(set, "day");
76848
76930
  AddDatePartOperator<DatePart::DecadeOperator>(set, "decade");
76849
76931
  AddDatePartOperator<DatePart::CenturyOperator>(set, "century");
76850
- AddDatePartOperator<DatePart::MilleniumOperator>(set, "millennium");
76932
+ AddDatePartOperator<DatePart::MillenniumOperator>(set, "millennium");
76851
76933
  AddDatePartOperator<DatePart::QuarterOperator>(set, "quarter");
76852
76934
  AddDatePartOperator<DatePart::DayOfWeekOperator>(set, "dayofweek");
76853
76935
  AddDatePartOperator<DatePart::ISODayOfWeekOperator>(set, "isodow");
76854
76936
  AddDatePartOperator<DatePart::DayOfYearOperator>(set, "dayofyear");
76855
76937
  AddDatePartOperator<DatePart::WeekOperator>(set, "week");
76856
76938
  AddDatePartOperator<DatePart::EraOperator>(set, "era");
76939
+ AddDatePartOperator<DatePart::TimezoneOperator>(set, "timezone");
76940
+ AddDatePartOperator<DatePart::TimezoneHourOperator>(set, "timezone_hour");
76941
+ AddDatePartOperator<DatePart::TimezoneMinuteOperator>(set, "timezone_minute");
76857
76942
  AddTimePartOperator<DatePart::EpochOperator>(set, "epoch");
76858
76943
  AddTimePartOperator<DatePart::MicrosecondsOperator>(set, "microsecond");
76859
76944
  AddTimePartOperator<DatePart::MillisecondsOperator>(set, "millisecond");
@@ -137063,6 +137148,10 @@ unique_ptr<ParsedExpression> Transformer::TransformFuncCall(duckdb_libpgquery::P
137063
137148
  throw ParserException("ORDER BY is not implemented for window functions!");
137064
137149
  }
137065
137150
 
137151
+ if (root->agg_filter) {
137152
+ throw ParserException("FILTER is not implemented for window functions!");
137153
+ }
137154
+
137066
137155
  const auto win_fun_type = WindowToExpressionType(lowercase_name);
137067
137156
  if (win_fun_type == ExpressionType::INVALID) {
137068
137157
  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 "93a657cdd"
15
- #define DUCKDB_VERSION "0.3.2-dev872"
14
+ #define DUCKDB_SOURCE_ID "a3178f09c"
15
+ #define DUCKDB_VERSION "0.3.2-dev890"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //