duckdb 0.7.2-dev586.0 → 0.7.2-dev654.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/extension/icu/icu-table-range.cpp +7 -7
- package/src/duckdb/extension/parquet/parquet_reader.cpp +1 -1
- package/src/duckdb/src/catalog/catalog_entry/table_catalog_entry.cpp +3 -3
- package/src/duckdb/src/catalog/dependency_list.cpp +12 -0
- package/src/duckdb/src/common/string_util.cpp +4 -1
- package/src/duckdb/src/common/types/blob.cpp +1 -1
- package/src/duckdb/src/common/types/chunk_collection.cpp +2 -2
- package/src/duckdb/src/common/types/data_chunk.cpp +1 -1
- package/src/duckdb/src/common/types/value.cpp +8 -8
- package/src/duckdb/src/common/types.cpp +11 -11
- package/src/duckdb/src/execution/operator/aggregate/physical_window.cpp +15 -3
- package/src/duckdb/src/execution/operator/helper/physical_vacuum.cpp +3 -0
- package/src/duckdb/src/execution/operator/join/physical_iejoin.cpp +2 -2
- package/src/duckdb/src/execution/operator/join/physical_piecewise_merge_join.cpp +6 -11
- package/src/duckdb/src/execution/operator/join/physical_range_join.cpp +1 -1
- package/src/duckdb/src/execution/operator/persistent/physical_copy_to_file.cpp +2 -2
- package/src/duckdb/src/execution/physical_plan/plan_comparison_join.cpp +3 -0
- package/src/duckdb/src/function/aggregate/distributive/bitstring_agg.cpp +22 -7
- package/src/duckdb/src/function/aggregate/distributive/first.cpp +1 -0
- package/src/duckdb/src/function/aggregate/holistic/approximate_quantile.cpp +5 -2
- package/src/duckdb/src/function/aggregate/holistic/quantile.cpp +1 -1
- package/src/duckdb/src/function/aggregate/nested/list.cpp +8 -8
- package/src/duckdb/src/function/cast/struct_cast.cpp +1 -1
- package/src/duckdb/src/function/scalar/date/date_part.cpp +1 -1
- package/src/duckdb/src/function/scalar/list/list_concat.cpp +5 -4
- package/src/duckdb/src/function/scalar/list/list_lambdas.cpp +3 -3
- package/src/duckdb/src/function/scalar/list/list_value.cpp +1 -1
- package/src/duckdb/src/function/scalar/map/map_entries.cpp +1 -1
- package/src/duckdb/src/function/scalar/struct/struct_insert.cpp +1 -1
- package/src/duckdb/src/function/scalar/struct/struct_pack.cpp +1 -1
- package/src/duckdb/src/function/table/arrow.cpp +2 -2
- package/src/duckdb/src/function/table/checkpoint.cpp +5 -1
- package/src/duckdb/src/function/table/system/duckdb_constraints.cpp +2 -2
- package/src/duckdb/src/function/table/system/test_all_types.cpp +2 -2
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/catalog/dependency_list.hpp +3 -0
- package/src/duckdb/src/include/duckdb/common/types/value.hpp +3 -3
- package/src/duckdb/src/include/duckdb/common/types.hpp +3 -3
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +3 -0
- package/src/duckdb/src/include/duckdb/storage/statistics/distinct_statistics.hpp +2 -0
- package/src/duckdb/src/include/duckdb/storage/table/update_segment.hpp +0 -1
- package/src/duckdb/src/main/config.cpp +4 -0
- package/src/duckdb/src/optimizer/join_order/cardinality_estimator.cpp +3 -4
- package/src/duckdb/src/optimizer/join_order/join_order_optimizer.cpp +5 -3
- package/src/duckdb/src/optimizer/pushdown/pushdown_aggregate.cpp +33 -5
- package/src/duckdb/src/optimizer/rule/move_constants.cpp +8 -2
- package/src/duckdb/src/optimizer/unnest_rewriter.cpp +2 -2
- package/src/duckdb/src/parser/expression/conjunction_expression.cpp +2 -0
- package/src/duckdb/src/parser/transform/expression/transform_function.cpp +17 -1
- package/src/duckdb/src/parser/transform/helpers/transform_typename.cpp +3 -2
- package/src/duckdb/src/parser/transform/statement/transform_select_node.cpp +1 -2
- package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +1 -1
- package/src/duckdb/src/planner/binder/expression/bind_columnref_expression.cpp +4 -3
- package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +25 -13
- package/src/duckdb/src/planner/binder/statement/bind_copy.cpp +2 -2
- package/src/duckdb/src/planner/binder/statement/bind_create.cpp +2 -1
- package/src/duckdb/src/planner/binder/statement/bind_create_table.cpp +9 -1
- package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +10 -6
- package/src/duckdb/src/planner/binder/statement/bind_update.cpp +3 -1
- package/src/duckdb/src/planner/binder/tableref/bind_pivot.cpp +1 -0
- package/src/duckdb/src/planner/binder/tableref/plan_cteref.cpp +1 -0
- package/src/duckdb/src/planner/expression_binder/having_binder.cpp +3 -0
- package/src/duckdb/src/planner/expression_binder.cpp +1 -1
- package/src/duckdb/src/storage/statistics/column_statistics.cpp +1 -2
- package/src/duckdb/src/storage/statistics/distinct_statistics.cpp +4 -0
- package/src/duckdb/src/storage/statistics/list_stats.cpp +6 -2
- package/src/duckdb/src/storage/statistics/struct_stats.cpp +3 -1
- package/src/duckdb/src/storage/table/row_group.cpp +6 -1
- package/src/duckdb/src/storage/table/update_segment.cpp +11 -7
@@ -335,6 +335,16 @@ void Binder::BindOnConflictClause(LogicalInsert &insert, TableCatalogEntry &tabl
|
|
335
335
|
ReplaceColumnBindings(*insert.on_conflict_condition, table_index, projection_index);
|
336
336
|
}
|
337
337
|
|
338
|
+
if (insert.action_type == OnConflictAction::REPLACE) {
|
339
|
+
D_ASSERT(on_conflict.set_info == nullptr);
|
340
|
+
on_conflict.set_info = CreateSetInfoForReplace(table, stmt);
|
341
|
+
insert.action_type = OnConflictAction::UPDATE;
|
342
|
+
}
|
343
|
+
if (on_conflict.set_info && on_conflict.set_info->columns.empty()) {
|
344
|
+
// if we are doing INSERT OR REPLACE on a table with no columns outside of the primary key column
|
345
|
+
// convert to INSERT OR IGNORE
|
346
|
+
insert.action_type = OnConflictAction::NOTHING;
|
347
|
+
}
|
338
348
|
if (insert.action_type == OnConflictAction::NOTHING) {
|
339
349
|
if (!insert.on_conflict_condition) {
|
340
350
|
return;
|
@@ -346,15 +356,9 @@ void Binder::BindOnConflictClause(LogicalInsert &insert, TableCatalogEntry &tabl
|
|
346
356
|
insert.columns_to_fetch = table_binding->GetBoundColumnIds();
|
347
357
|
return;
|
348
358
|
}
|
349
|
-
if (insert.action_type == OnConflictAction::REPLACE) {
|
350
|
-
D_ASSERT(on_conflict.set_info == nullptr);
|
351
|
-
on_conflict.set_info = CreateSetInfoForReplace(table, stmt);
|
352
|
-
insert.action_type = OnConflictAction::UPDATE;
|
353
|
-
}
|
354
359
|
|
355
360
|
D_ASSERT(on_conflict.set_info);
|
356
361
|
auto &set_info = *on_conflict.set_info;
|
357
|
-
D_ASSERT(!set_info.columns.empty());
|
358
362
|
D_ASSERT(set_info.columns.size() == set_info.expressions.size());
|
359
363
|
|
360
364
|
if (set_info.condition) {
|
@@ -195,11 +195,13 @@ BoundStatement Binder::Bind(UpdateStatement &stmt) {
|
|
195
195
|
AddCTEMap(stmt.cte_map);
|
196
196
|
|
197
197
|
if (stmt.from_table) {
|
198
|
+
auto from_binder = Binder::CreateBinder(context, this);
|
198
199
|
BoundJoinRef bound_crossproduct(JoinRefType::CROSS);
|
199
200
|
bound_crossproduct.left = std::move(bound_table);
|
200
|
-
bound_crossproduct.right = Bind(*stmt.from_table);
|
201
|
+
bound_crossproduct.right = from_binder->Bind(*stmt.from_table);
|
201
202
|
root = CreatePlan(bound_crossproduct);
|
202
203
|
get = (LogicalGet *)root->children[0].get();
|
204
|
+
bind_context.AddContext(std::move(from_binder->bind_context));
|
203
205
|
} else {
|
204
206
|
root = CreatePlan(*bound_table);
|
205
207
|
get = (LogicalGet *)root.get();
|
@@ -271,6 +271,7 @@ unique_ptr<SelectNode> Binder::BindUnpivot(Binder &child_binder, PivotRef &ref,
|
|
271
271
|
vector<vector<unique_ptr<ParsedExpression>>> unpivot_expressions;
|
272
272
|
for (idx_t v_idx = 0; v_idx < unpivot.entries[0].values.size(); v_idx++) {
|
273
273
|
vector<unique_ptr<ParsedExpression>> expressions;
|
274
|
+
expressions.reserve(unpivot.entries.size());
|
274
275
|
for (auto &entry : unpivot.entries) {
|
275
276
|
expressions.push_back(make_unique<ColumnRefExpression>(entry.values[v_idx].ToString()));
|
276
277
|
}
|
@@ -19,6 +19,9 @@ BindResult HavingBinder::BindColumnRef(unique_ptr<ParsedExpression> *expr_ptr, i
|
|
19
19
|
auto &expr = (ColumnRefExpression &)**expr_ptr;
|
20
20
|
auto alias_result = column_alias_binder.BindAlias(*this, expr, depth, root_expression);
|
21
21
|
if (!alias_result.HasError()) {
|
22
|
+
if (depth > 0) {
|
23
|
+
throw BinderException("Having clause cannot reference alias in correlated subquery");
|
24
|
+
}
|
22
25
|
return alias_result;
|
23
26
|
}
|
24
27
|
if (aggregate_handling == AggregateHandling::FORCE_AGGREGATES) {
|
@@ -157,7 +157,7 @@ LogicalType ExpressionBinder::ExchangeType(const LogicalType &type, LogicalTypeI
|
|
157
157
|
for (auto &child_type : child_types) {
|
158
158
|
child_type.second = ExchangeType(child_type.second, target, new_type);
|
159
159
|
}
|
160
|
-
return LogicalType::STRUCT(
|
160
|
+
return LogicalType::STRUCT(child_types);
|
161
161
|
}
|
162
162
|
case LogicalTypeId::UNION: {
|
163
163
|
auto member_types = UnionType::CopyMemberTypes(type);
|
@@ -4,8 +4,7 @@
|
|
4
4
|
namespace duckdb {
|
5
5
|
|
6
6
|
ColumnStatistics::ColumnStatistics(BaseStatistics stats_p) : stats(std::move(stats_p)) {
|
7
|
-
|
8
|
-
if (type != PhysicalType::LIST && type != PhysicalType::STRUCT) {
|
7
|
+
if (DistinctStatistics::TypeIsSupported(stats.GetType())) {
|
9
8
|
distinct_stats = make_unique<DistinctStatistics>();
|
10
9
|
}
|
11
10
|
}
|
@@ -94,4 +94,8 @@ idx_t DistinctStatistics::GetCount() const {
|
|
94
94
|
return MinValue<idx_t>(estimate, total_count);
|
95
95
|
}
|
96
96
|
|
97
|
+
bool DistinctStatistics::TypeIsSupported(const LogicalType &type) {
|
98
|
+
return type.InternalType() != PhysicalType::LIST && type.InternalType() != PhysicalType::STRUCT;
|
99
|
+
}
|
100
|
+
|
97
101
|
} // namespace duckdb
|
@@ -34,12 +34,16 @@ void ListStats::Copy(BaseStatistics &stats, const BaseStatistics &other) {
|
|
34
34
|
}
|
35
35
|
|
36
36
|
const BaseStatistics &ListStats::GetChildStats(const BaseStatistics &stats) {
|
37
|
-
|
37
|
+
if (stats.GetStatsType() != StatisticsType::LIST_STATS) {
|
38
|
+
throw InternalException("ListStats::GetChildStats called on stats that is not a list");
|
39
|
+
}
|
38
40
|
D_ASSERT(stats.child_stats);
|
39
41
|
return stats.child_stats[0];
|
40
42
|
}
|
41
43
|
BaseStatistics &ListStats::GetChildStats(BaseStatistics &stats) {
|
42
|
-
|
44
|
+
if (stats.GetStatsType() != StatisticsType::LIST_STATS) {
|
45
|
+
throw InternalException("ListStats::GetChildStats called on stats that is not a list");
|
46
|
+
}
|
43
47
|
D_ASSERT(stats.child_stats);
|
44
48
|
return stats.child_stats[0];
|
45
49
|
}
|
@@ -34,7 +34,9 @@ BaseStatistics StructStats::CreateEmpty(LogicalType type) {
|
|
34
34
|
}
|
35
35
|
|
36
36
|
const BaseStatistics *StructStats::GetChildStats(const BaseStatistics &stats) {
|
37
|
-
|
37
|
+
if (stats.GetStatsType() != StatisticsType::STRUCT_STATS) {
|
38
|
+
throw InternalException("Calling StructStats::GetChildStats on stats that is not a struct");
|
39
|
+
}
|
38
40
|
return stats.child_stats.get();
|
39
41
|
}
|
40
42
|
|
@@ -156,7 +156,11 @@ unique_ptr<RowGroup> RowGroup::AlterType(const LogicalType &target_type, idx_t c
|
|
156
156
|
// scan the original table, and fill the new column with the transformed value
|
157
157
|
InitializeScan(scan_state);
|
158
158
|
|
159
|
-
|
159
|
+
DataChunk append_chunk;
|
160
|
+
vector<LogicalType> append_types;
|
161
|
+
append_types.push_back(target_type);
|
162
|
+
append_chunk.Initialize(Allocator::DefaultAllocator(), append_types);
|
163
|
+
auto &append_vector = append_chunk.data[0];
|
160
164
|
SegmentStatistics altered_col_stats(target_type);
|
161
165
|
while (true) {
|
162
166
|
// scan the table
|
@@ -166,6 +170,7 @@ unique_ptr<RowGroup> RowGroup::AlterType(const LogicalType &target_type, idx_t c
|
|
166
170
|
break;
|
167
171
|
}
|
168
172
|
// execute the expression
|
173
|
+
append_chunk.Reset();
|
169
174
|
executor.ExecuteExpression(scan_chunk, append_vector);
|
170
175
|
column_data->Append(altered_col_stats.statistics, append_state, append_vector, scan_chunk.size());
|
171
176
|
}
|
@@ -38,7 +38,17 @@ UpdateSegment::UpdateSegment(UpdateSegment &other, ColumnData &owner)
|
|
38
38
|
: column_data(owner), root(std::move(other.root)), stats(std::move(other.stats)), type_size(other.type_size) {
|
39
39
|
|
40
40
|
this->heap.Move(other.heap);
|
41
|
-
|
41
|
+
// update the segment links
|
42
|
+
if (root) {
|
43
|
+
for (idx_t i = 0; i < RowGroup::ROW_GROUP_VECTOR_COUNT; i++) {
|
44
|
+
if (!root->info[i]) {
|
45
|
+
continue;
|
46
|
+
}
|
47
|
+
for (auto info = root->info[i]->info.get(); info; info = info->next) {
|
48
|
+
info->segment = this;
|
49
|
+
}
|
50
|
+
}
|
51
|
+
}
|
42
52
|
initialize_update_function = other.initialize_update_function;
|
43
53
|
merge_update_function = other.merge_update_function;
|
44
54
|
fetch_update_function = other.fetch_update_function;
|
@@ -52,12 +62,6 @@ UpdateSegment::UpdateSegment(UpdateSegment &other, ColumnData &owner)
|
|
52
62
|
UpdateSegment::~UpdateSegment() {
|
53
63
|
}
|
54
64
|
|
55
|
-
void UpdateSegment::ClearUpdates() {
|
56
|
-
stats.statistics.Copy(BaseStatistics::CreateEmpty(stats.statistics.GetType()));
|
57
|
-
root.reset();
|
58
|
-
heap.Destroy();
|
59
|
-
}
|
60
|
-
|
61
65
|
//===--------------------------------------------------------------------===//
|
62
66
|
// Update Info Helpers
|
63
67
|
//===--------------------------------------------------------------------===//
|