duckdb 0.3.2-dev330.0 → 0.3.2-dev341.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 +101 -93
- package/src/duckdb.hpp +2 -2
package/package.json
CHANGED
package/src/duckdb.cpp
CHANGED
|
@@ -49529,7 +49529,9 @@ idx_t GroupedAggregateHashTable::Scan(idx_t &scan_position, DataChunk &result) {
|
|
|
49529
49529
|
}
|
|
49530
49530
|
|
|
49531
49531
|
void GroupedAggregateHashTable::Finalize() {
|
|
49532
|
-
|
|
49532
|
+
if (is_finalized) {
|
|
49533
|
+
return;
|
|
49534
|
+
}
|
|
49533
49535
|
|
|
49534
49536
|
// early release hashes, not needed for partition/scan
|
|
49535
49537
|
hashes_hdl.reset();
|
|
@@ -65967,18 +65969,11 @@ public:
|
|
|
65967
65969
|
vector<vector<unique_ptr<Expression>>> expressions;
|
|
65968
65970
|
|
|
65969
65971
|
public:
|
|
65970
|
-
unique_ptr<
|
|
65971
|
-
|
|
65972
|
-
|
|
65973
|
-
|
|
65974
|
-
public:
|
|
65975
|
-
// Sink interface
|
|
65976
|
-
SinkResultType Sink(ExecutionContext &context, GlobalSinkState &gstate, LocalSinkState &lstate,
|
|
65977
|
-
DataChunk &input) const override;
|
|
65978
|
-
|
|
65979
|
-
unique_ptr<GlobalSinkState> GetGlobalSinkState(ClientContext &context) const override;
|
|
65972
|
+
unique_ptr<OperatorState> GetOperatorState(ClientContext &context) const override;
|
|
65973
|
+
OperatorResultType Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
65974
|
+
OperatorState &state) const override;
|
|
65980
65975
|
|
|
65981
|
-
bool
|
|
65976
|
+
bool ParallelOperator() const override {
|
|
65982
65977
|
return true;
|
|
65983
65978
|
}
|
|
65984
65979
|
|
|
@@ -65994,7 +65989,7 @@ public:
|
|
|
65994
65989
|
|
|
65995
65990
|
namespace duckdb {
|
|
65996
65991
|
|
|
65997
|
-
class ExpressionScanState : public
|
|
65992
|
+
class ExpressionScanState : public OperatorState {
|
|
65998
65993
|
public:
|
|
65999
65994
|
explicit ExpressionScanState(const PhysicalExpressionScan &op) : expression_index(0) {
|
|
66000
65995
|
temp_chunk.Initialize(op.GetTypes());
|
|
@@ -66006,16 +66001,26 @@ public:
|
|
|
66006
66001
|
DataChunk temp_chunk;
|
|
66007
66002
|
};
|
|
66008
66003
|
|
|
66009
|
-
|
|
66010
|
-
|
|
66011
|
-
|
|
66012
|
-
}
|
|
66004
|
+
unique_ptr<OperatorState> PhysicalExpressionScan::GetOperatorState(ClientContext &context) const {
|
|
66005
|
+
return make_unique<ExpressionScanState>(*this);
|
|
66006
|
+
}
|
|
66013
66007
|
|
|
66014
|
-
|
|
66015
|
-
|
|
66008
|
+
OperatorResultType PhysicalExpressionScan::Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
66009
|
+
OperatorState &state_p) const {
|
|
66010
|
+
auto &state = (ExpressionScanState &)state_p;
|
|
66016
66011
|
|
|
66017
|
-
|
|
66018
|
-
|
|
66012
|
+
for (; chunk.size() + input.size() <= STANDARD_VECTOR_SIZE && state.expression_index < expressions.size();
|
|
66013
|
+
state.expression_index++) {
|
|
66014
|
+
state.temp_chunk.Reset();
|
|
66015
|
+
EvaluateExpression(state.expression_index, &input, state.temp_chunk);
|
|
66016
|
+
chunk.Append(state.temp_chunk);
|
|
66017
|
+
}
|
|
66018
|
+
if (state.expression_index < expressions.size()) {
|
|
66019
|
+
return OperatorResultType::HAVE_MORE_OUTPUT;
|
|
66020
|
+
} else {
|
|
66021
|
+
state.expression_index = 0;
|
|
66022
|
+
return OperatorResultType::NEED_MORE_INPUT;
|
|
66023
|
+
}
|
|
66019
66024
|
}
|
|
66020
66025
|
|
|
66021
66026
|
void PhysicalExpressionScan::EvaluateExpression(idx_t expression_idx, DataChunk *child_chunk, DataChunk &result) const {
|
|
@@ -66028,20 +66033,6 @@ void PhysicalExpressionScan::EvaluateExpression(idx_t expression_idx, DataChunk
|
|
|
66028
66033
|
}
|
|
66029
66034
|
}
|
|
66030
66035
|
|
|
66031
|
-
void PhysicalExpressionScan::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate_p,
|
|
66032
|
-
LocalSourceState &lstate) const {
|
|
66033
|
-
D_ASSERT(sink_state);
|
|
66034
|
-
auto &state = (ExpressionScanState &)gstate_p;
|
|
66035
|
-
auto &gstate = (ExpressionSinkState &)*sink_state;
|
|
66036
|
-
|
|
66037
|
-
for (; chunk.size() < STANDARD_VECTOR_SIZE && state.expression_index < expressions.size();
|
|
66038
|
-
state.expression_index++) {
|
|
66039
|
-
state.temp_chunk.Reset();
|
|
66040
|
-
EvaluateExpression(state.expression_index, &gstate.child_chunk, state.temp_chunk);
|
|
66041
|
-
chunk.Append(state.temp_chunk);
|
|
66042
|
-
}
|
|
66043
|
-
}
|
|
66044
|
-
|
|
66045
66036
|
bool PhysicalExpressionScan::IsFoldable() const {
|
|
66046
66037
|
for (auto &expr_list : expressions) {
|
|
66047
66038
|
for (auto &expr : expr_list) {
|
|
@@ -66053,24 +66044,6 @@ bool PhysicalExpressionScan::IsFoldable() const {
|
|
|
66053
66044
|
return true;
|
|
66054
66045
|
}
|
|
66055
66046
|
|
|
66056
|
-
SinkResultType PhysicalExpressionScan::Sink(ExecutionContext &context, GlobalSinkState &gstate_p,
|
|
66057
|
-
LocalSinkState &lstate, DataChunk &input) const {
|
|
66058
|
-
auto &gstate = (ExpressionSinkState &)gstate_p;
|
|
66059
|
-
|
|
66060
|
-
D_ASSERT(children.size() == 1);
|
|
66061
|
-
D_ASSERT(gstate.child_chunk.size() == 0);
|
|
66062
|
-
if (input.size() != 1) {
|
|
66063
|
-
throw InternalException("Expected expression scan child to have exactly one element");
|
|
66064
|
-
}
|
|
66065
|
-
gstate.child_chunk.Move(input);
|
|
66066
|
-
gstate.child_chunk.Verify();
|
|
66067
|
-
return SinkResultType::FINISHED;
|
|
66068
|
-
}
|
|
66069
|
-
|
|
66070
|
-
unique_ptr<GlobalSinkState> PhysicalExpressionScan::GetGlobalSinkState(ClientContext &context) const {
|
|
66071
|
-
return make_unique<ExpressionSinkState>();
|
|
66072
|
-
}
|
|
66073
|
-
|
|
66074
66047
|
} // namespace duckdb
|
|
66075
66048
|
|
|
66076
66049
|
|
|
@@ -84826,14 +84799,7 @@ static void LeastGreatestFunction(DataChunk &args, ExpressionState &state, Vecto
|
|
|
84826
84799
|
}
|
|
84827
84800
|
auto result_type = VectorType::CONSTANT_VECTOR;
|
|
84828
84801
|
for (idx_t col_idx = 0; col_idx < args.ColumnCount(); col_idx++) {
|
|
84829
|
-
if (args.data[col_idx].GetVectorType()
|
|
84830
|
-
if (ConstantVector::IsNull(args.data[col_idx])) {
|
|
84831
|
-
// constant NULL: result is constant NULL
|
|
84832
|
-
result.SetVectorType(VectorType::CONSTANT_VECTOR);
|
|
84833
|
-
ConstantVector::SetNull(result, true);
|
|
84834
|
-
return;
|
|
84835
|
-
}
|
|
84836
|
-
} else {
|
|
84802
|
+
if (args.data[col_idx].GetVectorType() != VectorType::CONSTANT_VECTOR) {
|
|
84837
84803
|
// non-constant input: result is not a constant vector
|
|
84838
84804
|
result_type = VectorType::FLAT_VECTOR;
|
|
84839
84805
|
}
|
|
@@ -84843,60 +84809,67 @@ static void LeastGreatestFunction(DataChunk &args, ExpressionState &state, Vecto
|
|
|
84843
84809
|
}
|
|
84844
84810
|
}
|
|
84845
84811
|
|
|
84846
|
-
// we start off performing a binary operation between the first two inputs, where we store the lowest (or highest)
|
|
84847
|
-
// directly in the result
|
|
84848
|
-
BinaryExecutor::ExecuteGeneric<T, T, T, BinarySingleArgumentOperatorWrapper, LeastOperator<OP>, bool>(
|
|
84849
|
-
args.data[0], args.data[1], result, args.size(), false);
|
|
84850
|
-
|
|
84851
|
-
// now we loop over the other columns and compare it to the stored result
|
|
84852
84812
|
auto result_data = FlatVector::GetData<T>(result);
|
|
84853
84813
|
auto &result_mask = FlatVector::Validity(result);
|
|
84854
|
-
|
|
84855
|
-
|
|
84856
|
-
|
|
84857
|
-
|
|
84858
|
-
|
|
84859
|
-
|
|
84860
|
-
|
|
84814
|
+
// copy over the first column
|
|
84815
|
+
bool result_has_value[STANDARD_VECTOR_SIZE];
|
|
84816
|
+
{
|
|
84817
|
+
VectorData vdata;
|
|
84818
|
+
args.data[0].Orrify(args.size(), vdata);
|
|
84819
|
+
auto input_data = (T *)vdata.data;
|
|
84820
|
+
for (idx_t i = 0; i < args.size(); i++) {
|
|
84821
|
+
auto vindex = vdata.sel->get_index(i);
|
|
84822
|
+
if (vdata.validity.RowIsValid(vindex)) {
|
|
84823
|
+
result_data[i] = input_data[vindex];
|
|
84824
|
+
result_has_value[i] = true;
|
|
84825
|
+
} else {
|
|
84826
|
+
result_has_value[i] = false;
|
|
84827
|
+
}
|
|
84861
84828
|
}
|
|
84862
84829
|
}
|
|
84863
|
-
|
|
84830
|
+
// now handle the remainder of the columns
|
|
84831
|
+
for (idx_t col_idx = 1; col_idx < args.ColumnCount(); col_idx++) {
|
|
84832
|
+
if (args.data[col_idx].GetVectorType() == VectorType::CONSTANT_VECTOR &&
|
|
84833
|
+
ConstantVector::IsNull(args.data[col_idx])) {
|
|
84834
|
+
// ignore null vector
|
|
84835
|
+
continue;
|
|
84836
|
+
}
|
|
84837
|
+
|
|
84864
84838
|
VectorData vdata;
|
|
84865
84839
|
args.data[col_idx].Orrify(args.size(), vdata);
|
|
84866
84840
|
|
|
84867
84841
|
auto input_data = (T *)vdata.data;
|
|
84868
84842
|
if (!vdata.validity.AllValid()) {
|
|
84869
84843
|
// potential new null entries: have to check the null mask
|
|
84870
|
-
idx_t
|
|
84871
|
-
|
|
84872
|
-
|
|
84873
|
-
auto vindex = vdata.sel->get_index(rindex);
|
|
84874
|
-
if (!vdata.validity.RowIsValid(vindex)) {
|
|
84875
|
-
// new null entry: set nullmask
|
|
84876
|
-
result_mask.SetInvalid(rindex);
|
|
84877
|
-
} else {
|
|
84844
|
+
for (idx_t i = 0; i < args.size(); i++) {
|
|
84845
|
+
auto vindex = vdata.sel->get_index(i);
|
|
84846
|
+
if (vdata.validity.RowIsValid(vindex)) {
|
|
84878
84847
|
// not a null entry: perform the operation and add to new set
|
|
84879
84848
|
auto ivalue = input_data[vindex];
|
|
84880
|
-
if (OP::template Operation<T>(ivalue, result_data[
|
|
84881
|
-
|
|
84849
|
+
if (!result_has_value[i] || OP::template Operation<T>(ivalue, result_data[i])) {
|
|
84850
|
+
result_has_value[i] = true;
|
|
84851
|
+
result_data[i] = ivalue;
|
|
84882
84852
|
}
|
|
84883
|
-
rsel.set_index(new_count++, rindex);
|
|
84884
84853
|
}
|
|
84885
84854
|
}
|
|
84886
|
-
rcount = new_count;
|
|
84887
84855
|
} else {
|
|
84888
84856
|
// no new null entries: only need to perform the operation
|
|
84889
|
-
for (idx_t i = 0; i <
|
|
84890
|
-
auto
|
|
84891
|
-
auto vindex = vdata.sel->get_index(rindex);
|
|
84857
|
+
for (idx_t i = 0; i < args.size(); i++) {
|
|
84858
|
+
auto vindex = vdata.sel->get_index(i);
|
|
84892
84859
|
|
|
84893
84860
|
auto ivalue = input_data[vindex];
|
|
84894
|
-
if (OP::template Operation<T>(ivalue, result_data[
|
|
84895
|
-
|
|
84861
|
+
if (!result_has_value[i] || OP::template Operation<T>(ivalue, result_data[i])) {
|
|
84862
|
+
result_has_value[i] = true;
|
|
84863
|
+
result_data[i] = ivalue;
|
|
84896
84864
|
}
|
|
84897
84865
|
}
|
|
84898
84866
|
}
|
|
84899
84867
|
}
|
|
84868
|
+
for (idx_t i = 0; i < args.size(); i++) {
|
|
84869
|
+
if (!result_has_value[i]) {
|
|
84870
|
+
result_mask.SetInvalid(i);
|
|
84871
|
+
}
|
|
84872
|
+
}
|
|
84900
84873
|
result.SetVectorType(result_type);
|
|
84901
84874
|
}
|
|
84902
84875
|
|
|
@@ -117164,6 +117137,8 @@ struct CSEReplacementState {
|
|
|
117164
117137
|
column_binding_map_t<idx_t> column_map;
|
|
117165
117138
|
//! The set of expressions of the resulting projection
|
|
117166
117139
|
vector<unique_ptr<Expression>> expressions;
|
|
117140
|
+
//! Cached expressions that are kept around so the expression_map always contains valid expressions
|
|
117141
|
+
vector<unique_ptr<Expression>> cached_expressions;
|
|
117167
117142
|
};
|
|
117168
117143
|
|
|
117169
117144
|
void CommonSubExpressionOptimizer::VisitOperator(LogicalOperator &op) {
|
|
@@ -117239,6 +117214,8 @@ void CommonSubExpressionOptimizer::PerformCSEReplacement(unique_ptr<Expression>
|
|
|
117239
117214
|
// has not been pushed yet: push it
|
|
117240
117215
|
node.column_index = state.expressions.size();
|
|
117241
117216
|
state.expressions.push_back(move(*expr_ptr));
|
|
117217
|
+
} else {
|
|
117218
|
+
state.cached_expressions.push_back(move(*expr_ptr));
|
|
117242
117219
|
}
|
|
117243
117220
|
// replace the original expression with a bound column ref
|
|
117244
117221
|
*expr_ptr = make_unique<BoundColumnRefExpression>(alias, type,
|
|
@@ -126069,7 +126046,6 @@ void Executor::BuildPipelines(PhysicalOperator *op, Pipeline *current) {
|
|
|
126069
126046
|
case PhysicalOperatorType::TOP_N:
|
|
126070
126047
|
case PhysicalOperatorType::COPY_TO_FILE:
|
|
126071
126048
|
case PhysicalOperatorType::LIMIT:
|
|
126072
|
-
case PhysicalOperatorType::EXPRESSION_SCAN:
|
|
126073
126049
|
case PhysicalOperatorType::EXPLAIN_ANALYZE:
|
|
126074
126050
|
D_ASSERT(op->children.size() == 1);
|
|
126075
126051
|
// single operator:
|
|
@@ -154822,6 +154798,15 @@ void ExpressionIterator::EnumerateTableRefChildren(BoundTableRef &ref,
|
|
|
154822
154798
|
EnumerateTableRefChildren(*bound_crossproduct.right, callback);
|
|
154823
154799
|
break;
|
|
154824
154800
|
}
|
|
154801
|
+
case TableReferenceType::EXPRESSION_LIST: {
|
|
154802
|
+
auto &bound_expr_list = (BoundExpressionListRef &)ref;
|
|
154803
|
+
for (auto &expr_list : bound_expr_list.values) {
|
|
154804
|
+
for (auto &expr : expr_list) {
|
|
154805
|
+
EnumerateExpression(expr, callback);
|
|
154806
|
+
}
|
|
154807
|
+
}
|
|
154808
|
+
break;
|
|
154809
|
+
}
|
|
154825
154810
|
case TableReferenceType::JOIN: {
|
|
154826
154811
|
auto &bound_join = (BoundJoinRef &)ref;
|
|
154827
154812
|
EnumerateExpression(bound_join.condition, callback);
|
|
@@ -156577,6 +156562,29 @@ unique_ptr<LogicalOperator> FlattenDependentJoins::PushDownDependentJoinInternal
|
|
|
156577
156562
|
case LogicalOperatorType::LOGICAL_DISTINCT:
|
|
156578
156563
|
plan->children[0] = PushDownDependentJoin(move(plan->children[0]));
|
|
156579
156564
|
return plan;
|
|
156565
|
+
case LogicalOperatorType::LOGICAL_EXPRESSION_GET: {
|
|
156566
|
+
// expression get
|
|
156567
|
+
// first we flatten the dependent join in the child
|
|
156568
|
+
plan->children[0] = PushDownDependentJoinInternal(move(plan->children[0]));
|
|
156569
|
+
// then we replace any correlated expressions with the corresponding entry in the correlated_map
|
|
156570
|
+
RewriteCorrelatedExpressions rewriter(base_binding, correlated_map);
|
|
156571
|
+
rewriter.VisitOperator(*plan);
|
|
156572
|
+
// now we add all the correlated columns to each of the expressions of the expression scan
|
|
156573
|
+
auto expr_get = (LogicalExpressionGet *)plan.get();
|
|
156574
|
+
for (idx_t i = 0; i < correlated_columns.size(); i++) {
|
|
156575
|
+
for (auto &expr_list : expr_get->expressions) {
|
|
156576
|
+
auto colref = make_unique<BoundColumnRefExpression>(
|
|
156577
|
+
correlated_columns[i].type, ColumnBinding(base_binding.table_index, base_binding.column_index + i));
|
|
156578
|
+
expr_list.push_back(move(colref));
|
|
156579
|
+
}
|
|
156580
|
+
expr_get->expr_types.push_back(correlated_columns[i].type);
|
|
156581
|
+
}
|
|
156582
|
+
|
|
156583
|
+
base_binding.table_index = expr_get->table_index;
|
|
156584
|
+
this->delim_offset = base_binding.column_index = expr_get->expr_types.size() - correlated_columns.size();
|
|
156585
|
+
this->data_offset = 0;
|
|
156586
|
+
return plan;
|
|
156587
|
+
}
|
|
156580
156588
|
case LogicalOperatorType::LOGICAL_ORDER_BY:
|
|
156581
156589
|
throw ParserException("ORDER BY not supported in correlated subquery");
|
|
156582
156590
|
default:
|
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.3.2-
|
|
13
|
+
#define DUCKDB_SOURCE_ID "32060df04"
|
|
14
|
+
#define DUCKDB_VERSION "0.3.2-dev341"
|
|
15
15
|
//===----------------------------------------------------------------------===//
|
|
16
16
|
// DuckDB
|
|
17
17
|
//
|