Skip to content

Commit 4e07810

Browse files
duckdblabs-botgithub-actions[bot]
authored andcommitted
Update vendored DuckDB sources to 7ce99bc041
1 parent 6091ecd commit 4e07810

File tree

12 files changed

+94
-20
lines changed

12 files changed

+94
-20
lines changed

src/duckdb/src/execution/join_hashtable.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -888,19 +888,25 @@ idx_t ScanStructure::ResolvePredicates(DataChunk &keys, SelectionVector &match_s
888888
}
889889

890890
// If there is a matcher for the probing side because of non-equality predicates, use it
891+
idx_t result_count;
891892
if (ht.needs_chain_matcher) {
892893
idx_t no_match_count = 0;
893894
auto &matcher = no_match_sel ? ht.row_matcher_probe_no_match_sel : ht.row_matcher_probe;
894895
D_ASSERT(matcher);
895896

896897
// we need to only use the vectors with the indices of the columns that are used in the probe phase, namely
897898
// the non-equality columns
898-
return matcher->Match(keys, key_state.vector_data, match_sel, this->count, pointers, no_match_sel,
899-
no_match_count);
899+
result_count =
900+
matcher->Match(keys, key_state.vector_data, match_sel, this->count, pointers, no_match_sel, no_match_count);
900901
} else {
901902
// no match sel is the opposite of match sel
902-
return this->count;
903+
result_count = this->count;
903904
}
905+
906+
// Update total probe match count
907+
ht.total_probe_matches.fetch_add(result_count, std::memory_order_relaxed);
908+
909+
return result_count;
904910
}
905911

906912
idx_t ScanStructure::ScanInnerJoin(DataChunk &keys, SelectionVector &result_vector) {

src/duckdb/src/execution/operator/join/physical_hash_join.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,11 @@ class HashJoinGlobalSinkState : public GlobalSinkState {
164164
}
165165
}
166166

167+
~HashJoinGlobalSinkState() override {
168+
DUCKDB_LOG(context, PhysicalOperatorLogType, op, "PhysicalHashJoin", "GetData",
169+
{{"total_probe_matches", to_string(hash_table->total_probe_matches)}});
170+
}
171+
167172
void ScheduleFinalize(Pipeline &pipeline, Event &event);
168173
void InitializeProbeSpill();
169174

src/duckdb/src/function/table/version/pragma_version.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#ifndef DUCKDB_PATCH_VERSION
2-
#define DUCKDB_PATCH_VERSION "2-dev279"
2+
#define DUCKDB_PATCH_VERSION "2-dev284"
33
#endif
44
#ifndef DUCKDB_MINOR_VERSION
55
#define DUCKDB_MINOR_VERSION 4
@@ -8,10 +8,10 @@
88
#define DUCKDB_MAJOR_VERSION 1
99
#endif
1010
#ifndef DUCKDB_VERSION
11-
#define DUCKDB_VERSION "v1.4.2-dev279"
11+
#define DUCKDB_VERSION "v1.4.2-dev284"
1212
#endif
1313
#ifndef DUCKDB_SOURCE_ID
14-
#define DUCKDB_SOURCE_ID "783f08ffd8"
14+
#define DUCKDB_SOURCE_ID "7ce99bc041"
1515
#endif
1616
#include "duckdb/function/table/system_functions.hpp"
1717
#include "duckdb/main/database.hpp"

src/duckdb/src/include/duckdb/execution/join_hashtable.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,8 @@ class JoinHashTable {
277277
uint64_t bitmask = DConstants::INVALID_INDEX;
278278
//! Whether or not we error on multiple rows found per match in a SINGLE join
279279
bool single_join_error_on_multiple_rows = true;
280+
//! Number of probe matches
281+
atomic<idx_t> total_probe_matches {0};
280282

281283
struct {
282284
mutex mj_lock;

src/duckdb/src/include/duckdb/main/relation.hpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,19 +162,27 @@ class Relation : public enable_shared_from_this<Relation> {
162162

163163
//! Insert the data from this relation into a table
164164
DUCKDB_API shared_ptr<Relation> InsertRel(const string &schema_name, const string &table_name);
165+
DUCKDB_API shared_ptr<Relation> InsertRel(const string &catalog_name, const string &schema_name,
166+
const string &table_name);
165167
DUCKDB_API void Insert(const string &table_name);
166168
DUCKDB_API void Insert(const string &schema_name, const string &table_name);
169+
DUCKDB_API void Insert(const string &catalog_name, const string &schema_name, const string &table_name);
167170
//! Insert a row (i.e.,list of values) into a table
168-
DUCKDB_API void Insert(const vector<vector<Value>> &values);
169-
DUCKDB_API void Insert(vector<vector<unique_ptr<ParsedExpression>>> &&expressions);
171+
DUCKDB_API virtual void Insert(const vector<vector<Value>> &values);
172+
DUCKDB_API virtual void Insert(vector<vector<unique_ptr<ParsedExpression>>> &&expressions);
170173
//! Create a table and insert the data from this relation into that table
171174
DUCKDB_API shared_ptr<Relation> CreateRel(const string &schema_name, const string &table_name,
172175
bool temporary = false,
173176
OnCreateConflict on_conflict = OnCreateConflict::ERROR_ON_CONFLICT);
177+
DUCKDB_API shared_ptr<Relation> CreateRel(const string &catalog_name, const string &schema_name,
178+
const string &table_name, bool temporary = false,
179+
OnCreateConflict on_conflict = OnCreateConflict::ERROR_ON_CONFLICT);
174180
DUCKDB_API void Create(const string &table_name, bool temporary = false,
175181
OnCreateConflict on_conflict = OnCreateConflict::ERROR_ON_CONFLICT);
176182
DUCKDB_API void Create(const string &schema_name, const string &table_name, bool temporary = false,
177183
OnCreateConflict on_conflict = OnCreateConflict::ERROR_ON_CONFLICT);
184+
DUCKDB_API void Create(const string &catalog_name, const string &schema_name, const string &table_name,
185+
bool temporary = false, OnCreateConflict on_conflict = OnCreateConflict::ERROR_ON_CONFLICT);
178186

179187
//! Write a relation to a CSV file
180188
DUCKDB_API shared_ptr<Relation>

src/duckdb/src/include/duckdb/main/relation/create_table_relation.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@ class CreateTableRelation : public Relation {
1616
public:
1717
CreateTableRelation(shared_ptr<Relation> child, string schema_name, string table_name, bool temporary,
1818
OnCreateConflict on_conflict);
19+
CreateTableRelation(shared_ptr<Relation> child, string catalog_name, string schema_name, string table_name,
20+
bool temporary, OnCreateConflict on_conflict);
1921

2022
shared_ptr<Relation> child;
23+
string catalog_name;
2124
string schema_name;
2225
string table_name;
2326
vector<ColumnDefinition> columns;

src/duckdb/src/include/duckdb/main/relation/insert_relation.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ namespace duckdb {
1515
class InsertRelation : public Relation {
1616
public:
1717
InsertRelation(shared_ptr<Relation> child, string schema_name, string table_name);
18+
InsertRelation(shared_ptr<Relation> child, string catalog_name, string schema_name, string table_name);
1819

1920
shared_ptr<Relation> child;
21+
string catalog_name;
2022
string schema_name;
2123
string table_name;
2224
vector<ColumnDefinition> columns;

src/duckdb/src/include/duckdb/main/relation/table_relation.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ class TableRelation : public Relation {
2929

3030
unique_ptr<TableRef> GetTableRef() override;
3131

32+
void Insert(const vector<vector<Value>> &values) override;
33+
void Insert(vector<vector<unique_ptr<ParsedExpression>>> &&expressions) override;
3234
void Update(const string &update, const string &condition = string()) override;
3335
void Update(vector<string> column_names, vector<unique_ptr<ParsedExpression>> &&update,
3436
unique_ptr<ParsedExpression> condition = nullptr) override;

src/duckdb/src/main/relation.cpp

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -241,15 +241,24 @@ BoundStatement Relation::Bind(Binder &binder) {
241241
}
242242

243243
shared_ptr<Relation> Relation::InsertRel(const string &schema_name, const string &table_name) {
244-
return make_shared_ptr<InsertRelation>(shared_from_this(), schema_name, table_name);
244+
return InsertRel(INVALID_CATALOG, schema_name, table_name);
245+
}
246+
247+
shared_ptr<Relation> Relation::InsertRel(const string &catalog_name, const string &schema_name,
248+
const string &table_name) {
249+
return make_shared_ptr<InsertRelation>(shared_from_this(), catalog_name, schema_name, table_name);
245250
}
246251

247252
void Relation::Insert(const string &table_name) {
248253
Insert(INVALID_SCHEMA, table_name);
249254
}
250255

251256
void Relation::Insert(const string &schema_name, const string &table_name) {
252-
auto insert = InsertRel(schema_name, table_name);
257+
Insert(INVALID_CATALOG, schema_name, table_name);
258+
}
259+
260+
void Relation::Insert(const string &catalog_name, const string &schema_name, const string &table_name) {
261+
auto insert = InsertRel(catalog_name, schema_name, table_name);
253262
auto res = insert->Execute();
254263
if (res->HasError()) {
255264
const string prepended_message = "Failed to insert into table '" + table_name + "': ";
@@ -258,30 +267,37 @@ void Relation::Insert(const string &schema_name, const string &table_name) {
258267
}
259268

260269
void Relation::Insert(const vector<vector<Value>> &values) {
261-
vector<string> column_names;
262-
auto rel = make_shared_ptr<ValueRelation>(context->GetContext(), values, std::move(column_names), "values");
263-
rel->Insert(GetAlias());
270+
throw InvalidInputException("INSERT with values can only be used on base tables!");
264271
}
265272

266273
void Relation::Insert(vector<vector<unique_ptr<ParsedExpression>>> &&expressions) {
267-
vector<string> column_names;
268-
auto rel = make_shared_ptr<ValueRelation>(context->GetContext(), std::move(expressions), std::move(column_names),
269-
"values");
270-
rel->Insert(GetAlias());
274+
(void)std::move(expressions);
275+
throw InvalidInputException("INSERT with expressions can only be used on base tables!");
271276
}
272277

273278
shared_ptr<Relation> Relation::CreateRel(const string &schema_name, const string &table_name, bool temporary,
274279
OnCreateConflict on_conflict) {
275-
return make_shared_ptr<CreateTableRelation>(shared_from_this(), schema_name, table_name, temporary, on_conflict);
280+
return CreateRel(INVALID_CATALOG, schema_name, table_name, temporary, on_conflict);
281+
}
282+
283+
shared_ptr<Relation> Relation::CreateRel(const string &catalog_name, const string &schema_name,
284+
const string &table_name, bool temporary, OnCreateConflict on_conflict) {
285+
return make_shared_ptr<CreateTableRelation>(shared_from_this(), catalog_name, schema_name, table_name, temporary,
286+
on_conflict);
276287
}
277288

278289
void Relation::Create(const string &table_name, bool temporary, OnCreateConflict on_conflict) {
279-
Create(INVALID_SCHEMA, table_name, temporary, on_conflict);
290+
Create(INVALID_CATALOG, INVALID_SCHEMA, table_name, temporary, on_conflict);
280291
}
281292

282293
void Relation::Create(const string &schema_name, const string &table_name, bool temporary,
283294
OnCreateConflict on_conflict) {
284-
auto create = CreateRel(schema_name, table_name, temporary, on_conflict);
295+
Create(INVALID_CATALOG, schema_name, table_name, temporary, on_conflict);
296+
}
297+
298+
void Relation::Create(const string &catalog_name, const string &schema_name, const string &table_name, bool temporary,
299+
OnCreateConflict on_conflict) {
300+
auto create = CreateRel(catalog_name, schema_name, table_name, temporary, on_conflict);
285301
auto res = create->Execute();
286302
if (res->HasError()) {
287303
const string prepended_message = "Failed to create table '" + table_name + "': ";

src/duckdb/src/main/relation/create_table_relation.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,21 @@ CreateTableRelation::CreateTableRelation(shared_ptr<Relation> child_p, string sc
1414
TryBindRelation(columns);
1515
}
1616

17+
CreateTableRelation::CreateTableRelation(shared_ptr<Relation> child_p, string catalog_name, string schema_name,
18+
string table_name, bool temporary_p, OnCreateConflict on_conflict)
19+
: Relation(child_p->context, RelationType::CREATE_TABLE_RELATION), child(std::move(child_p)),
20+
catalog_name(std::move(catalog_name)), schema_name(std::move(schema_name)), table_name(std::move(table_name)),
21+
temporary(temporary_p), on_conflict(on_conflict) {
22+
TryBindRelation(columns);
23+
}
24+
1725
BoundStatement CreateTableRelation::Bind(Binder &binder) {
1826
auto select = make_uniq<SelectStatement>();
1927
select->node = child->GetQueryNode();
2028

2129
CreateStatement stmt;
2230
auto info = make_uniq<CreateTableInfo>();
31+
info->catalog = catalog_name;
2332
info->schema = schema_name;
2433
info->table = table_name;
2534
info->query = std::move(select);

0 commit comments

Comments
 (0)