duckdb 0.4.1-dev454.0 → 0.4.1-dev456.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 +216 -214
- package/src/duckdb.hpp +3 -3
- package/src/parquet-amalgamation.cpp +31199 -31199
package/package.json
CHANGED
package/src/duckdb.cpp
CHANGED
|
@@ -7600,8 +7600,8 @@ string PhysicalOperatorToString(PhysicalOperatorType type) {
|
|
|
7600
7600
|
return "STREAMING_WINDOW";
|
|
7601
7601
|
case PhysicalOperatorType::UNNEST:
|
|
7602
7602
|
return "UNNEST";
|
|
7603
|
-
case PhysicalOperatorType::
|
|
7604
|
-
return "
|
|
7603
|
+
case PhysicalOperatorType::UNGROUPED_AGGREGATE:
|
|
7604
|
+
return "UNGROUPED_AGGREGATE";
|
|
7605
7605
|
case PhysicalOperatorType::HASH_GROUP_BY:
|
|
7606
7606
|
return "HASH_GROUP_BY";
|
|
7607
7607
|
case PhysicalOperatorType::PERFECT_HASH_GROUP_BY:
|
|
@@ -58596,7 +58596,197 @@ string PhysicalPerfectHashAggregate::ParamsToString() const {
|
|
|
58596
58596
|
//===----------------------------------------------------------------------===//
|
|
58597
58597
|
// DuckDB
|
|
58598
58598
|
//
|
|
58599
|
-
// duckdb/execution/operator/aggregate/
|
|
58599
|
+
// duckdb/execution/operator/aggregate/physical_window.hpp
|
|
58600
|
+
//
|
|
58601
|
+
//
|
|
58602
|
+
//===----------------------------------------------------------------------===//
|
|
58603
|
+
|
|
58604
|
+
|
|
58605
|
+
|
|
58606
|
+
|
|
58607
|
+
|
|
58608
|
+
|
|
58609
|
+
namespace duckdb {
|
|
58610
|
+
|
|
58611
|
+
//! PhysicalStreamingWindow implements streaming window functions (i.e. with an empty OVER clause)
|
|
58612
|
+
class PhysicalStreamingWindow : public PhysicalOperator {
|
|
58613
|
+
public:
|
|
58614
|
+
PhysicalStreamingWindow(vector<LogicalType> types, vector<unique_ptr<Expression>> select_list,
|
|
58615
|
+
idx_t estimated_cardinality,
|
|
58616
|
+
PhysicalOperatorType type = PhysicalOperatorType::STREAMING_WINDOW);
|
|
58617
|
+
|
|
58618
|
+
//! The projection list of the WINDOW statement
|
|
58619
|
+
vector<unique_ptr<Expression>> select_list;
|
|
58620
|
+
|
|
58621
|
+
public:
|
|
58622
|
+
unique_ptr<GlobalOperatorState> GetGlobalOperatorState(ClientContext &context) const override;
|
|
58623
|
+
unique_ptr<OperatorState> GetOperatorState(ExecutionContext &context) const override;
|
|
58624
|
+
|
|
58625
|
+
OperatorResultType Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
58626
|
+
GlobalOperatorState &gstate, OperatorState &state) const override;
|
|
58627
|
+
|
|
58628
|
+
string ParamsToString() const override;
|
|
58629
|
+
};
|
|
58630
|
+
|
|
58631
|
+
} // namespace duckdb
|
|
58632
|
+
|
|
58633
|
+
|
|
58634
|
+
|
|
58635
|
+
//===----------------------------------------------------------------------===//
|
|
58636
|
+
// DuckDB
|
|
58637
|
+
//
|
|
58638
|
+
// duckdb/parallel/thread_context.hpp
|
|
58639
|
+
//
|
|
58640
|
+
//
|
|
58641
|
+
//===----------------------------------------------------------------------===//
|
|
58642
|
+
|
|
58643
|
+
|
|
58644
|
+
|
|
58645
|
+
|
|
58646
|
+
|
|
58647
|
+
namespace duckdb {
|
|
58648
|
+
class ClientContext;
|
|
58649
|
+
|
|
58650
|
+
//! The ThreadContext holds thread-local info for parallel usage
|
|
58651
|
+
class ThreadContext {
|
|
58652
|
+
public:
|
|
58653
|
+
explicit ThreadContext(ClientContext &context);
|
|
58654
|
+
|
|
58655
|
+
//! The operator profiler for the individual thread context
|
|
58656
|
+
OperatorProfiler profiler;
|
|
58657
|
+
};
|
|
58658
|
+
|
|
58659
|
+
} // namespace duckdb
|
|
58660
|
+
|
|
58661
|
+
|
|
58662
|
+
|
|
58663
|
+
|
|
58664
|
+
namespace duckdb {
|
|
58665
|
+
|
|
58666
|
+
PhysicalStreamingWindow::PhysicalStreamingWindow(vector<LogicalType> types, vector<unique_ptr<Expression>> select_list,
|
|
58667
|
+
idx_t estimated_cardinality, PhysicalOperatorType type)
|
|
58668
|
+
: PhysicalOperator(type, move(types), estimated_cardinality), select_list(move(select_list)) {
|
|
58669
|
+
}
|
|
58670
|
+
|
|
58671
|
+
class StreamingWindowGlobalState : public GlobalOperatorState {
|
|
58672
|
+
public:
|
|
58673
|
+
StreamingWindowGlobalState() : row_number(1) {
|
|
58674
|
+
}
|
|
58675
|
+
|
|
58676
|
+
//! The next row number.
|
|
58677
|
+
std::atomic<int64_t> row_number;
|
|
58678
|
+
};
|
|
58679
|
+
|
|
58680
|
+
class StreamingWindowState : public OperatorState {
|
|
58681
|
+
public:
|
|
58682
|
+
StreamingWindowState() : initialized(false) {
|
|
58683
|
+
}
|
|
58684
|
+
|
|
58685
|
+
void Initialize(Allocator &allocator, DataChunk &input, const vector<unique_ptr<Expression>> &expressions) {
|
|
58686
|
+
for (idx_t expr_idx = 0; expr_idx < expressions.size(); expr_idx++) {
|
|
58687
|
+
auto &expr = *expressions[expr_idx];
|
|
58688
|
+
switch (expr.GetExpressionType()) {
|
|
58689
|
+
case ExpressionType::WINDOW_FIRST_VALUE: {
|
|
58690
|
+
auto &wexpr = (BoundWindowExpression &)expr;
|
|
58691
|
+
|
|
58692
|
+
// Just execute the expression once
|
|
58693
|
+
ExpressionExecutor executor(allocator);
|
|
58694
|
+
executor.AddExpression(*wexpr.children[0]);
|
|
58695
|
+
DataChunk result;
|
|
58696
|
+
result.Initialize(allocator, {wexpr.children[0]->return_type});
|
|
58697
|
+
executor.Execute(input, result);
|
|
58698
|
+
|
|
58699
|
+
const_vectors.push_back(make_unique<Vector>(result.GetValue(0, 0)));
|
|
58700
|
+
break;
|
|
58701
|
+
}
|
|
58702
|
+
case ExpressionType::WINDOW_PERCENT_RANK: {
|
|
58703
|
+
const_vectors.push_back(make_unique<Vector>(Value((double)0)));
|
|
58704
|
+
break;
|
|
58705
|
+
}
|
|
58706
|
+
case ExpressionType::WINDOW_RANK:
|
|
58707
|
+
case ExpressionType::WINDOW_RANK_DENSE: {
|
|
58708
|
+
const_vectors.push_back(make_unique<Vector>(Value((int64_t)1)));
|
|
58709
|
+
break;
|
|
58710
|
+
}
|
|
58711
|
+
default:
|
|
58712
|
+
const_vectors.push_back(nullptr);
|
|
58713
|
+
}
|
|
58714
|
+
}
|
|
58715
|
+
initialized = true;
|
|
58716
|
+
}
|
|
58717
|
+
|
|
58718
|
+
public:
|
|
58719
|
+
bool initialized;
|
|
58720
|
+
vector<unique_ptr<Vector>> const_vectors;
|
|
58721
|
+
};
|
|
58722
|
+
|
|
58723
|
+
unique_ptr<GlobalOperatorState> PhysicalStreamingWindow::GetGlobalOperatorState(ClientContext &context) const {
|
|
58724
|
+
return make_unique<StreamingWindowGlobalState>();
|
|
58725
|
+
}
|
|
58726
|
+
|
|
58727
|
+
unique_ptr<OperatorState> PhysicalStreamingWindow::GetOperatorState(ExecutionContext &context) const {
|
|
58728
|
+
return make_unique<StreamingWindowState>();
|
|
58729
|
+
}
|
|
58730
|
+
|
|
58731
|
+
OperatorResultType PhysicalStreamingWindow::Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
58732
|
+
GlobalOperatorState &gstate_p, OperatorState &state_p) const {
|
|
58733
|
+
auto &gstate = (StreamingWindowGlobalState &)gstate_p;
|
|
58734
|
+
auto &state = (StreamingWindowState &)state_p;
|
|
58735
|
+
if (!state.initialized) {
|
|
58736
|
+
auto &allocator = Allocator::Get(context.client);
|
|
58737
|
+
state.Initialize(allocator, input, select_list);
|
|
58738
|
+
}
|
|
58739
|
+
// Put payload columns in place
|
|
58740
|
+
for (idx_t col_idx = 0; col_idx < input.data.size(); col_idx++) {
|
|
58741
|
+
chunk.data[col_idx].Reference(input.data[col_idx]);
|
|
58742
|
+
}
|
|
58743
|
+
// Compute window function
|
|
58744
|
+
const idx_t count = input.size();
|
|
58745
|
+
for (idx_t expr_idx = 0; expr_idx < select_list.size(); expr_idx++) {
|
|
58746
|
+
idx_t col_idx = input.data.size() + expr_idx;
|
|
58747
|
+
auto &expr = *select_list[expr_idx];
|
|
58748
|
+
switch (expr.GetExpressionType()) {
|
|
58749
|
+
case ExpressionType::WINDOW_FIRST_VALUE:
|
|
58750
|
+
case ExpressionType::WINDOW_PERCENT_RANK:
|
|
58751
|
+
case ExpressionType::WINDOW_RANK:
|
|
58752
|
+
case ExpressionType::WINDOW_RANK_DENSE: {
|
|
58753
|
+
// Reference constant vector
|
|
58754
|
+
chunk.data[col_idx].Reference(*state.const_vectors[expr_idx]);
|
|
58755
|
+
break;
|
|
58756
|
+
}
|
|
58757
|
+
case ExpressionType::WINDOW_ROW_NUMBER: {
|
|
58758
|
+
// Set row numbers
|
|
58759
|
+
auto rdata = FlatVector::GetData<int64_t>(chunk.data[col_idx]);
|
|
58760
|
+
for (idx_t i = 0; i < count; i++) {
|
|
58761
|
+
rdata[i] = gstate.row_number + i;
|
|
58762
|
+
}
|
|
58763
|
+
break;
|
|
58764
|
+
}
|
|
58765
|
+
default:
|
|
58766
|
+
throw NotImplementedException("%s for StreamingWindow", ExpressionTypeToString(expr.GetExpressionType()));
|
|
58767
|
+
}
|
|
58768
|
+
}
|
|
58769
|
+
gstate.row_number += count;
|
|
58770
|
+
chunk.SetCardinality(count);
|
|
58771
|
+
return OperatorResultType::NEED_MORE_INPUT;
|
|
58772
|
+
}
|
|
58773
|
+
|
|
58774
|
+
string PhysicalStreamingWindow::ParamsToString() const {
|
|
58775
|
+
string result;
|
|
58776
|
+
for (idx_t i = 0; i < select_list.size(); i++) {
|
|
58777
|
+
if (i > 0) {
|
|
58778
|
+
result += "\n";
|
|
58779
|
+
}
|
|
58780
|
+
result += select_list[i]->GetName();
|
|
58781
|
+
}
|
|
58782
|
+
return result;
|
|
58783
|
+
}
|
|
58784
|
+
|
|
58785
|
+
} // namespace duckdb
|
|
58786
|
+
//===----------------------------------------------------------------------===//
|
|
58787
|
+
// DuckDB
|
|
58788
|
+
//
|
|
58789
|
+
// duckdb/execution/operator/aggregate/physical_ungrouped_aggregate.hpp
|
|
58600
58790
|
//
|
|
58601
58791
|
//
|
|
58602
58792
|
//===----------------------------------------------------------------------===//
|
|
@@ -58608,12 +58798,12 @@ string PhysicalPerfectHashAggregate::ParamsToString() const {
|
|
|
58608
58798
|
|
|
58609
58799
|
namespace duckdb {
|
|
58610
58800
|
|
|
58611
|
-
//!
|
|
58801
|
+
//! PhysicalUngroupedAggregate is an aggregate operator that can only perform aggregates (1) without any groups, (2)
|
|
58612
58802
|
//! without any DISTINCT aggregates, and (3) when all aggregates are combineable
|
|
58613
|
-
class
|
|
58803
|
+
class PhysicalUngroupedAggregate : public PhysicalOperator {
|
|
58614
58804
|
public:
|
|
58615
|
-
|
|
58616
|
-
|
|
58805
|
+
PhysicalUngroupedAggregate(vector<LogicalType> types, vector<unique_ptr<Expression>> expressions,
|
|
58806
|
+
idx_t estimated_cardinality);
|
|
58617
58807
|
|
|
58618
58808
|
//! The aggregates that have to be computed
|
|
58619
58809
|
vector<unique_ptr<Expression>> aggregates;
|
|
@@ -58654,39 +58844,15 @@ public:
|
|
|
58654
58844
|
|
|
58655
58845
|
|
|
58656
58846
|
|
|
58657
|
-
//===----------------------------------------------------------------------===//
|
|
58658
|
-
// DuckDB
|
|
58659
|
-
//
|
|
58660
|
-
// duckdb/parallel/thread_context.hpp
|
|
58661
|
-
//
|
|
58662
|
-
//
|
|
58663
|
-
//===----------------------------------------------------------------------===//
|
|
58664
|
-
|
|
58665
|
-
|
|
58666
58847
|
|
|
58667
58848
|
|
|
58668
58849
|
|
|
58669
58850
|
namespace duckdb {
|
|
58670
|
-
class ClientContext;
|
|
58671
|
-
|
|
58672
|
-
//! The ThreadContext holds thread-local info for parallel usage
|
|
58673
|
-
class ThreadContext {
|
|
58674
|
-
public:
|
|
58675
|
-
explicit ThreadContext(ClientContext &context);
|
|
58676
58851
|
|
|
58677
|
-
|
|
58678
|
-
|
|
58679
|
-
|
|
58680
|
-
|
|
58681
|
-
} // namespace duckdb
|
|
58682
|
-
|
|
58683
|
-
|
|
58684
|
-
|
|
58685
|
-
namespace duckdb {
|
|
58686
|
-
|
|
58687
|
-
PhysicalSimpleAggregate::PhysicalSimpleAggregate(vector<LogicalType> types, vector<unique_ptr<Expression>> expressions,
|
|
58688
|
-
idx_t estimated_cardinality)
|
|
58689
|
-
: PhysicalOperator(PhysicalOperatorType::SIMPLE_AGGREGATE, move(types), estimated_cardinality),
|
|
58852
|
+
PhysicalUngroupedAggregate::PhysicalUngroupedAggregate(vector<LogicalType> types,
|
|
58853
|
+
vector<unique_ptr<Expression>> expressions,
|
|
58854
|
+
idx_t estimated_cardinality)
|
|
58855
|
+
: PhysicalOperator(PhysicalOperatorType::UNGROUPED_AGGREGATE, move(types), estimated_cardinality),
|
|
58690
58856
|
aggregates(move(expressions)) {
|
|
58691
58857
|
}
|
|
58692
58858
|
|
|
@@ -58785,16 +58951,16 @@ public:
|
|
|
58785
58951
|
AggregateFilterDataSet filter_set;
|
|
58786
58952
|
};
|
|
58787
58953
|
|
|
58788
|
-
unique_ptr<GlobalSinkState>
|
|
58954
|
+
unique_ptr<GlobalSinkState> PhysicalUngroupedAggregate::GetGlobalSinkState(ClientContext &context) const {
|
|
58789
58955
|
return make_unique<SimpleAggregateGlobalState>(aggregates);
|
|
58790
58956
|
}
|
|
58791
58957
|
|
|
58792
|
-
unique_ptr<LocalSinkState>
|
|
58958
|
+
unique_ptr<LocalSinkState> PhysicalUngroupedAggregate::GetLocalSinkState(ExecutionContext &context) const {
|
|
58793
58959
|
return make_unique<SimpleAggregateLocalState>(Allocator::Get(context.client), aggregates, children[0]->GetTypes());
|
|
58794
58960
|
}
|
|
58795
58961
|
|
|
58796
|
-
SinkResultType
|
|
58797
|
-
|
|
58962
|
+
SinkResultType PhysicalUngroupedAggregate::Sink(ExecutionContext &context, GlobalSinkState &state,
|
|
58963
|
+
LocalSinkState &lstate, DataChunk &input) const {
|
|
58798
58964
|
auto &sink = (SimpleAggregateLocalState &)lstate;
|
|
58799
58965
|
// perform the aggregation inside the local state
|
|
58800
58966
|
idx_t payload_idx = 0, payload_expr_idx = 0;
|
|
@@ -58840,7 +59006,8 @@ SinkResultType PhysicalSimpleAggregate::Sink(ExecutionContext &context, GlobalSi
|
|
|
58840
59006
|
//===--------------------------------------------------------------------===//
|
|
58841
59007
|
// Finalize
|
|
58842
59008
|
//===--------------------------------------------------------------------===//
|
|
58843
|
-
void
|
|
59009
|
+
void PhysicalUngroupedAggregate::Combine(ExecutionContext &context, GlobalSinkState &state,
|
|
59010
|
+
LocalSinkState &lstate) const {
|
|
58844
59011
|
auto &gstate = (SimpleAggregateGlobalState &)state;
|
|
58845
59012
|
auto &source = (SimpleAggregateLocalState &)lstate;
|
|
58846
59013
|
D_ASSERT(!gstate.finished);
|
|
@@ -58866,8 +59033,8 @@ void PhysicalSimpleAggregate::Combine(ExecutionContext &context, GlobalSinkState
|
|
|
58866
59033
|
client_profiler.Flush(context.thread.profiler);
|
|
58867
59034
|
}
|
|
58868
59035
|
|
|
58869
|
-
SinkFinalizeType
|
|
58870
|
-
|
|
59036
|
+
SinkFinalizeType PhysicalUngroupedAggregate::Finalize(Pipeline &pipeline, Event &event, ClientContext &context,
|
|
59037
|
+
GlobalSinkState &gstate_p) const {
|
|
58871
59038
|
auto &gstate = (SimpleAggregateGlobalState &)gstate_p;
|
|
58872
59039
|
|
|
58873
59040
|
D_ASSERT(!gstate.finished);
|
|
@@ -58886,7 +59053,7 @@ public:
|
|
|
58886
59053
|
bool finished;
|
|
58887
59054
|
};
|
|
58888
59055
|
|
|
58889
|
-
unique_ptr<GlobalSourceState>
|
|
59056
|
+
unique_ptr<GlobalSourceState> PhysicalUngroupedAggregate::GetGlobalSourceState(ClientContext &context) const {
|
|
58890
59057
|
return make_unique<SimpleAggregateState>();
|
|
58891
59058
|
}
|
|
58892
59059
|
|
|
@@ -58904,8 +59071,8 @@ void VerifyNullHandling(DataChunk &chunk, AggregateState &state, const vector<un
|
|
|
58904
59071
|
#endif
|
|
58905
59072
|
}
|
|
58906
59073
|
|
|
58907
|
-
void
|
|
58908
|
-
|
|
59074
|
+
void PhysicalUngroupedAggregate::GetData(ExecutionContext &context, DataChunk &chunk, GlobalSourceState &gstate_p,
|
|
59075
|
+
LocalSourceState &lstate) const {
|
|
58909
59076
|
auto &gstate = (SimpleAggregateGlobalState &)*sink_state;
|
|
58910
59077
|
auto &state = (SimpleAggregateState &)gstate_p;
|
|
58911
59078
|
D_ASSERT(gstate.finished);
|
|
@@ -58926,7 +59093,7 @@ void PhysicalSimpleAggregate::GetData(ExecutionContext &context, DataChunk &chun
|
|
|
58926
59093
|
state.finished = true;
|
|
58927
59094
|
}
|
|
58928
59095
|
|
|
58929
|
-
string
|
|
59096
|
+
string PhysicalUngroupedAggregate::ParamsToString() const {
|
|
58930
59097
|
string result;
|
|
58931
59098
|
for (idx_t i = 0; i < aggregates.size(); i++) {
|
|
58932
59099
|
auto &aggregate = (BoundAggregateExpression &)*aggregates[i];
|
|
@@ -58955,171 +59122,6 @@ string PhysicalSimpleAggregate::ParamsToString() const {
|
|
|
58955
59122
|
|
|
58956
59123
|
|
|
58957
59124
|
|
|
58958
|
-
namespace duckdb {
|
|
58959
|
-
|
|
58960
|
-
//! PhysicalStreamingWindow implements streaming window functions (i.e. with an empty OVER clause)
|
|
58961
|
-
class PhysicalStreamingWindow : public PhysicalOperator {
|
|
58962
|
-
public:
|
|
58963
|
-
PhysicalStreamingWindow(vector<LogicalType> types, vector<unique_ptr<Expression>> select_list,
|
|
58964
|
-
idx_t estimated_cardinality,
|
|
58965
|
-
PhysicalOperatorType type = PhysicalOperatorType::STREAMING_WINDOW);
|
|
58966
|
-
|
|
58967
|
-
//! The projection list of the WINDOW statement
|
|
58968
|
-
vector<unique_ptr<Expression>> select_list;
|
|
58969
|
-
|
|
58970
|
-
public:
|
|
58971
|
-
unique_ptr<GlobalOperatorState> GetGlobalOperatorState(ClientContext &context) const override;
|
|
58972
|
-
unique_ptr<OperatorState> GetOperatorState(ExecutionContext &context) const override;
|
|
58973
|
-
|
|
58974
|
-
OperatorResultType Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
58975
|
-
GlobalOperatorState &gstate, OperatorState &state) const override;
|
|
58976
|
-
|
|
58977
|
-
string ParamsToString() const override;
|
|
58978
|
-
};
|
|
58979
|
-
|
|
58980
|
-
} // namespace duckdb
|
|
58981
|
-
|
|
58982
|
-
|
|
58983
|
-
|
|
58984
|
-
|
|
58985
|
-
|
|
58986
|
-
|
|
58987
|
-
|
|
58988
|
-
namespace duckdb {
|
|
58989
|
-
|
|
58990
|
-
PhysicalStreamingWindow::PhysicalStreamingWindow(vector<LogicalType> types, vector<unique_ptr<Expression>> select_list,
|
|
58991
|
-
idx_t estimated_cardinality, PhysicalOperatorType type)
|
|
58992
|
-
: PhysicalOperator(type, move(types), estimated_cardinality), select_list(move(select_list)) {
|
|
58993
|
-
}
|
|
58994
|
-
|
|
58995
|
-
class StreamingWindowGlobalState : public GlobalOperatorState {
|
|
58996
|
-
public:
|
|
58997
|
-
StreamingWindowGlobalState() : row_number(1) {
|
|
58998
|
-
}
|
|
58999
|
-
|
|
59000
|
-
//! The next row number.
|
|
59001
|
-
std::atomic<int64_t> row_number;
|
|
59002
|
-
};
|
|
59003
|
-
|
|
59004
|
-
class StreamingWindowState : public OperatorState {
|
|
59005
|
-
public:
|
|
59006
|
-
StreamingWindowState() : initialized(false) {
|
|
59007
|
-
}
|
|
59008
|
-
|
|
59009
|
-
void Initialize(Allocator &allocator, DataChunk &input, const vector<unique_ptr<Expression>> &expressions) {
|
|
59010
|
-
for (idx_t expr_idx = 0; expr_idx < expressions.size(); expr_idx++) {
|
|
59011
|
-
auto &expr = *expressions[expr_idx];
|
|
59012
|
-
switch (expr.GetExpressionType()) {
|
|
59013
|
-
case ExpressionType::WINDOW_FIRST_VALUE: {
|
|
59014
|
-
auto &wexpr = (BoundWindowExpression &)expr;
|
|
59015
|
-
|
|
59016
|
-
// Just execute the expression once
|
|
59017
|
-
ExpressionExecutor executor(allocator);
|
|
59018
|
-
executor.AddExpression(*wexpr.children[0]);
|
|
59019
|
-
DataChunk result;
|
|
59020
|
-
result.Initialize(allocator, {wexpr.children[0]->return_type});
|
|
59021
|
-
executor.Execute(input, result);
|
|
59022
|
-
|
|
59023
|
-
const_vectors.push_back(make_unique<Vector>(result.GetValue(0, 0)));
|
|
59024
|
-
break;
|
|
59025
|
-
}
|
|
59026
|
-
case ExpressionType::WINDOW_PERCENT_RANK: {
|
|
59027
|
-
const_vectors.push_back(make_unique<Vector>(Value((double)0)));
|
|
59028
|
-
break;
|
|
59029
|
-
}
|
|
59030
|
-
case ExpressionType::WINDOW_RANK:
|
|
59031
|
-
case ExpressionType::WINDOW_RANK_DENSE: {
|
|
59032
|
-
const_vectors.push_back(make_unique<Vector>(Value((int64_t)1)));
|
|
59033
|
-
break;
|
|
59034
|
-
}
|
|
59035
|
-
default:
|
|
59036
|
-
const_vectors.push_back(nullptr);
|
|
59037
|
-
}
|
|
59038
|
-
}
|
|
59039
|
-
initialized = true;
|
|
59040
|
-
}
|
|
59041
|
-
|
|
59042
|
-
public:
|
|
59043
|
-
bool initialized;
|
|
59044
|
-
vector<unique_ptr<Vector>> const_vectors;
|
|
59045
|
-
};
|
|
59046
|
-
|
|
59047
|
-
unique_ptr<GlobalOperatorState> PhysicalStreamingWindow::GetGlobalOperatorState(ClientContext &context) const {
|
|
59048
|
-
return make_unique<StreamingWindowGlobalState>();
|
|
59049
|
-
}
|
|
59050
|
-
|
|
59051
|
-
unique_ptr<OperatorState> PhysicalStreamingWindow::GetOperatorState(ExecutionContext &context) const {
|
|
59052
|
-
return make_unique<StreamingWindowState>();
|
|
59053
|
-
}
|
|
59054
|
-
|
|
59055
|
-
OperatorResultType PhysicalStreamingWindow::Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
|
|
59056
|
-
GlobalOperatorState &gstate_p, OperatorState &state_p) const {
|
|
59057
|
-
auto &gstate = (StreamingWindowGlobalState &)gstate_p;
|
|
59058
|
-
auto &state = (StreamingWindowState &)state_p;
|
|
59059
|
-
if (!state.initialized) {
|
|
59060
|
-
auto &allocator = Allocator::Get(context.client);
|
|
59061
|
-
state.Initialize(allocator, input, select_list);
|
|
59062
|
-
}
|
|
59063
|
-
// Put payload columns in place
|
|
59064
|
-
for (idx_t col_idx = 0; col_idx < input.data.size(); col_idx++) {
|
|
59065
|
-
chunk.data[col_idx].Reference(input.data[col_idx]);
|
|
59066
|
-
}
|
|
59067
|
-
// Compute window function
|
|
59068
|
-
const idx_t count = input.size();
|
|
59069
|
-
for (idx_t expr_idx = 0; expr_idx < select_list.size(); expr_idx++) {
|
|
59070
|
-
idx_t col_idx = input.data.size() + expr_idx;
|
|
59071
|
-
auto &expr = *select_list[expr_idx];
|
|
59072
|
-
switch (expr.GetExpressionType()) {
|
|
59073
|
-
case ExpressionType::WINDOW_FIRST_VALUE:
|
|
59074
|
-
case ExpressionType::WINDOW_PERCENT_RANK:
|
|
59075
|
-
case ExpressionType::WINDOW_RANK:
|
|
59076
|
-
case ExpressionType::WINDOW_RANK_DENSE: {
|
|
59077
|
-
// Reference constant vector
|
|
59078
|
-
chunk.data[col_idx].Reference(*state.const_vectors[expr_idx]);
|
|
59079
|
-
break;
|
|
59080
|
-
}
|
|
59081
|
-
case ExpressionType::WINDOW_ROW_NUMBER: {
|
|
59082
|
-
// Set row numbers
|
|
59083
|
-
auto rdata = FlatVector::GetData<int64_t>(chunk.data[col_idx]);
|
|
59084
|
-
for (idx_t i = 0; i < count; i++) {
|
|
59085
|
-
rdata[i] = gstate.row_number + i;
|
|
59086
|
-
}
|
|
59087
|
-
break;
|
|
59088
|
-
}
|
|
59089
|
-
default:
|
|
59090
|
-
throw NotImplementedException("%s for StreamingWindow", ExpressionTypeToString(expr.GetExpressionType()));
|
|
59091
|
-
}
|
|
59092
|
-
}
|
|
59093
|
-
gstate.row_number += count;
|
|
59094
|
-
chunk.SetCardinality(count);
|
|
59095
|
-
return OperatorResultType::NEED_MORE_INPUT;
|
|
59096
|
-
}
|
|
59097
|
-
|
|
59098
|
-
string PhysicalStreamingWindow::ParamsToString() const {
|
|
59099
|
-
string result;
|
|
59100
|
-
for (idx_t i = 0; i < select_list.size(); i++) {
|
|
59101
|
-
if (i > 0) {
|
|
59102
|
-
result += "\n";
|
|
59103
|
-
}
|
|
59104
|
-
result += select_list[i]->GetName();
|
|
59105
|
-
}
|
|
59106
|
-
return result;
|
|
59107
|
-
}
|
|
59108
|
-
|
|
59109
|
-
} // namespace duckdb
|
|
59110
|
-
//===----------------------------------------------------------------------===//
|
|
59111
|
-
// DuckDB
|
|
59112
|
-
//
|
|
59113
|
-
// duckdb/execution/operator/aggregate/physical_window.hpp
|
|
59114
|
-
//
|
|
59115
|
-
//
|
|
59116
|
-
//===----------------------------------------------------------------------===//
|
|
59117
|
-
|
|
59118
|
-
|
|
59119
|
-
|
|
59120
|
-
|
|
59121
|
-
|
|
59122
|
-
|
|
59123
59125
|
|
|
59124
59126
|
namespace duckdb {
|
|
59125
59127
|
|
|
@@ -74770,8 +74772,8 @@ unique_ptr<PhysicalOperator> PhysicalPlanGenerator::CreatePlan(LogicalAggregate
|
|
|
74770
74772
|
}
|
|
74771
74773
|
}
|
|
74772
74774
|
if (use_simple_aggregation) {
|
|
74773
|
-
groupby = make_unique_base<PhysicalOperator,
|
|
74774
|
-
|
|
74775
|
+
groupby = make_unique_base<PhysicalOperator, PhysicalUngroupedAggregate>(op.types, move(op.expressions),
|
|
74776
|
+
op.estimated_cardinality);
|
|
74775
74777
|
} else {
|
|
74776
74778
|
groupby = make_unique_base<PhysicalOperator, PhysicalHashAggregate>(context, op.types, move(op.expressions),
|
|
74777
74779
|
op.estimated_cardinality);
|
|
@@ -127315,7 +127317,7 @@ bool QueryProfiler::OperatorRequiresProfiling(PhysicalOperatorType op_type) {
|
|
|
127315
127317
|
case PhysicalOperatorType::TOP_N:
|
|
127316
127318
|
case PhysicalOperatorType::WINDOW:
|
|
127317
127319
|
case PhysicalOperatorType::UNNEST:
|
|
127318
|
-
case PhysicalOperatorType::
|
|
127320
|
+
case PhysicalOperatorType::UNGROUPED_AGGREGATE:
|
|
127319
127321
|
case PhysicalOperatorType::HASH_GROUP_BY:
|
|
127320
127322
|
case PhysicalOperatorType::FILTER:
|
|
127321
127323
|
case PhysicalOperatorType::PROJECTION:
|
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 "
|
|
15
|
-
#define DUCKDB_VERSION "v0.4.1-
|
|
14
|
+
#define DUCKDB_SOURCE_ID "1e8e67cfe"
|
|
15
|
+
#define DUCKDB_VERSION "v0.4.1-dev456"
|
|
16
16
|
//===----------------------------------------------------------------------===//
|
|
17
17
|
// DuckDB
|
|
18
18
|
//
|
|
@@ -10544,7 +10544,7 @@ enum class PhysicalOperatorType : uint8_t {
|
|
|
10544
10544
|
TOP_N,
|
|
10545
10545
|
WINDOW,
|
|
10546
10546
|
UNNEST,
|
|
10547
|
-
|
|
10547
|
+
UNGROUPED_AGGREGATE,
|
|
10548
10548
|
HASH_GROUP_BY,
|
|
10549
10549
|
PERFECT_HASH_GROUP_BY,
|
|
10550
10550
|
FILTER,
|