duckdb 0.4.1-dev144.0 → 0.4.1-dev152.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.4.1-dev144.0",
4
+ "version": "0.4.1-dev152.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -45834,6 +45834,10 @@ struct StructPackFun {
45834
45834
  static void RegisterFunction(BuiltinFunctions &set);
45835
45835
  };
45836
45836
 
45837
+ struct StructInsertFun {
45838
+ static void RegisterFunction(BuiltinFunctions &set);
45839
+ };
45840
+
45837
45841
  struct ListValueFun {
45838
45842
  static void RegisterFunction(BuiltinFunctions &set);
45839
45843
  };
@@ -98812,6 +98816,7 @@ void BuiltinFunctions::RegisterNestedFunctions() {
98812
98816
  Register<ArraySliceFun>();
98813
98817
  Register<StructPackFun>();
98814
98818
  Register<StructExtractFun>();
98819
+ Register<StructInsertFun>();
98815
98820
  Register<ListConcatFun>();
98816
98821
  Register<ListContainsFun>();
98817
98822
  Register<ListPositionFun>();
@@ -104604,6 +104609,111 @@ void StructExtractFun::RegisterFunction(BuiltinFunctions &set) {
104604
104609
 
104605
104610
 
104606
104611
 
104612
+ namespace duckdb {
104613
+
104614
+ static void StructInsertFunction(DataChunk &args, ExpressionState &state, Vector &result) {
104615
+ auto &starting_vec = args.data[0];
104616
+
104617
+ starting_vec.Verify(args.size());
104618
+
104619
+ auto &starting_child_entries = StructVector::GetEntries(starting_vec);
104620
+
104621
+ auto &result_child_entries = StructVector::GetEntries(result);
104622
+
104623
+ // Assign the starting vector entries to the result vector
104624
+ for (size_t i = 0; i < starting_child_entries.size(); i++) {
104625
+ auto &starting_child = starting_child_entries[i];
104626
+ result_child_entries[i]->Reference(*starting_child);
104627
+ }
104628
+
104629
+ // Assign the new entries to the result vector
104630
+ for (size_t i = 1; i < args.ColumnCount(); i++) {
104631
+ result_child_entries[starting_child_entries.size() + i - 1]->Reference(args.data[i]);
104632
+ }
104633
+
104634
+ result.Verify(args.size());
104635
+ }
104636
+
104637
+ static unique_ptr<FunctionData> StructInsertBind(ClientContext &context, ScalarFunction &bound_function,
104638
+ vector<unique_ptr<Expression>> &arguments) {
104639
+ case_insensitive_set_t name_collision_set;
104640
+
104641
+ if (arguments.empty()) {
104642
+ throw Exception("Missing required arguments for struct_insert function.");
104643
+ }
104644
+
104645
+ if (LogicalTypeId::STRUCT != arguments[0]->return_type.id()) {
104646
+ throw Exception("The first argument to struct_insert must be a STRUCT");
104647
+ }
104648
+
104649
+ if (arguments.size() < 2) {
104650
+ throw Exception("Can't insert nothing into a struct");
104651
+ }
104652
+
104653
+ child_list_t<LogicalType> new_struct_children;
104654
+
104655
+ auto &existing_struct_children = StructType::GetChildTypes(arguments[0]->return_type);
104656
+
104657
+ for (size_t i = 0; i < existing_struct_children.size(); i++) {
104658
+ auto &child = existing_struct_children[i];
104659
+ name_collision_set.insert(child.first);
104660
+ new_struct_children.push_back(make_pair(child.first, child.second));
104661
+ }
104662
+
104663
+ // Loop through the additional arguments (name/value pairs)
104664
+ for (idx_t i = 1; i < arguments.size(); i++) {
104665
+ auto &child = arguments[i];
104666
+ if (child->alias.empty() && bound_function.name == "struct_insert") {
104667
+ throw BinderException("Need named argument for struct insert, e.g. STRUCT_PACK(a := b)");
104668
+ }
104669
+ if (name_collision_set.find(child->alias) != name_collision_set.end()) {
104670
+ throw BinderException("Duplicate struct entry name \"%s\"", child->alias);
104671
+ }
104672
+ name_collision_set.insert(child->alias);
104673
+ new_struct_children.push_back(make_pair(child->alias, arguments[i]->return_type));
104674
+ }
104675
+
104676
+ // this is more for completeness reasons
104677
+ bound_function.return_type = LogicalType::STRUCT(move(new_struct_children));
104678
+ return make_unique<VariableReturnBindData>(bound_function.return_type);
104679
+ }
104680
+
104681
+ unique_ptr<BaseStatistics> StructInsertStats(ClientContext &context, FunctionStatisticsInput &input) {
104682
+ auto &child_stats = input.child_stats;
104683
+ auto &expr = input.expr;
104684
+
104685
+ auto &existing_struct_stats = (StructStatistics &)*child_stats[0];
104686
+ auto new_struct_stats = make_unique<StructStatistics>(expr.return_type);
104687
+
104688
+ for (idx_t i = 0; i < existing_struct_stats.child_stats.size(); i++) {
104689
+ new_struct_stats->child_stats[i] =
104690
+ existing_struct_stats.child_stats[i] ? existing_struct_stats.child_stats[i]->Copy() : nullptr;
104691
+ }
104692
+
104693
+ auto offset = new_struct_stats->child_stats.size() - child_stats.size();
104694
+ for (idx_t i = 1; i < child_stats.size(); i++) {
104695
+ new_struct_stats->child_stats[offset + i] = child_stats[i] ? child_stats[i]->Copy() : nullptr;
104696
+ }
104697
+ return move(new_struct_stats);
104698
+ }
104699
+
104700
+ void StructInsertFun::RegisterFunction(BuiltinFunctions &set) {
104701
+ // the arguments and return types are actually set in the binder function
104702
+ ScalarFunction fun("struct_insert", {}, LogicalTypeId::STRUCT, StructInsertFunction, false, StructInsertBind,
104703
+ nullptr, StructInsertStats);
104704
+ fun.varargs = LogicalType::ANY;
104705
+ set.AddFunction(fun);
104706
+ }
104707
+
104708
+ } // namespace duckdb
104709
+
104710
+
104711
+
104712
+
104713
+
104714
+
104715
+
104716
+
104607
104717
  namespace duckdb {
104608
104718
 
104609
104719
  static void StructPackFunction(DataChunk &args, ExpressionState &state, Vector &result) {
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 "7548d73b3"
15
- #define DUCKDB_VERSION "v0.4.1-dev144"
14
+ #define DUCKDB_SOURCE_ID "687b4c85d"
15
+ #define DUCKDB_VERSION "v0.4.1-dev152"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //