duckdb 0.3.3-dev835.0 → 0.3.3-dev844.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-dev835.0",
4
+ "version": "0.3.3-dev844.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -76299,10 +76299,12 @@ static void ListCombineFunction(Vector &state, Vector &combined, idx_t count) {
76299
76299
  auto states_ptr = (ListAggState **)sdata.data;
76300
76300
 
76301
76301
  auto combined_ptr = FlatVector::GetData<ListAggState *>(combined);
76302
-
76303
76302
  for (idx_t i = 0; i < count; i++) {
76304
76303
  auto state = states_ptr[sdata.sel->get_index(i)];
76305
- D_ASSERT(state->list_vector);
76304
+ if (!state->list_vector) {
76305
+ // NULL, no need to append.
76306
+ continue;
76307
+ }
76306
76308
  if (!combined_ptr[i]->list_vector) {
76307
76309
  combined_ptr[i]->list_vector = new Vector(state->list_vector->GetType());
76308
76310
  }
@@ -76320,17 +76322,18 @@ static void ListFinalize(Vector &state_vector, FunctionData *, Vector &result, i
76320
76322
 
76321
76323
  auto &mask = FlatVector::Validity(result);
76322
76324
  size_t total_len = ListVector::GetListSize(result);
76325
+
76323
76326
  for (idx_t i = 0; i < count; i++) {
76324
76327
  auto state = states[sdata.sel->get_index(i)];
76328
+ const auto rid = i + offset;
76325
76329
  if (!state->list_vector) {
76326
- mask.SetInvalid(i);
76330
+ mask.SetInvalid(rid);
76327
76331
  continue;
76328
76332
  }
76329
- D_ASSERT(state->list_vector);
76333
+
76330
76334
  auto list_struct_data = FlatVector::GetData<list_entry_t>(result);
76331
76335
  auto &state_lv = *state->list_vector;
76332
76336
  auto state_lv_count = ListVector::GetListSize(state_lv);
76333
- const auto rid = i + offset;
76334
76337
  list_struct_data[rid].length = state_lv_count;
76335
76338
  list_struct_data[rid].offset = total_len;
76336
76339
  total_len += state_lv_count;
@@ -90184,17 +90187,75 @@ struct MD5Operator {
90184
90187
  }
90185
90188
  };
90186
90189
 
90190
+ struct MD5Number128Operator {
90191
+ template <class INPUT_TYPE, class RESULT_TYPE>
90192
+ static RESULT_TYPE Operation(INPUT_TYPE input) {
90193
+ data_t digest[MD5Context::MD5_HASH_LENGTH_BINARY];
90194
+
90195
+ MD5Context context;
90196
+ context.Add(input);
90197
+ context.Finish(digest);
90198
+ return *reinterpret_cast<hugeint_t *>(digest);
90199
+ }
90200
+ };
90201
+
90202
+ template <bool lower>
90203
+ struct MD5Number64Operator {
90204
+ template <class INPUT_TYPE, class RESULT_TYPE>
90205
+ static RESULT_TYPE Operation(INPUT_TYPE input) {
90206
+ data_t digest[MD5Context::MD5_HASH_LENGTH_BINARY];
90207
+
90208
+ MD5Context context;
90209
+ context.Add(input);
90210
+ context.Finish(digest);
90211
+ return *reinterpret_cast<uint64_t *>(&digest[lower ? 8 : 0]);
90212
+ }
90213
+ };
90214
+
90187
90215
  static void MD5Function(DataChunk &args, ExpressionState &state, Vector &result) {
90188
90216
  auto &input = args.data[0];
90189
90217
 
90190
90218
  UnaryExecutor::ExecuteString<string_t, string_t, MD5Operator>(input, result, args.size());
90191
90219
  }
90192
90220
 
90221
+ static void MD5NumberFunction(DataChunk &args, ExpressionState &state, Vector &result) {
90222
+ auto &input = args.data[0];
90223
+
90224
+ UnaryExecutor::Execute<string_t, hugeint_t, MD5Number128Operator>(input, result, args.size());
90225
+ }
90226
+
90227
+ static void MD5NumberUpperFunction(DataChunk &args, ExpressionState &state, Vector &result) {
90228
+ auto &input = args.data[0];
90229
+
90230
+ UnaryExecutor::Execute<string_t, uint64_t, MD5Number64Operator<false>>(input, result, args.size());
90231
+ }
90232
+
90233
+ static void MD5NumberLowerFunction(DataChunk &args, ExpressionState &state, Vector &result) {
90234
+ auto &input = args.data[0];
90235
+
90236
+ UnaryExecutor::Execute<string_t, uint64_t, MD5Number64Operator<true>>(input, result, args.size());
90237
+ }
90238
+
90193
90239
  void MD5Fun::RegisterFunction(BuiltinFunctions &set) {
90194
90240
  set.AddFunction(ScalarFunction("md5", // name of the function
90195
90241
  {LogicalType::VARCHAR}, // argument list
90196
90242
  LogicalType::VARCHAR, // return type
90197
90243
  MD5Function)); // pointer to function implementation
90244
+
90245
+ set.AddFunction(ScalarFunction("md5_number", // name of the function
90246
+ {LogicalType::VARCHAR}, // argument list
90247
+ LogicalType::HUGEINT, // return type
90248
+ MD5NumberFunction)); // pointer to function implementation
90249
+
90250
+ set.AddFunction(ScalarFunction("md5_number_upper", // name of the function
90251
+ {LogicalType::VARCHAR}, // argument list
90252
+ LogicalType::UBIGINT, // return type
90253
+ MD5NumberUpperFunction)); // pointer to function implementation
90254
+
90255
+ set.AddFunction(ScalarFunction("md5_number_lower", // name of the function
90256
+ {LogicalType::VARCHAR}, // argument list
90257
+ LogicalType::UBIGINT, // return type
90258
+ MD5NumberLowerFunction)); // pointer to function implementation
90198
90259
  }
90199
90260
 
90200
90261
  } // namespace duckdb
@@ -128146,12 +128207,30 @@ bool Pipeline::GetProgressInternal(ClientContext &context, PhysicalOperator *op,
128146
128207
  current_percentage = get.function.table_scan_progress(context, get.bind_data.get());
128147
128208
  return true;
128148
128209
  }
128149
- //! If the table_scan_progress is not implemented it means we don't support this function yet in the progress
128150
- //! bar
128210
+ // If the table_scan_progress is not implemented it means we don't support this function yet in the progress
128211
+ // bar
128151
128212
  return false;
128152
128213
  }
128153
- default:
128154
- return false;
128214
+ // If it is not a table scan we go down on all children until we reach the leaf operators
128215
+ default: {
128216
+ vector<idx_t> progress;
128217
+ vector<idx_t> cardinality;
128218
+ double total_cardinality = 0;
128219
+ current_percentage = 0;
128220
+ for (auto &op_child : op->children) {
128221
+ double child_percentage = 0;
128222
+ if (!GetProgressInternal(context, op_child.get(), child_percentage)) {
128223
+ return false;
128224
+ }
128225
+ progress.push_back(child_percentage);
128226
+ cardinality.push_back(op_child->estimated_cardinality);
128227
+ total_cardinality += op_child->estimated_cardinality;
128228
+ }
128229
+ for (size_t i = 0; i < progress.size(); i++) {
128230
+ current_percentage += progress[i] * cardinality[i] / total_cardinality;
128231
+ }
128232
+ return true;
128233
+ }
128155
128234
  }
128156
128235
  }
128157
128236
  // LCOV_EXCL_STOP