duckdb 0.4.1-dev1559.0 → 0.4.1-dev1562.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-dev1559.0",
4
+ "version": "0.4.1-dev1562.0",
5
5
  "description": "DuckDB node.js API",
6
6
  "gypfile": true,
7
7
  "dependencies": {
package/src/duckdb.cpp CHANGED
@@ -99332,7 +99332,6 @@ static void ListAggregatesFunction(DataChunk &args, ExpressionState &state, Vect
99332
99332
 
99333
99333
  // states vector is full, update
99334
99334
  if (states_idx == STANDARD_VECTOR_SIZE) {
99335
-
99336
99335
  // update the aggregate state(s)
99337
99336
  Vector slice = Vector(child_vector, sel_vector, states_idx);
99338
99337
  aggr.function.update(&slice, aggr_input_data, 1, state_vector_update, states_idx);
@@ -99437,14 +99436,21 @@ static void ListUniqueFunction(DataChunk &args, ExpressionState &state, Vector &
99437
99436
  }
99438
99437
 
99439
99438
  template <bool IS_AGGR = false>
99440
- static unique_ptr<FunctionData> ListAggregatesBindFunction(ClientContext &context, ScalarFunction &bound_function,
99441
- const LogicalType &list_child_type,
99442
- AggregateFunction &aggr_function) {
99439
+ static unique_ptr<FunctionData>
99440
+ ListAggregatesBindFunction(ClientContext &context, ScalarFunction &bound_function, const LogicalType &list_child_type,
99441
+ AggregateFunction &aggr_function, vector<unique_ptr<Expression>> &arguments) {
99443
99442
 
99444
99443
  // create the child expression and its type
99445
99444
  vector<unique_ptr<Expression>> children;
99446
99445
  auto expr = make_unique<BoundConstantExpression>(Value(list_child_type));
99447
99446
  children.push_back(move(expr));
99447
+ // push any extra arguments into the list aggregate bind
99448
+ if (arguments.size() > 2) {
99449
+ for (idx_t i = 2; i < arguments.size(); i++) {
99450
+ children.push_back(move(arguments[i]));
99451
+ }
99452
+ arguments.resize(2);
99453
+ }
99448
99454
 
99449
99455
  auto bound_aggr_function = AggregateFunction::BindAggregateFunction(context, aggr_function, move(children));
99450
99456
  bound_function.arguments[0] = LogicalType::LIST(bound_aggr_function->function.arguments[0]);
@@ -99452,6 +99458,12 @@ static unique_ptr<FunctionData> ListAggregatesBindFunction(ClientContext &contex
99452
99458
  if (IS_AGGR) {
99453
99459
  bound_function.return_type = bound_aggr_function->function.return_type;
99454
99460
  }
99461
+ // check if the aggregate function consumed all the extra input arguments
99462
+ if (bound_aggr_function->children.size() > 1) {
99463
+ throw InvalidInputException(
99464
+ "Aggregate function %s is not supported for list_aggr: extra arguments were not removed during bind",
99465
+ bound_aggr_function->ToString());
99466
+ }
99455
99467
 
99456
99468
  return make_unique<ListAggregatesBindData>(bound_function.return_type, move(bound_aggr_function));
99457
99469
  }
@@ -99470,7 +99482,6 @@ static unique_ptr<FunctionData> ListAggregatesBind(ClientContext &context, Scala
99470
99482
 
99471
99483
  string function_name = "histogram";
99472
99484
  if (IS_AGGR) { // get the name of the aggregate function
99473
-
99474
99485
  if (!arguments[1]->IsFoldable()) {
99475
99486
  throw InvalidInputException("Aggregate function name must be a constant");
99476
99487
  }
@@ -99495,31 +99506,35 @@ static unique_ptr<FunctionData> ListAggregatesBind(ClientContext &context, Scala
99495
99506
  string error;
99496
99507
  vector<LogicalType> types;
99497
99508
  types.push_back(list_child_type);
99509
+ // push any extra arguments into the type list
99510
+ for (idx_t i = 2; i < arguments.size(); i++) {
99511
+ types.push_back(arguments[i]->return_type);
99512
+ }
99498
99513
  auto best_function_idx = Function::BindFunction(func->name, func->functions, types, error);
99499
99514
  if (best_function_idx == DConstants::INVALID_INDEX) {
99500
- throw BinderException("No matching aggregate function");
99515
+ throw BinderException("No matching aggregate function\n%s", error);
99501
99516
  }
99502
99517
 
99503
99518
  // found a matching function, bind it as an aggregate
99504
99519
  auto &best_function = func->functions[best_function_idx];
99505
99520
 
99506
99521
  if (IS_AGGR) {
99507
- return ListAggregatesBindFunction<IS_AGGR>(context, bound_function, list_child_type, best_function);
99522
+ return ListAggregatesBindFunction<IS_AGGR>(context, bound_function, list_child_type, best_function, arguments);
99508
99523
  }
99509
99524
 
99510
99525
  // create the unordered map histogram function
99511
99526
  D_ASSERT(best_function.arguments.size() == 1);
99512
99527
  auto key_type = best_function.arguments[0];
99513
99528
  auto aggr_function = HistogramFun::GetHistogramUnorderedMap(key_type);
99514
- return ListAggregatesBindFunction<IS_AGGR>(context, bound_function, list_child_type, aggr_function);
99529
+ return ListAggregatesBindFunction<IS_AGGR>(context, bound_function, list_child_type, aggr_function, arguments);
99515
99530
  }
99516
99531
 
99517
99532
  static unique_ptr<FunctionData> ListAggregateBind(ClientContext &context, ScalarFunction &bound_function,
99518
99533
  vector<unique_ptr<Expression>> &arguments) {
99519
99534
 
99520
99535
  // the list column and the name of the aggregate function
99521
- D_ASSERT(bound_function.arguments.size() == 2);
99522
- D_ASSERT(arguments.size() == 2);
99536
+ D_ASSERT(bound_function.arguments.size() >= 2);
99537
+ D_ASSERT(arguments.size() >= 2);
99523
99538
 
99524
99539
  return ListAggregatesBind<true>(context, bound_function, arguments);
99525
99540
  }
@@ -99548,6 +99563,7 @@ ScalarFunction ListAggregateFun::GetFunction() {
99548
99563
  auto result = ScalarFunction({LogicalType::LIST(LogicalType::ANY), LogicalType::VARCHAR}, LogicalType::ANY,
99549
99564
  ListAggregateFunction, ListAggregateBind);
99550
99565
  result.null_handling = FunctionNullHandling::SPECIAL_HANDLING;
99566
+ result.varargs = LogicalType::ANY;
99551
99567
  return result;
99552
99568
  }
99553
99569
 
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 "246ee60e8"
15
- #define DUCKDB_VERSION "v0.4.1-dev1559"
14
+ #define DUCKDB_SOURCE_ID "5fdf4a947"
15
+ #define DUCKDB_VERSION "v0.4.1-dev1562"
16
16
  //===----------------------------------------------------------------------===//
17
17
  // DuckDB
18
18
  //