duckdb 0.3.3-dev562.0 → 0.3.3-dev581.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.3-dev562.0",
4
+ "version": "0.3.3-dev581.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -75773,6 +75773,11 @@ struct ListContainsFun {
75773
75773
  static void RegisterFunction(BuiltinFunctions &set);
75774
75774
  };
75775
75775
 
75776
+ struct ListFlattenFun {
75777
+ static ScalarFunction GetFunction();
75778
+ static void RegisterFunction(BuiltinFunctions &set);
75779
+ };
75780
+
75776
75781
  struct ListPositionFun {
75777
75782
  static ScalarFunction GetFunction();
75778
75783
  static void RegisterFunction(BuiltinFunctions &set);
@@ -84005,7 +84010,6 @@ void ListPositionFun::RegisterFunction(BuiltinFunctions &set) {
84005
84010
  } // namespace duckdb
84006
84011
 
84007
84012
 
84008
-
84009
84013
  //===----------------------------------------------------------------------===//
84010
84014
  // DuckDB
84011
84015
  //
@@ -84044,6 +84048,142 @@ public:
84044
84048
  } // namespace duckdb
84045
84049
 
84046
84050
 
84051
+ namespace duckdb {
84052
+
84053
+ void ListFlattenFunction(DataChunk &args, ExpressionState &state, Vector &result) {
84054
+ D_ASSERT(args.ColumnCount() == 1);
84055
+
84056
+ Vector &input = args.data[0];
84057
+ if (input.GetType().id() == LogicalTypeId::SQLNULL) {
84058
+ result.Reference(input);
84059
+ return;
84060
+ }
84061
+
84062
+ idx_t count = args.size();
84063
+
84064
+ VectorData list_data;
84065
+ input.Orrify(count, list_data);
84066
+ auto list_entries = (list_entry_t *)list_data.data;
84067
+
84068
+ auto &child_vector = ListVector::GetEntry(input);
84069
+
84070
+ result.SetVectorType(VectorType::FLAT_VECTOR);
84071
+ auto result_entries = FlatVector::GetData<list_entry_t>(result);
84072
+ auto &result_validity = FlatVector::Validity(result);
84073
+
84074
+ if (child_vector.GetType().id() == LogicalTypeId::SQLNULL) {
84075
+ auto result_entries = FlatVector::GetData<list_entry_t>(result);
84076
+ for (idx_t i = 0; i < count; i++) {
84077
+ auto list_index = list_data.sel->get_index(i);
84078
+ if (!list_data.validity.RowIsValid(list_index)) {
84079
+ result_validity.SetInvalid(i);
84080
+ continue;
84081
+ }
84082
+ result_entries[i].offset = 0;
84083
+ result_entries[i].length = 0;
84084
+ }
84085
+ return;
84086
+ }
84087
+
84088
+ auto child_size = ListVector::GetListSize(input);
84089
+ VectorData child_data;
84090
+ child_vector.Orrify(child_size, child_data);
84091
+ auto child_entries = (list_entry_t *)child_data.data;
84092
+ auto &data_vector = ListVector::GetEntry(child_vector);
84093
+
84094
+ idx_t offset = 0;
84095
+ for (idx_t i = 0; i < count; i++) {
84096
+ auto list_index = list_data.sel->get_index(i);
84097
+ if (!list_data.validity.RowIsValid(list_index)) {
84098
+ result_validity.SetInvalid(i);
84099
+ continue;
84100
+ }
84101
+ auto list_entry = list_entries[list_index];
84102
+
84103
+ idx_t source_offset = 0;
84104
+ // Find first valid child list entry to get offset
84105
+ for (idx_t j = 0; j < list_entry.length; j++) {
84106
+ auto child_list_index = child_data.sel->get_index(list_entry.offset + j);
84107
+ if (child_data.validity.RowIsValid(child_list_index)) {
84108
+ source_offset = child_entries[child_list_index].offset;
84109
+ break;
84110
+ }
84111
+ }
84112
+
84113
+ idx_t length = 0;
84114
+ // Find last valid child list entry to get length
84115
+ for (idx_t j = list_entry.length - 1; j != (idx_t)-1; j--) {
84116
+ auto child_list_index = child_data.sel->get_index(list_entry.offset + j);
84117
+ if (child_data.validity.RowIsValid(child_list_index)) {
84118
+ auto child_entry = child_entries[child_list_index];
84119
+ length = child_entry.offset + child_entry.length - source_offset;
84120
+ break;
84121
+ }
84122
+ }
84123
+ ListVector::Append(result, data_vector, source_offset + length, source_offset);
84124
+
84125
+ result_entries[i].offset = offset;
84126
+ result_entries[i].length = length;
84127
+ offset += length;
84128
+ }
84129
+
84130
+ if (input.GetVectorType() == VectorType::CONSTANT_VECTOR) {
84131
+ result.SetVectorType(VectorType::CONSTANT_VECTOR);
84132
+ }
84133
+ }
84134
+
84135
+ static unique_ptr<FunctionData> ListFlattenBind(ClientContext &context, ScalarFunction &bound_function,
84136
+ vector<unique_ptr<Expression>> &arguments) {
84137
+ D_ASSERT(bound_function.arguments.size() == 1);
84138
+
84139
+ auto &input_type = arguments[0]->return_type;
84140
+ bound_function.arguments[0] = input_type;
84141
+ if (input_type.id() == LogicalTypeId::SQLNULL) {
84142
+ bound_function.return_type = LogicalType(LogicalTypeId::SQLNULL);
84143
+ return make_unique<VariableReturnBindData>(bound_function.return_type);
84144
+ }
84145
+ D_ASSERT(input_type.id() == LogicalTypeId::LIST);
84146
+
84147
+ auto child_type = ListType::GetChildType(input_type);
84148
+ if (child_type.id() == LogicalType::SQLNULL) {
84149
+ bound_function.return_type = input_type;
84150
+ return make_unique<VariableReturnBindData>(bound_function.return_type);
84151
+ }
84152
+ D_ASSERT(child_type.id() == LogicalTypeId::LIST);
84153
+
84154
+ bound_function.return_type = child_type;
84155
+ return make_unique<VariableReturnBindData>(bound_function.return_type);
84156
+ }
84157
+
84158
+ static unique_ptr<BaseStatistics> ListFlattenStats(ClientContext &context, BoundFunctionExpression &expr,
84159
+ FunctionData *bind_data,
84160
+ vector<unique_ptr<BaseStatistics>> &child_stats) {
84161
+ if (!child_stats[0]) {
84162
+ return nullptr;
84163
+ }
84164
+ auto &list_stats = (ListStatistics &)*child_stats[0];
84165
+ if (!list_stats.child_stats || list_stats.child_stats->type == LogicalTypeId::SQLNULL) {
84166
+ return nullptr;
84167
+ }
84168
+
84169
+ auto child_copy = list_stats.child_stats->Copy();
84170
+ child_copy->validity_stats = make_unique<ValidityStatistics>(true);
84171
+ return child_copy;
84172
+ }
84173
+
84174
+ void ListFlattenFun::RegisterFunction(BuiltinFunctions &set) {
84175
+ ScalarFunction fun({LogicalType::LIST(LogicalType::LIST(LogicalType::ANY))}, LogicalType::LIST(LogicalType::ANY),
84176
+ ListFlattenFunction, false, ListFlattenBind, nullptr, ListFlattenStats);
84177
+ set.AddFunction({"flatten"}, fun);
84178
+ }
84179
+
84180
+ } // namespace duckdb
84181
+
84182
+
84183
+
84184
+
84185
+
84186
+
84047
84187
 
84048
84188
  namespace duckdb {
84049
84189
 
@@ -86233,6 +86373,7 @@ void BuiltinFunctions::RegisterNestedFunctions() {
86233
86373
  Register<ListValueFun>();
86234
86374
  Register<ListExtractFun>();
86235
86375
  Register<ListRangeFun>();
86376
+ Register<ListFlattenFun>();
86236
86377
  Register<MapFun>();
86237
86378
  Register<MapExtractFun>();
86238
86379
  Register<CardinalityFun>();
@@ -98992,7 +99133,8 @@ void PragmaDatabaseSizeFunction(ClientContext &context, const FunctionData *bind
98992
99133
  auto free_blocks = block_manager.FreeBlocks();
98993
99134
  auto used_blocks = total_blocks - free_blocks;
98994
99135
  auto bytes = (total_blocks * block_size);
98995
- auto wal_size = storage.GetWriteAheadLog()->GetWALSize();
99136
+ auto wal = storage.GetWriteAheadLog();
99137
+ auto wal_size = wal ? wal->GetWALSize() : 0;
98996
99138
  output.data[0].SetValue(0, Value(StringUtil::BytesToHumanReadableString(bytes)));
98997
99139
  output.data[1].SetValue(0, Value::BIGINT(block_size));
98998
99140
  output.data[2].SetValue(0, Value::BIGINT(total_blocks));
@@ -227194,6 +227336,7 @@ size_t Utf8Proc::RenderWidth(const char *s, size_t len, size_t pos) {
227194
227336
 
227195
227337
 
227196
227338
  #include <stdlib.h>
227339
+ #include <string>
227197
227340
 
227198
227341
 
227199
227342
 
@@ -227206,7 +227349,7 @@ typedef struct parse_result_str parse_result;
227206
227349
  struct parse_result_str {
227207
227350
  bool success;
227208
227351
  PGList *parse_tree;
227209
- char *error_message;
227352
+ std::string error_message;
227210
227353
  int error_location;
227211
227354
  };
227212
227355
 
@@ -227287,6 +227430,7 @@ static void allocate_new(parser_state *state, size_t n) {
227287
227430
  if (state->malloc_ptr_idx >= state->malloc_ptr_size) {
227288
227431
  size_t new_size = state->malloc_ptr_size * 2;
227289
227432
  auto new_malloc_ptrs = (char **) malloc(sizeof(char *) * new_size);
227433
+ memset(new_malloc_ptrs, 0, sizeof(char*) * new_size);
227290
227434
  memcpy(new_malloc_ptrs, state->malloc_ptrs, state->malloc_ptr_size * sizeof(char*));
227291
227435
  free(state->malloc_ptrs);
227292
227436
  state->malloc_ptr_size = new_size;
@@ -227328,6 +227472,7 @@ void pg_parser_init() {
227328
227472
 
227329
227473
  pg_parser_state.malloc_ptr_size = 4;
227330
227474
  pg_parser_state.malloc_ptrs = (char **) malloc(sizeof(char *) * pg_parser_state.malloc_ptr_size);
227475
+ memset(pg_parser_state.malloc_ptrs, 0, sizeof(char*) * pg_parser_state.malloc_ptr_size);
227331
227476
  pg_parser_state.malloc_ptr_idx = 0;
227332
227477
  allocate_new(&pg_parser_state, 1);
227333
227478
  }
@@ -227339,14 +227484,7 @@ void pg_parser_parse(const char *query, parse_result *res) {
227339
227484
  res->success = pg_parser_state.pg_err_code == PGUNDEFINED;
227340
227485
  } catch (std::exception &ex) {
227341
227486
  res->success = false;
227342
- // copy the error message of the exception
227343
- auto error_message = ex.what();
227344
- uint32_t pos = 0;
227345
- while(pos < 1023 && error_message[pos]) {
227346
- pg_parser_state.pg_err_msg[pos] = error_message[pos];
227347
- pos++;
227348
- }
227349
- pg_parser_state.pg_err_msg[pos] = '\0';
227487
+ res->error_message = ex.what();
227350
227488
  }
227351
227489
  res->error_message = pg_parser_state.pg_err_msg;
227352
227490
  res->error_location = pg_parser_state.pg_err_pos;
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 "9243d7b58"
15
- #define DUCKDB_VERSION "v0.3.3-dev562"
14
+ #define DUCKDB_SOURCE_ID "818903e44"
15
+ #define DUCKDB_VERSION "v0.3.3-dev581"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //