duckdb 0.3.2-dev841.0 → 0.3.2-dev860.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-dev841.0",
4
+ "version": "0.3.2-dev860.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -21146,6 +21146,7 @@ public:
21146
21146
  bool CanSeek() override {
21147
21147
  return false;
21148
21148
  }
21149
+ void FileSync(FileHandle &handle) override;
21149
21150
 
21150
21151
  std::string GetName() const override {
21151
21152
  return "PipeFileSystem";
@@ -21200,6 +21201,9 @@ int64_t PipeFileSystem::GetFileSize(FileHandle &handle) {
21200
21201
  return 0;
21201
21202
  }
21202
21203
 
21204
+ void PipeFileSystem::FileSync(FileHandle &handle) {
21205
+ }
21206
+
21203
21207
  unique_ptr<FileHandle> PipeFileSystem::OpenPipe(unique_ptr<FileHandle> handle) {
21204
21208
  auto path = handle->path;
21205
21209
  return make_unique<PipeFile>(move(handle), path);
@@ -72386,7 +72390,7 @@ namespace duckdb {
72386
72390
  struct VariableReturnBindData : public FunctionData {
72387
72391
  LogicalType stype;
72388
72392
 
72389
- explicit VariableReturnBindData(LogicalType stype) : stype(stype) {
72393
+ explicit VariableReturnBindData(const LogicalType &stype_p) : stype(stype_p) {
72390
72394
  }
72391
72395
 
72392
72396
  unique_ptr<FunctionData> Copy() override {
@@ -73737,9 +73741,13 @@ static int64_t TargetTypeCost(const LogicalType &type) {
73737
73741
  case LogicalTypeId::TIMESTAMP:
73738
73742
  return 120;
73739
73743
  case LogicalTypeId::VARCHAR:
73740
- return 199;
73744
+ return 149;
73741
73745
  case LogicalTypeId::DECIMAL:
73742
73746
  return 104;
73747
+ case LogicalTypeId::STRUCT:
73748
+ case LogicalTypeId::MAP:
73749
+ case LogicalTypeId::LIST:
73750
+ return 160;
73743
73751
  default:
73744
73752
  return 110;
73745
73753
  }
@@ -75636,6 +75644,10 @@ void DateDiffFun::RegisterFunction(BuiltinFunctions &set) {
75636
75644
 
75637
75645
 
75638
75646
 
75647
+
75648
+
75649
+
75650
+
75639
75651
  namespace duckdb {
75640
75652
 
75641
75653
  bool TryGetDatePartSpecifier(const string &specifier_p, DatePartSpecifier &result) {
@@ -75702,6 +75714,73 @@ DatePartSpecifier GetDatePartSpecifier(const string &specifier) {
75702
75714
  return result;
75703
75715
  }
75704
75716
 
75717
+ DatePartSpecifier GetDateTypePartSpecifier(const string &specifier, LogicalType &type) {
75718
+ const auto part = GetDatePartSpecifier(specifier);
75719
+ switch (type.id()) {
75720
+ case LogicalType::TIMESTAMP:
75721
+ case LogicalType::TIMESTAMP_TZ:
75722
+ return part;
75723
+ case LogicalType::DATE:
75724
+ switch (part) {
75725
+ case DatePartSpecifier::YEAR:
75726
+ case DatePartSpecifier::MONTH:
75727
+ case DatePartSpecifier::DAY:
75728
+ case DatePartSpecifier::DECADE:
75729
+ case DatePartSpecifier::CENTURY:
75730
+ case DatePartSpecifier::MILLENNIUM:
75731
+ case DatePartSpecifier::DOW:
75732
+ case DatePartSpecifier::ISODOW:
75733
+ case DatePartSpecifier::WEEK:
75734
+ case DatePartSpecifier::QUARTER:
75735
+ case DatePartSpecifier::DOY:
75736
+ case DatePartSpecifier::YEARWEEK:
75737
+ case DatePartSpecifier::ERA:
75738
+ return part;
75739
+ default:
75740
+ break;
75741
+ }
75742
+ break;
75743
+ case LogicalType::TIME:
75744
+ switch (part) {
75745
+ case DatePartSpecifier::MICROSECONDS:
75746
+ case DatePartSpecifier::MILLISECONDS:
75747
+ case DatePartSpecifier::SECOND:
75748
+ case DatePartSpecifier::MINUTE:
75749
+ case DatePartSpecifier::HOUR:
75750
+ case DatePartSpecifier::EPOCH:
75751
+ case DatePartSpecifier::OFFSET:
75752
+ return part;
75753
+ default:
75754
+ break;
75755
+ }
75756
+ break;
75757
+ case LogicalType::INTERVAL:
75758
+ switch (part) {
75759
+ case DatePartSpecifier::YEAR:
75760
+ case DatePartSpecifier::MONTH:
75761
+ case DatePartSpecifier::DAY:
75762
+ case DatePartSpecifier::DECADE:
75763
+ case DatePartSpecifier::CENTURY:
75764
+ case DatePartSpecifier::QUARTER:
75765
+ case DatePartSpecifier::MILLENNIUM:
75766
+ case DatePartSpecifier::MICROSECONDS:
75767
+ case DatePartSpecifier::MILLISECONDS:
75768
+ case DatePartSpecifier::SECOND:
75769
+ case DatePartSpecifier::MINUTE:
75770
+ case DatePartSpecifier::HOUR:
75771
+ case DatePartSpecifier::EPOCH:
75772
+ return part;
75773
+ default:
75774
+ break;
75775
+ }
75776
+ break;
75777
+ default:
75778
+ break;
75779
+ }
75780
+
75781
+ throw NotImplementedException("\"%s\" units \"%s\" not recognized", LogicalTypeIdToString(type.id()), specifier);
75782
+ }
75783
+
75705
75784
  template <class T>
75706
75785
  static void LastYearFunction(DataChunk &args, ExpressionState &state, Vector &result) {
75707
75786
  int32_t last_year = 0;
@@ -76035,6 +76114,137 @@ struct DatePart {
76035
76114
  return PropagateSimpleDatePartStatistics<0, 0>(child_stats);
76036
76115
  }
76037
76116
  };
76117
+
76118
+ struct StructOperator {
76119
+ using part_codes_t = vector<DatePartSpecifier>;
76120
+ using part_mask_t = uint64_t;
76121
+
76122
+ enum MaskBits : uint8_t {
76123
+ YMD = 1 << 0,
76124
+ DOW = 1 << 1,
76125
+ DOY = 1 << 2,
76126
+ EPOCH = 1 << 3,
76127
+ TIME = 1 << 4,
76128
+ ZONE = 1 << 5
76129
+ };
76130
+
76131
+ static part_mask_t GetMask(const part_codes_t &part_codes) {
76132
+ part_mask_t mask = 0;
76133
+ for (const auto &part_code : part_codes) {
76134
+ switch (part_code) {
76135
+ case DatePartSpecifier::YEAR:
76136
+ case DatePartSpecifier::MONTH:
76137
+ case DatePartSpecifier::DAY:
76138
+ case DatePartSpecifier::DECADE:
76139
+ case DatePartSpecifier::CENTURY:
76140
+ case DatePartSpecifier::MILLENNIUM:
76141
+ case DatePartSpecifier::QUARTER:
76142
+ case DatePartSpecifier::ERA:
76143
+ mask |= YMD;
76144
+ break;
76145
+ case DatePartSpecifier::YEARWEEK:
76146
+ mask |= YMD;
76147
+ mask |= DOW;
76148
+ break;
76149
+ case DatePartSpecifier::DOW:
76150
+ case DatePartSpecifier::ISODOW:
76151
+ case DatePartSpecifier::WEEK:
76152
+ mask |= DOW;
76153
+ break;
76154
+ case DatePartSpecifier::DOY:
76155
+ mask |= DOY;
76156
+ break;
76157
+ case DatePartSpecifier::EPOCH:
76158
+ mask |= EPOCH;
76159
+ break;
76160
+ case DatePartSpecifier::MICROSECONDS:
76161
+ case DatePartSpecifier::MILLISECONDS:
76162
+ case DatePartSpecifier::SECOND:
76163
+ case DatePartSpecifier::MINUTE:
76164
+ case DatePartSpecifier::HOUR:
76165
+ mask |= TIME;
76166
+ break;
76167
+ case DatePartSpecifier::OFFSET:
76168
+ mask |= ZONE;
76169
+ break;
76170
+ }
76171
+ }
76172
+ return mask;
76173
+ }
76174
+
76175
+ template <typename P>
76176
+ static inline P HasPartValue(P *part_values, DatePartSpecifier part) {
76177
+ return part_values[int(part)];
76178
+ }
76179
+
76180
+ template <class TA, class TR>
76181
+ static inline void Operation(TR **part_values, const TA &input, const idx_t idx, const part_mask_t mask) {
76182
+ TR *part_data;
76183
+ // YMD calculations
76184
+ int32_t yyyy = 1970;
76185
+ int32_t mm = 0;
76186
+ int32_t dd = 1;
76187
+ if (mask & YMD) {
76188
+ Date::Convert(input, yyyy, mm, dd);
76189
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::YEAR))) {
76190
+ part_data[idx] = yyyy;
76191
+ }
76192
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::MONTH))) {
76193
+ part_data[idx] = mm;
76194
+ }
76195
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::DAY))) {
76196
+ part_data[idx] = dd;
76197
+ }
76198
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::DECADE))) {
76199
+ part_data[idx] = yyyy / 10;
76200
+ }
76201
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::CENTURY))) {
76202
+ part_data[idx] = (yyyy - 1) / 100 + 1;
76203
+ }
76204
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::MILLENNIUM))) {
76205
+ part_data[idx] = (yyyy - 1) / 1000 + 1;
76206
+ }
76207
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::QUARTER))) {
76208
+ part_data[idx] = (mm - 1) / Interval::MONTHS_PER_QUARTER + 1;
76209
+ }
76210
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::ERA))) {
76211
+ part_data[idx] = yyyy > 0 ? 1 : 0;
76212
+ }
76213
+ }
76214
+
76215
+ // Week calculations
76216
+ int32_t isodow = 0;
76217
+ int32_t ww = 0;
76218
+ if (mask & DOW) {
76219
+ isodow = Date::ExtractISODayOfTheWeek(input);
76220
+ ww = Date::ExtractISOWeekNumber(input);
76221
+ int32_t dow = isodow % 7;
76222
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::DOW))) {
76223
+ part_data[idx] = dow;
76224
+ }
76225
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::ISODOW))) {
76226
+ part_data[idx] = isodow;
76227
+ }
76228
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::WEEK))) {
76229
+ part_data[idx] = ww;
76230
+ }
76231
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::YEARWEEK))) {
76232
+ part_data[idx] = yyyy * 100 + ww;
76233
+ }
76234
+ }
76235
+
76236
+ if (mask & EPOCH) {
76237
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::EPOCH))) {
76238
+ part_data[idx] = Date::Epoch(input);
76239
+ }
76240
+ }
76241
+ if (mask & DOY) {
76242
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::DOY))) {
76243
+ part_data[idx] = Date::ExtractDayOfTheYear(input);
76244
+ }
76245
+ }
76246
+ }
76247
+ };
76038
76248
  };
76039
76249
 
76040
76250
  template <>
@@ -76331,7 +76541,7 @@ int64_t DatePart::OffsetOperator::Operation(timestamp_t input) {
76331
76541
 
76332
76542
  template <>
76333
76543
  int64_t DatePart::OffsetOperator::Operation(interval_t input) {
76334
- return 0;
76544
+ throw NotImplementedException("\"interval\" units \"offset\" not recognized");
76335
76545
  }
76336
76546
 
76337
76547
  template <>
@@ -76339,7 +76549,110 @@ int64_t DatePart::OffsetOperator::Operation(dtime_t input) {
76339
76549
  return 0;
76340
76550
  }
76341
76551
 
76342
- template <class T>
76552
+ template <>
76553
+ void DatePart::StructOperator::Operation(int64_t **part_values, const dtime_t &input, const idx_t idx,
76554
+ const part_mask_t mask) {
76555
+ int64_t *part_data;
76556
+ if (mask & TIME) {
76557
+ const auto micros = MicrosecondsOperator::Operation<dtime_t, int64_t>(input);
76558
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::MICROSECONDS))) {
76559
+ part_data[idx] = micros;
76560
+ }
76561
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::MILLISECONDS))) {
76562
+ part_data[idx] = micros / Interval::MICROS_PER_MSEC;
76563
+ }
76564
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::SECOND))) {
76565
+ part_data[idx] = micros / Interval::MICROS_PER_SEC;
76566
+ }
76567
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::MINUTE))) {
76568
+ part_data[idx] = MinutesOperator::Operation<dtime_t, int64_t>(input);
76569
+ }
76570
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::HOUR))) {
76571
+ part_data[idx] = HoursOperator::Operation<dtime_t, int64_t>(input);
76572
+ }
76573
+ }
76574
+
76575
+ if (mask & EPOCH) {
76576
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::EPOCH))) {
76577
+ part_data[idx] = EpochOperator::Operation<dtime_t, int64_t>(input);
76578
+ ;
76579
+ }
76580
+ }
76581
+
76582
+ if (mask & ZONE) {
76583
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::OFFSET))) {
76584
+ part_data[idx] = 0;
76585
+ }
76586
+ }
76587
+ }
76588
+
76589
+ template <>
76590
+ void DatePart::StructOperator::Operation(int64_t **part_values, const timestamp_t &input, const idx_t idx,
76591
+ const part_mask_t mask) {
76592
+ date_t d;
76593
+ dtime_t t;
76594
+ Timestamp::Convert(input, d, t);
76595
+ // Time first because they both define epoch.
76596
+ Operation(part_values, t, idx, mask);
76597
+ Operation(part_values, d, idx, mask);
76598
+ }
76599
+
76600
+ template <>
76601
+ void DatePart::StructOperator::Operation(int64_t **part_values, const interval_t &input, const idx_t idx,
76602
+ const part_mask_t mask) {
76603
+ int64_t *part_data;
76604
+ if (mask & YMD) {
76605
+ const auto mm = input.months % Interval::MONTHS_PER_YEAR;
76606
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::YEAR))) {
76607
+ part_data[idx] = input.months / Interval::MONTHS_PER_YEAR;
76608
+ }
76609
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::MONTH))) {
76610
+ part_data[idx] = mm;
76611
+ }
76612
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::DAY))) {
76613
+ part_data[idx] = input.days;
76614
+ }
76615
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::DECADE))) {
76616
+ part_data[idx] = input.months / Interval::MONTHS_PER_DECADE;
76617
+ }
76618
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::CENTURY))) {
76619
+ part_data[idx] = input.months / Interval::MONTHS_PER_CENTURY;
76620
+ }
76621
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::MILLENNIUM))) {
76622
+ part_data[idx] = input.months / Interval::MONTHS_PER_MILLENIUM;
76623
+ }
76624
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::QUARTER))) {
76625
+ part_data[idx] = mm / Interval::MONTHS_PER_QUARTER + 1;
76626
+ }
76627
+ }
76628
+
76629
+ if (mask & TIME) {
76630
+ const auto micros = MicrosecondsOperator::Operation<interval_t, int64_t>(input);
76631
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::MICROSECONDS))) {
76632
+ part_data[idx] = micros;
76633
+ }
76634
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::MILLISECONDS))) {
76635
+ part_data[idx] = micros / Interval::MICROS_PER_MSEC;
76636
+ }
76637
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::SECOND))) {
76638
+ part_data[idx] = micros / Interval::MICROS_PER_SEC;
76639
+ }
76640
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::MINUTE))) {
76641
+ part_data[idx] = MinutesOperator::Operation<interval_t, int64_t>(input);
76642
+ }
76643
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::HOUR))) {
76644
+ part_data[idx] = HoursOperator::Operation<interval_t, int64_t>(input);
76645
+ }
76646
+ }
76647
+
76648
+ if (mask & EPOCH) {
76649
+ if ((part_data = HasPartValue(part_values, DatePartSpecifier::EPOCH))) {
76650
+ part_data[idx] = EpochOperator::Operation<interval_t, int64_t>(input);
76651
+ }
76652
+ }
76653
+ }
76654
+
76655
+ template <typename T>
76343
76656
  static int64_t ExtractElement(DatePartSpecifier type, T element) {
76344
76657
  switch (type) {
76345
76658
  case DatePartSpecifier::YEAR:
@@ -76479,6 +76792,164 @@ struct DayNameOperator {
76479
76792
  }
76480
76793
  };
76481
76794
 
76795
+ struct StructDatePart {
76796
+ using part_codes_t = vector<DatePartSpecifier>;
76797
+
76798
+ struct BindData : public VariableReturnBindData {
76799
+ part_codes_t part_codes;
76800
+
76801
+ explicit BindData(const LogicalType &stype, const part_codes_t &part_codes_p)
76802
+ : VariableReturnBindData(stype), part_codes(part_codes_p) {
76803
+ }
76804
+
76805
+ unique_ptr<FunctionData> Copy() override {
76806
+ return make_unique<BindData>(stype, part_codes);
76807
+ }
76808
+ };
76809
+
76810
+ static unique_ptr<FunctionData> Bind(ClientContext &context, ScalarFunction &bound_function,
76811
+ vector<unique_ptr<Expression>> &arguments) {
76812
+ // collect names and deconflict, construct return type
76813
+ if (!arguments[0]->IsFoldable()) {
76814
+ throw BinderException("%s can only take constant lists of part names", bound_function.name);
76815
+ }
76816
+
76817
+ case_insensitive_set_t name_collision_set;
76818
+ child_list_t<LogicalType> struct_children;
76819
+ part_codes_t part_codes;
76820
+
76821
+ Value parts_list = ExpressionExecutor::EvaluateScalar(*arguments[0]);
76822
+ if (parts_list.type().id() == LogicalTypeId::LIST) {
76823
+ if (parts_list.list_value.empty()) {
76824
+ throw BinderException("%s requires non-empty lists of part names", bound_function.name);
76825
+ }
76826
+ for (const auto &part_value : parts_list.list_value) {
76827
+ if (part_value.is_null) {
76828
+ throw BinderException("NULL struct entry name in %s", bound_function.name);
76829
+ }
76830
+ const auto part_name = part_value.ToString();
76831
+ const auto part_code = GetDateTypePartSpecifier(part_name, arguments[1]->return_type);
76832
+ if (name_collision_set.find(part_name) != name_collision_set.end()) {
76833
+ throw BinderException("Duplicate struct entry name \"%s\" in %s", part_name, bound_function.name);
76834
+ }
76835
+ name_collision_set.insert(part_name);
76836
+ part_codes.emplace_back(part_code);
76837
+ struct_children.emplace_back(make_pair(part_name, LogicalType::BIGINT));
76838
+ }
76839
+ } else {
76840
+ throw BinderException("%s can only take constant lists of part names", bound_function.name);
76841
+ }
76842
+
76843
+ arguments.erase(arguments.begin());
76844
+ bound_function.arguments.erase(bound_function.arguments.begin());
76845
+ bound_function.return_type = LogicalType::STRUCT(move(struct_children));
76846
+ return make_unique<BindData>(bound_function.return_type, part_codes);
76847
+ }
76848
+
76849
+ template <typename INPUT_TYPE>
76850
+ static void Function(DataChunk &args, ExpressionState &state, Vector &result) {
76851
+ auto &func_expr = (BoundFunctionExpression &)state.expr;
76852
+ auto &info = (BindData &)*func_expr.bind_info;
76853
+ D_ASSERT(args.ColumnCount() == 1);
76854
+
76855
+ const auto count = args.size();
76856
+ Vector &input = args.data[0];
76857
+ vector<int64_t *> part_values(int(DatePartSpecifier::OFFSET) + 1, nullptr);
76858
+ const auto part_mask = DatePart::StructOperator::GetMask(info.part_codes);
76859
+
76860
+ auto &child_entries = StructVector::GetEntries(result);
76861
+
76862
+ // The first computer of a part "owns" it
76863
+ // and other requestors just reference the owner
76864
+ vector<size_t> owners(int(DatePartSpecifier::OFFSET) + 1, child_entries.size());
76865
+ for (size_t col = 0; col < child_entries.size(); ++col) {
76866
+ const auto part_index = size_t(info.part_codes[col]);
76867
+ if (owners[part_index] == child_entries.size()) {
76868
+ owners[part_index] = col;
76869
+ }
76870
+ }
76871
+
76872
+ if (input.GetVectorType() == VectorType::CONSTANT_VECTOR) {
76873
+ result.SetVectorType(VectorType::CONSTANT_VECTOR);
76874
+
76875
+ if (ConstantVector::IsNull(input)) {
76876
+ ConstantVector::SetNull(result, true);
76877
+ } else {
76878
+ ConstantVector::SetNull(result, false);
76879
+ for (size_t col = 0; col < child_entries.size(); ++col) {
76880
+ auto &child_entry = child_entries[col];
76881
+ ConstantVector::SetNull(*child_entry, false);
76882
+ const auto part_index = size_t(info.part_codes[col]);
76883
+ if (owners[part_index] == col) {
76884
+ part_values[part_index] = ConstantVector::GetData<int64_t>(*child_entry);
76885
+ }
76886
+ }
76887
+ auto tdata = ConstantVector::GetData<INPUT_TYPE>(input);
76888
+ DatePart::StructOperator::Operation(part_values.data(), tdata[0], 0, part_mask);
76889
+ }
76890
+ } else {
76891
+ VectorData rdata;
76892
+ input.Orrify(count, rdata);
76893
+
76894
+ const auto &arg_valid = rdata.validity;
76895
+ auto tdata = (const INPUT_TYPE *)rdata.data;
76896
+
76897
+ // Start with a valid flat vector
76898
+ result.SetVectorType(VectorType::FLAT_VECTOR);
76899
+ auto &res_valid = FlatVector::Validity(result);
76900
+ if (res_valid.GetData()) {
76901
+ res_valid.SetAllValid(count);
76902
+ }
76903
+
76904
+ // Start with valid children
76905
+ for (size_t col = 0; col < child_entries.size(); ++col) {
76906
+ auto &child_entry = child_entries[col];
76907
+ child_entry->SetVectorType(VectorType::FLAT_VECTOR);
76908
+ auto &child_validity = FlatVector::Validity(*child_entry);
76909
+ if (child_validity.GetData()) {
76910
+ child_validity.SetAllValid(count);
76911
+ }
76912
+
76913
+ // Pre-multiplex
76914
+ const auto part_index = size_t(info.part_codes[col]);
76915
+ if (owners[part_index] == col) {
76916
+ part_values[part_index] = FlatVector::GetData<int64_t>(*child_entry);
76917
+ }
76918
+ }
76919
+
76920
+ for (idx_t i = 0; i < count; ++i) {
76921
+ const auto idx = rdata.sel->get_index(i);
76922
+ if (arg_valid.RowIsValid(idx)) {
76923
+ DatePart::StructOperator::Operation(part_values.data(), tdata[idx], idx, part_mask);
76924
+ } else {
76925
+ res_valid.SetInvalid(idx);
76926
+ for (auto &child_entry : child_entries) {
76927
+ FlatVector::Validity(*child_entry).SetInvalid(idx);
76928
+ }
76929
+ }
76930
+ }
76931
+ }
76932
+
76933
+ // Reference any duplicate parts
76934
+ for (size_t col = 0; col < child_entries.size(); ++col) {
76935
+ const auto part_index = size_t(info.part_codes[col]);
76936
+ const auto owner = owners[part_index];
76937
+ if (owner != col) {
76938
+ child_entries[col]->Reference(*child_entries[owner]);
76939
+ }
76940
+ }
76941
+
76942
+ result.Verify(count);
76943
+ }
76944
+
76945
+ template <typename INPUT_TYPE>
76946
+ static ScalarFunction GetFunction(const LogicalType &temporal_type) {
76947
+ auto part_type = LogicalType::LIST(LogicalType::VARCHAR);
76948
+ auto result_type = LogicalType::STRUCT({});
76949
+ return ScalarFunction({part_type, temporal_type}, result_type, Function<INPUT_TYPE>, false, Bind);
76950
+ }
76951
+ };
76952
+
76482
76953
  void DatePartFun::RegisterFunction(BuiltinFunctions &set) {
76483
76954
  // register the individual operators
76484
76955
  AddGenericDatePartOperator(set, "year", LastYearFunction<date_t>, LastYearFunction<timestamp_t>,
@@ -76545,6 +77016,13 @@ void DatePartFun::RegisterFunction(BuiltinFunctions &set) {
76545
77016
  ScalarFunction({LogicalType::VARCHAR, LogicalType::TIME}, LogicalType::BIGINT, DatePartFunction<dtime_t>));
76546
77017
  date_part.AddFunction(ScalarFunction({LogicalType::VARCHAR, LogicalType::INTERVAL}, LogicalType::BIGINT,
76547
77018
  DatePartFunction<interval_t>));
77019
+
77020
+ // struct variants
77021
+ date_part.AddFunction(StructDatePart::GetFunction<date_t>(LogicalType::DATE));
77022
+ date_part.AddFunction(StructDatePart::GetFunction<timestamp_t>(LogicalType::TIMESTAMP));
77023
+ date_part.AddFunction(StructDatePart::GetFunction<dtime_t>(LogicalType::TIME));
77024
+ date_part.AddFunction(StructDatePart::GetFunction<interval_t>(LogicalType::INTERVAL));
77025
+
76548
77026
  set.AddFunction(date_part);
76549
77027
  date_part.name = "datepart";
76550
77028
  set.AddFunction(date_part);
@@ -141006,8 +141484,10 @@ bool BindContext::CheckExclusionList(StarExpression &expr, Binding *binding, con
141006
141484
  }
141007
141485
  auto entry = expr.replace_list.find(column_name);
141008
141486
  if (entry != expr.replace_list.end()) {
141487
+ auto new_entry = entry->second->Copy();
141488
+ new_entry->alias = entry->first;
141009
141489
  excluded_columns.insert(entry->first);
141010
- new_select_list.push_back(entry->second->Copy());
141490
+ new_select_list.push_back(move(new_entry));
141011
141491
  return true;
141012
141492
  }
141013
141493
  return false;
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 "dee46dbe3"
15
- #define DUCKDB_VERSION "0.3.2-dev841"
14
+ #define DUCKDB_SOURCE_ID "768b528e1"
15
+ #define DUCKDB_VERSION "0.3.2-dev860"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //