duckdb 0.2.10-dev437.0 → 0.2.10-dev451.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 +1 -1
- package/src/duckdb.cpp +96 -22
- package/src/duckdb.hpp +56 -38
package/package.json
CHANGED
package/src/duckdb.cpp
CHANGED
|
@@ -47804,12 +47804,15 @@ namespace duckdb {
|
|
|
47804
47804
|
|
|
47805
47805
|
unique_ptr<ExpressionState> ExpressionExecutor::InitializeState(const BoundFunctionExpression &expr,
|
|
47806
47806
|
ExpressionExecutorState &root) {
|
|
47807
|
-
auto result = make_unique<
|
|
47807
|
+
auto result = make_unique<ExecuteFunctionState>(expr, root);
|
|
47808
47808
|
for (auto &child : expr.children) {
|
|
47809
47809
|
result->AddChild(child.get());
|
|
47810
47810
|
}
|
|
47811
47811
|
result->Finalize();
|
|
47812
|
-
|
|
47812
|
+
if (expr.function.init_local_state) {
|
|
47813
|
+
result->local_state = expr.function.init_local_state(expr, expr.bind_info.get());
|
|
47814
|
+
}
|
|
47815
|
+
return move(result);
|
|
47813
47816
|
}
|
|
47814
47817
|
|
|
47815
47818
|
void ExpressionExecutor::Execute(const BoundFunctionExpression &expr, ExpressionState *state,
|
|
@@ -80389,20 +80392,20 @@ template <class OP>
|
|
|
80389
80392
|
static void RegisterLeastGreatest(BuiltinFunctions &set, const string &fun_name) {
|
|
80390
80393
|
ScalarFunctionSet fun_set(fun_name);
|
|
80391
80394
|
fun_set.AddFunction(ScalarFunction({LogicalType::DATE}, LogicalType::DATE, LeastGreatestFunction<date_t, OP>, false,
|
|
80392
|
-
nullptr, nullptr, nullptr, LogicalType::DATE));
|
|
80395
|
+
nullptr, nullptr, nullptr, nullptr, LogicalType::DATE));
|
|
80393
80396
|
fun_set.AddFunction(ScalarFunction({LogicalType::TIMESTAMP}, LogicalType::TIMESTAMP,
|
|
80394
80397
|
LeastGreatestFunction<timestamp_t, OP>, false, nullptr, nullptr, nullptr,
|
|
80395
|
-
LogicalType::TIMESTAMP));
|
|
80398
|
+
nullptr, LogicalType::TIMESTAMP));
|
|
80396
80399
|
fun_set.AddFunction(ScalarFunction({LogicalType::BIGINT}, LogicalType::BIGINT, LeastGreatestFunction<int64_t, OP>,
|
|
80397
|
-
false, nullptr, nullptr, nullptr, LogicalType::BIGINT));
|
|
80400
|
+
false, nullptr, nullptr, nullptr, nullptr, LogicalType::BIGINT));
|
|
80398
80401
|
fun_set.AddFunction(ScalarFunction({LogicalType::HUGEINT}, LogicalType::HUGEINT,
|
|
80399
|
-
LeastGreatestFunction<hugeint_t, OP>, false, nullptr, nullptr, nullptr,
|
|
80402
|
+
LeastGreatestFunction<hugeint_t, OP>, false, nullptr, nullptr, nullptr, nullptr,
|
|
80400
80403
|
LogicalType::HUGEINT));
|
|
80401
80404
|
fun_set.AddFunction(ScalarFunction({LogicalType::DOUBLE}, LogicalType::DOUBLE, LeastGreatestFunction<double, OP>,
|
|
80402
|
-
false, nullptr, nullptr, nullptr, LogicalType::DOUBLE));
|
|
80405
|
+
false, nullptr, nullptr, nullptr, nullptr, LogicalType::DOUBLE));
|
|
80403
80406
|
fun_set.AddFunction(ScalarFunction({LogicalType::VARCHAR}, LogicalType::VARCHAR,
|
|
80404
80407
|
LeastGreatestFunction<string_t, OP, true>, false, nullptr, nullptr, nullptr,
|
|
80405
|
-
LogicalType::VARCHAR));
|
|
80408
|
+
nullptr, LogicalType::VARCHAR));
|
|
80406
80409
|
set.AddFunction(fun_set);
|
|
80407
80410
|
}
|
|
80408
80411
|
|
|
@@ -87959,7 +87962,7 @@ struct RegexpMatchesBindData : public FunctionData {
|
|
|
87959
87962
|
|
|
87960
87963
|
duckdb_re2::RE2::Options options;
|
|
87961
87964
|
string constant_string;
|
|
87962
|
-
|
|
87965
|
+
bool constant_pattern;
|
|
87963
87966
|
string range_min;
|
|
87964
87967
|
string range_max;
|
|
87965
87968
|
bool range_success;
|
|
@@ -87981,13 +87984,14 @@ namespace duckdb {
|
|
|
87981
87984
|
|
|
87982
87985
|
RegexpMatchesBindData::RegexpMatchesBindData(duckdb_re2::RE2::Options options, string constant_string_p)
|
|
87983
87986
|
: options(options), constant_string(move(constant_string_p)) {
|
|
87984
|
-
|
|
87985
|
-
|
|
87986
|
-
|
|
87987
|
-
|
|
87987
|
+
constant_pattern = !constant_string.empty();
|
|
87988
|
+
if (constant_pattern) {
|
|
87989
|
+
auto pattern = make_unique<RE2>(constant_string, options);
|
|
87990
|
+
if (!pattern->ok()) {
|
|
87991
|
+
throw Exception(pattern->error());
|
|
87988
87992
|
}
|
|
87989
87993
|
|
|
87990
|
-
range_success =
|
|
87994
|
+
range_success = pattern->PossibleMatchRange(&range_min, &range_max, 1000);
|
|
87991
87995
|
} else {
|
|
87992
87996
|
range_success = false;
|
|
87993
87997
|
}
|
|
@@ -88056,6 +88060,24 @@ struct RegexFullMatch {
|
|
|
88056
88060
|
}
|
|
88057
88061
|
};
|
|
88058
88062
|
|
|
88063
|
+
struct RegexLocalState : public FunctionData {
|
|
88064
|
+
explicit RegexLocalState(RegexpMatchesBindData &info)
|
|
88065
|
+
: constant_pattern(duckdb_re2::StringPiece(info.constant_string.c_str(), info.constant_string.size()),
|
|
88066
|
+
info.options) {
|
|
88067
|
+
D_ASSERT(info.constant_pattern);
|
|
88068
|
+
}
|
|
88069
|
+
|
|
88070
|
+
RE2 constant_pattern;
|
|
88071
|
+
};
|
|
88072
|
+
|
|
88073
|
+
static unique_ptr<FunctionData> RegexInitLocalState(const BoundFunctionExpression &expr, FunctionData *bind_data) {
|
|
88074
|
+
auto &info = (RegexpMatchesBindData &)*bind_data;
|
|
88075
|
+
if (info.constant_pattern) {
|
|
88076
|
+
return make_unique<RegexLocalState>(info);
|
|
88077
|
+
}
|
|
88078
|
+
return nullptr;
|
|
88079
|
+
}
|
|
88080
|
+
|
|
88059
88081
|
template <class OP>
|
|
88060
88082
|
static void RegexpMatchesFunction(DataChunk &args, ExpressionState &state, Vector &result) {
|
|
88061
88083
|
auto &strings = args.data[0];
|
|
@@ -88065,8 +88087,9 @@ static void RegexpMatchesFunction(DataChunk &args, ExpressionState &state, Vecto
|
|
|
88065
88087
|
auto &info = (RegexpMatchesBindData &)*func_expr.bind_info;
|
|
88066
88088
|
|
|
88067
88089
|
if (info.constant_pattern) {
|
|
88090
|
+
auto &lstate = (RegexLocalState &)*ExecuteFunctionState::GetFunctionState(state);
|
|
88068
88091
|
UnaryExecutor::Execute<string_t, bool>(strings, result, args.size(), [&](string_t input) {
|
|
88069
|
-
return OP::Operation(CreateStringPiece(input),
|
|
88092
|
+
return OP::Operation(CreateStringPiece(input), lstate.constant_pattern);
|
|
88070
88093
|
});
|
|
88071
88094
|
} else {
|
|
88072
88095
|
BinaryExecutor::Execute<string_t, string_t, bool>(strings, patterns, result, args.size(),
|
|
@@ -88153,18 +88176,19 @@ static unique_ptr<FunctionData> RegexReplaceBind(ClientContext &context, ScalarF
|
|
|
88153
88176
|
void RegexpFun::RegisterFunction(BuiltinFunctions &set) {
|
|
88154
88177
|
ScalarFunctionSet regexp_full_match("regexp_full_match");
|
|
88155
88178
|
regexp_full_match.AddFunction(ScalarFunction({LogicalType::VARCHAR, LogicalType::VARCHAR}, LogicalType::BOOLEAN,
|
|
88156
|
-
RegexpMatchesFunction<RegexFullMatch>, false, RegexpMatchesBind
|
|
88179
|
+
RegexpMatchesFunction<RegexFullMatch>, false, RegexpMatchesBind,
|
|
88180
|
+
nullptr, nullptr, RegexInitLocalState));
|
|
88157
88181
|
regexp_full_match.AddFunction(ScalarFunction({LogicalType::VARCHAR, LogicalType::VARCHAR, LogicalType::VARCHAR},
|
|
88158
88182
|
LogicalType::BOOLEAN, RegexpMatchesFunction<RegexFullMatch>, false,
|
|
88159
|
-
RegexpMatchesBind));
|
|
88183
|
+
RegexpMatchesBind, nullptr, nullptr, RegexInitLocalState));
|
|
88160
88184
|
|
|
88161
88185
|
ScalarFunctionSet regexp_partial_match("regexp_matches");
|
|
88162
88186
|
regexp_partial_match.AddFunction(ScalarFunction({LogicalType::VARCHAR, LogicalType::VARCHAR}, LogicalType::BOOLEAN,
|
|
88163
|
-
RegexpMatchesFunction<RegexPartialMatch>, false,
|
|
88164
|
-
|
|
88187
|
+
RegexpMatchesFunction<RegexPartialMatch>, false, RegexpMatchesBind,
|
|
88188
|
+
nullptr, nullptr, RegexInitLocalState));
|
|
88165
88189
|
regexp_partial_match.AddFunction(ScalarFunction({LogicalType::VARCHAR, LogicalType::VARCHAR, LogicalType::VARCHAR},
|
|
88166
88190
|
LogicalType::BOOLEAN, RegexpMatchesFunction<RegexPartialMatch>,
|
|
88167
|
-
false, RegexpMatchesBind));
|
|
88191
|
+
false, RegexpMatchesBind, nullptr, nullptr, RegexInitLocalState));
|
|
88168
88192
|
|
|
88169
88193
|
ScalarFunctionSet regexp_replace("regexp_replace");
|
|
88170
88194
|
regexp_replace.AddFunction(ScalarFunction({LogicalType::VARCHAR, LogicalType::VARCHAR, LogicalType::VARCHAR},
|
|
@@ -126729,6 +126753,27 @@ unique_ptr<ParsedExpression> Transformer::TransformFuncCall(duckdb_libpgquery::P
|
|
|
126729
126753
|
auto order_bys = make_unique<OrderModifier>();
|
|
126730
126754
|
TransformOrderBy(root->agg_order, order_bys->orders);
|
|
126731
126755
|
|
|
126756
|
+
// Ordered aggregates can be either WITHIN GROUP or after the function arguments
|
|
126757
|
+
if (root->agg_within_group) {
|
|
126758
|
+
// https://www.postgresql.org/docs/current/functions-aggregate.html#FUNCTIONS-ORDEREDSET-TABLE
|
|
126759
|
+
// Since we implement "ordered aggregates" without sorting,
|
|
126760
|
+
// we map all the ones we support to the corresponding aggregate function.
|
|
126761
|
+
if (order_bys->orders.size() != 1) {
|
|
126762
|
+
throw ParserException("Cannot use multiple ORDER BY clauses with WITHIN GROUP");
|
|
126763
|
+
}
|
|
126764
|
+
if (lowercase_name == "percentile_cont") {
|
|
126765
|
+
lowercase_name = "quantile_cont";
|
|
126766
|
+
} else if (lowercase_name == "percentile_disc") {
|
|
126767
|
+
lowercase_name = "quantile_disc";
|
|
126768
|
+
} else if (lowercase_name == "mode") {
|
|
126769
|
+
lowercase_name = "mode";
|
|
126770
|
+
} else {
|
|
126771
|
+
throw ParserException("Unknown ordered aggregate \"%s\".", function_name);
|
|
126772
|
+
}
|
|
126773
|
+
children.insert(children.begin(), move(order_bys->orders[0].expression));
|
|
126774
|
+
order_bys->orders.clear();
|
|
126775
|
+
}
|
|
126776
|
+
|
|
126732
126777
|
// star gets eaten in the parser
|
|
126733
126778
|
if (lowercase_name == "count" && children.empty()) {
|
|
126734
126779
|
lowercase_name = "count_star";
|
|
@@ -135014,6 +135059,16 @@ static unique_ptr<ParsedExpression> SummarizeCreateAggregate(const string &aggre
|
|
|
135014
135059
|
return move(cast_function);
|
|
135015
135060
|
}
|
|
135016
135061
|
|
|
135062
|
+
static unique_ptr<ParsedExpression> SummarizeCreateAggregate(const string &aggregate, string column_name,
|
|
135063
|
+
const Value &modifier) {
|
|
135064
|
+
vector<unique_ptr<ParsedExpression>> children;
|
|
135065
|
+
children.push_back(make_unique<ColumnRefExpression>(move(column_name)));
|
|
135066
|
+
children.push_back(make_unique<ConstantExpression>(modifier));
|
|
135067
|
+
auto aggregate_function = make_unique<FunctionExpression>(aggregate, move(children));
|
|
135068
|
+
auto cast_function = make_unique<CastExpression>(LogicalType::VARCHAR, move(aggregate_function));
|
|
135069
|
+
return move(cast_function);
|
|
135070
|
+
}
|
|
135071
|
+
|
|
135017
135072
|
static unique_ptr<ParsedExpression> SummarizeCreateCountStar() {
|
|
135018
135073
|
vector<unique_ptr<ParsedExpression>> children;
|
|
135019
135074
|
auto aggregate_function = make_unique<FunctionExpression>("count_star", move(children));
|
|
@@ -135057,6 +135112,10 @@ BoundStatement Binder::BindSummarize(ShowStatement &stmt) {
|
|
|
135057
135112
|
vector<unique_ptr<ParsedExpression>> max_children;
|
|
135058
135113
|
vector<unique_ptr<ParsedExpression>> unique_children;
|
|
135059
135114
|
vector<unique_ptr<ParsedExpression>> avg_children;
|
|
135115
|
+
vector<unique_ptr<ParsedExpression>> std_children;
|
|
135116
|
+
vector<unique_ptr<ParsedExpression>> q25_children;
|
|
135117
|
+
vector<unique_ptr<ParsedExpression>> q50_children;
|
|
135118
|
+
vector<unique_ptr<ParsedExpression>> q75_children;
|
|
135060
135119
|
vector<unique_ptr<ParsedExpression>> count_children;
|
|
135061
135120
|
vector<unique_ptr<ParsedExpression>> null_percentage_children;
|
|
135062
135121
|
auto select = make_unique<SelectStatement>();
|
|
@@ -135067,8 +135126,19 @@ BoundStatement Binder::BindSummarize(ShowStatement &stmt) {
|
|
|
135067
135126
|
min_children.push_back(SummarizeCreateAggregate("min", plan.names[i]));
|
|
135068
135127
|
max_children.push_back(SummarizeCreateAggregate("max", plan.names[i]));
|
|
135069
135128
|
unique_children.push_back(SummarizeCreateAggregate("approx_count_distinct", plan.names[i]));
|
|
135070
|
-
|
|
135071
|
-
|
|
135129
|
+
if (plan.types[i].IsNumeric()) {
|
|
135130
|
+
avg_children.push_back(SummarizeCreateAggregate("avg", plan.names[i]));
|
|
135131
|
+
std_children.push_back(SummarizeCreateAggregate("stddev", plan.names[i]));
|
|
135132
|
+
q25_children.push_back(SummarizeCreateAggregate("approx_quantile", plan.names[i], Value::FLOAT(0.25)));
|
|
135133
|
+
q50_children.push_back(SummarizeCreateAggregate("approx_quantile", plan.names[i], Value::FLOAT(0.50)));
|
|
135134
|
+
q75_children.push_back(SummarizeCreateAggregate("approx_quantile", plan.names[i], Value::FLOAT(0.75)));
|
|
135135
|
+
} else {
|
|
135136
|
+
avg_children.push_back(make_unique<ConstantExpression>(Value()));
|
|
135137
|
+
std_children.push_back(make_unique<ConstantExpression>(Value()));
|
|
135138
|
+
q25_children.push_back(make_unique<ConstantExpression>(Value()));
|
|
135139
|
+
q50_children.push_back(make_unique<ConstantExpression>(Value()));
|
|
135140
|
+
q75_children.push_back(make_unique<ConstantExpression>(Value()));
|
|
135141
|
+
}
|
|
135072
135142
|
count_children.push_back(SummarizeCreateCountStar());
|
|
135073
135143
|
null_percentage_children.push_back(SummarizeCreateNullPercentage(plan.names[i]));
|
|
135074
135144
|
}
|
|
@@ -135082,6 +135152,10 @@ BoundStatement Binder::BindSummarize(ShowStatement &stmt) {
|
|
|
135082
135152
|
select_node->select_list.push_back(SummarizeWrapUnnest(max_children, "max"));
|
|
135083
135153
|
select_node->select_list.push_back(SummarizeWrapUnnest(unique_children, "approx_unique"));
|
|
135084
135154
|
select_node->select_list.push_back(SummarizeWrapUnnest(avg_children, "avg"));
|
|
135155
|
+
select_node->select_list.push_back(SummarizeWrapUnnest(std_children, "std"));
|
|
135156
|
+
select_node->select_list.push_back(SummarizeWrapUnnest(q25_children, "q25"));
|
|
135157
|
+
select_node->select_list.push_back(SummarizeWrapUnnest(q50_children, "q50"));
|
|
135158
|
+
select_node->select_list.push_back(SummarizeWrapUnnest(q75_children, "q75"));
|
|
135085
135159
|
select_node->select_list.push_back(SummarizeWrapUnnest(count_children, "count"));
|
|
135086
135160
|
select_node->select_list.push_back(SummarizeWrapUnnest(null_percentage_children, "null_percentage"));
|
|
135087
135161
|
select_node->from_table = move(subquery_ref);
|
package/src/duckdb.hpp
CHANGED
|
@@ -10,8 +10,8 @@ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLI
|
|
|
10
10
|
|
|
11
11
|
#pragma once
|
|
12
12
|
#define DUCKDB_AMALGAMATION 1
|
|
13
|
-
#define DUCKDB_SOURCE_ID "
|
|
14
|
-
#define DUCKDB_VERSION "0.2.10-
|
|
13
|
+
#define DUCKDB_SOURCE_ID "0edad5d3d"
|
|
14
|
+
#define DUCKDB_VERSION "0.2.10-dev451"
|
|
15
15
|
//===----------------------------------------------------------------------===//
|
|
16
16
|
// DuckDB
|
|
17
17
|
//
|
|
@@ -5014,40 +5014,6 @@ private:
|
|
|
5014
5014
|
} // namespace duckdb
|
|
5015
5015
|
|
|
5016
5016
|
|
|
5017
|
-
|
|
5018
|
-
namespace duckdb {
|
|
5019
|
-
class Expression;
|
|
5020
|
-
class ExpressionExecutor;
|
|
5021
|
-
struct ExpressionExecutorState;
|
|
5022
|
-
|
|
5023
|
-
struct ExpressionState {
|
|
5024
|
-
ExpressionState(const Expression &expr, ExpressionExecutorState &root);
|
|
5025
|
-
virtual ~ExpressionState() {
|
|
5026
|
-
}
|
|
5027
|
-
|
|
5028
|
-
const Expression &expr;
|
|
5029
|
-
ExpressionExecutorState &root;
|
|
5030
|
-
vector<unique_ptr<ExpressionState>> child_states;
|
|
5031
|
-
vector<LogicalType> types;
|
|
5032
|
-
DataChunk intermediate_chunk;
|
|
5033
|
-
string name;
|
|
5034
|
-
CycleCounter profiler;
|
|
5035
|
-
|
|
5036
|
-
public:
|
|
5037
|
-
void AddChild(Expression *expr);
|
|
5038
|
-
void Finalize();
|
|
5039
|
-
};
|
|
5040
|
-
|
|
5041
|
-
struct ExpressionExecutorState {
|
|
5042
|
-
explicit ExpressionExecutorState(const string &name);
|
|
5043
|
-
unique_ptr<ExpressionState> root_state;
|
|
5044
|
-
ExpressionExecutor *executor;
|
|
5045
|
-
CycleCounter profiler;
|
|
5046
|
-
string name;
|
|
5047
|
-
};
|
|
5048
|
-
|
|
5049
|
-
} // namespace duckdb
|
|
5050
|
-
|
|
5051
5017
|
//===----------------------------------------------------------------------===//
|
|
5052
5018
|
// DuckDB
|
|
5053
5019
|
//
|
|
@@ -5711,6 +5677,53 @@ private:
|
|
|
5711
5677
|
|
|
5712
5678
|
} // namespace duckdb
|
|
5713
5679
|
|
|
5680
|
+
|
|
5681
|
+
namespace duckdb {
|
|
5682
|
+
class Expression;
|
|
5683
|
+
class ExpressionExecutor;
|
|
5684
|
+
struct ExpressionExecutorState;
|
|
5685
|
+
|
|
5686
|
+
struct ExpressionState {
|
|
5687
|
+
ExpressionState(const Expression &expr, ExpressionExecutorState &root);
|
|
5688
|
+
virtual ~ExpressionState() {
|
|
5689
|
+
}
|
|
5690
|
+
|
|
5691
|
+
const Expression &expr;
|
|
5692
|
+
ExpressionExecutorState &root;
|
|
5693
|
+
vector<unique_ptr<ExpressionState>> child_states;
|
|
5694
|
+
vector<LogicalType> types;
|
|
5695
|
+
DataChunk intermediate_chunk;
|
|
5696
|
+
string name;
|
|
5697
|
+
CycleCounter profiler;
|
|
5698
|
+
|
|
5699
|
+
public:
|
|
5700
|
+
void AddChild(Expression *expr);
|
|
5701
|
+
void Finalize();
|
|
5702
|
+
};
|
|
5703
|
+
|
|
5704
|
+
struct ExecuteFunctionState : public ExpressionState {
|
|
5705
|
+
ExecuteFunctionState(const Expression &expr, ExpressionExecutorState &root) : ExpressionState(expr, root) {
|
|
5706
|
+
}
|
|
5707
|
+
|
|
5708
|
+
unique_ptr<FunctionData> local_state;
|
|
5709
|
+
|
|
5710
|
+
public:
|
|
5711
|
+
static FunctionData *GetFunctionState(ExpressionState &state) {
|
|
5712
|
+
return ((ExecuteFunctionState &)state).local_state.get();
|
|
5713
|
+
}
|
|
5714
|
+
};
|
|
5715
|
+
|
|
5716
|
+
struct ExpressionExecutorState {
|
|
5717
|
+
explicit ExpressionExecutorState(const string &name);
|
|
5718
|
+
unique_ptr<ExpressionState> root_state;
|
|
5719
|
+
ExpressionExecutor *executor;
|
|
5720
|
+
CycleCounter profiler;
|
|
5721
|
+
string name;
|
|
5722
|
+
};
|
|
5723
|
+
|
|
5724
|
+
} // namespace duckdb
|
|
5725
|
+
|
|
5726
|
+
|
|
5714
5727
|
//===----------------------------------------------------------------------===//
|
|
5715
5728
|
// DuckDB
|
|
5716
5729
|
//
|
|
@@ -6296,6 +6309,7 @@ typedef std::function<void(DataChunk &, ExpressionState &, Vector &)> scalar_fun
|
|
|
6296
6309
|
//! Binds the scalar function and creates the function data
|
|
6297
6310
|
typedef unique_ptr<FunctionData> (*bind_scalar_function_t)(ClientContext &context, ScalarFunction &bound_function,
|
|
6298
6311
|
vector<unique_ptr<Expression>> &arguments);
|
|
6312
|
+
typedef unique_ptr<FunctionData> (*init_local_state_t)(const BoundFunctionExpression &expr, FunctionData *bind_data);
|
|
6299
6313
|
typedef unique_ptr<BaseStatistics> (*function_statistics_t)(ClientContext &context, BoundFunctionExpression &expr,
|
|
6300
6314
|
FunctionData *bind_data,
|
|
6301
6315
|
vector<unique_ptr<BaseStatistics>> &child_stats);
|
|
@@ -6307,23 +6321,27 @@ public:
|
|
|
6307
6321
|
ScalarFunction(string name, vector<LogicalType> arguments, LogicalType return_type, scalar_function_t function,
|
|
6308
6322
|
bool has_side_effects = false, bind_scalar_function_t bind = nullptr,
|
|
6309
6323
|
dependency_function_t dependency = nullptr, function_statistics_t statistics = nullptr,
|
|
6324
|
+
init_local_state_t init_local_state = nullptr,
|
|
6310
6325
|
LogicalType varargs = LogicalType(LogicalTypeId::INVALID))
|
|
6311
6326
|
: BaseScalarFunction(name, arguments, return_type, has_side_effects, varargs), function(function), bind(bind),
|
|
6312
|
-
dependency(dependency), statistics(statistics) {
|
|
6327
|
+
init_local_state(init_local_state), dependency(dependency), statistics(statistics) {
|
|
6313
6328
|
}
|
|
6314
6329
|
|
|
6315
6330
|
ScalarFunction(vector<LogicalType> arguments, LogicalType return_type, scalar_function_t function,
|
|
6316
6331
|
bool has_side_effects = false, bind_scalar_function_t bind = nullptr,
|
|
6317
6332
|
dependency_function_t dependency = nullptr, function_statistics_t statistics = nullptr,
|
|
6333
|
+
init_local_state_t init_local_state = nullptr,
|
|
6318
6334
|
LogicalType varargs = LogicalType(LogicalTypeId::INVALID))
|
|
6319
6335
|
: ScalarFunction(string(), arguments, return_type, function, has_side_effects, bind, dependency, statistics,
|
|
6320
|
-
varargs) {
|
|
6336
|
+
init_local_state, varargs) {
|
|
6321
6337
|
}
|
|
6322
6338
|
|
|
6323
6339
|
//! The main scalar function to execute
|
|
6324
6340
|
scalar_function_t function;
|
|
6325
6341
|
//! The bind function (if any)
|
|
6326
6342
|
bind_scalar_function_t bind;
|
|
6343
|
+
//! Init thread local state for the function (if any)
|
|
6344
|
+
init_local_state_t init_local_state;
|
|
6327
6345
|
// The dependency function (if any)
|
|
6328
6346
|
dependency_function_t dependency;
|
|
6329
6347
|
//! The statistics propagation function (if any)
|