Skip to content

Commit 9a17fe8

Browse files
duckdblabs-botgithub-actions[bot]
authored andcommitted
Update vendored DuckDB sources to 7f217607e4
1 parent 84598a8 commit 9a17fe8

5 files changed

Lines changed: 77 additions & 60 deletions

File tree

src/duckdb/src/common/adbc/adbc.cpp

Lines changed: 24 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1161,12 +1161,21 @@ AdbcStatusCode StatementSetOption(struct AdbcStatement *statement, const char *k
11611161
return ADBC_STATUS_INVALID_ARGUMENT;
11621162
}
11631163

1164+
std::string createFilter(const char *input) {
1165+
if (input) {
1166+
auto quoted = duckdb::KeywordHelper::WriteQuoted(input, '\'');
1167+
return quoted;
1168+
}
1169+
return "'%'";
1170+
}
1171+
11641172
AdbcStatusCode ConnectionGetObjects(struct AdbcConnection *connection, int depth, const char *catalog,
11651173
const char *db_schema, const char *table_name, const char **table_type,
11661174
const char *column_name, struct ArrowArrayStream *out, struct AdbcError *error) {
1167-
std::string catalog_filter = catalog ? catalog : "%";
1168-
std::string db_schema_filter = db_schema ? db_schema : "%";
1169-
std::string table_name_filter = table_name ? table_name : "%";
1175+
std::string catalog_filter = createFilter(catalog);
1176+
std::string db_schema_filter = createFilter(db_schema);
1177+
std::string table_name_filter = createFilter(table_name);
1178+
std::string column_name_filter = createFilter(column_name);
11701179
std::string table_type_condition = "";
11711180
if (table_type && table_type[0]) {
11721181
table_type_condition = " AND table_type IN (";
@@ -1182,13 +1191,10 @@ AdbcStatusCode ConnectionGetObjects(struct AdbcConnection *connection, int depth
11821191
if (i > 0) {
11831192
table_type_condition += ", ";
11841193
}
1185-
table_type_condition += "'";
1186-
table_type_condition += table_type[i];
1187-
table_type_condition += "'";
1194+
table_type_condition += createFilter(table_type[i]);
11881195
}
11891196
table_type_condition += ")";
11901197
}
1191-
std::string column_name_filter = column_name ? column_name : "%";
11921198

11931199
std::string query;
11941200
switch (depth) {
@@ -1233,7 +1239,7 @@ AdbcStatusCode ConnectionGetObjects(struct AdbcConnection *connection, int depth
12331239
)[] catalog_db_schemas
12341240
FROM
12351241
information_schema.schemata
1236-
WHERE catalog_name LIKE '%s'
1242+
WHERE catalog_name LIKE %s
12371243
GROUP BY catalog_name
12381244
)",
12391245
catalog_filter);
@@ -1246,7 +1252,7 @@ AdbcStatusCode ConnectionGetObjects(struct AdbcConnection *connection, int depth
12461252
catalog_name,
12471253
schema_name,
12481254
FROM information_schema.schemata
1249-
WHERE schema_name LIKE '%s'
1255+
WHERE schema_name LIKE %s
12501256
)
12511257
12521258
SELECT
@@ -1289,7 +1295,7 @@ AdbcStatusCode ConnectionGetObjects(struct AdbcConnection *connection, int depth
12891295
information_schema.schemata
12901296
LEFT JOIN db_schemas dbs
12911297
USING (catalog_name, schema_name)
1292-
WHERE catalog_name LIKE '%s'
1298+
WHERE catalog_name LIKE %s
12931299
GROUP BY catalog_name
12941300
)",
12951301
db_schema_filter, catalog_filter);
@@ -1333,7 +1339,7 @@ AdbcStatusCode ConnectionGetObjects(struct AdbcConnection *connection, int depth
13331339
)[],
13341340
}) db_schema_tables
13351341
FROM information_schema.tables
1336-
WHERE table_name LIKE '%s'%s
1342+
WHERE table_name LIKE %s%s
13371343
GROUP BY table_catalog, table_schema
13381344
),
13391345
db_schemas AS (
@@ -1344,7 +1350,7 @@ AdbcStatusCode ConnectionGetObjects(struct AdbcConnection *connection, int depth
13441350
FROM information_schema.schemata
13451351
LEFT JOIN tables
13461352
USING (catalog_name, schema_name)
1347-
WHERE schema_name LIKE '%s'
1353+
WHERE schema_name LIKE %s
13481354
)
13491355
13501356
SELECT
@@ -1357,7 +1363,7 @@ AdbcStatusCode ConnectionGetObjects(struct AdbcConnection *connection, int depth
13571363
information_schema.schemata
13581364
LEFT JOIN db_schemas dbs
13591365
USING (catalog_name, schema_name)
1360-
WHERE catalog_name LIKE '%s'
1366+
WHERE catalog_name LIKE %s
13611367
GROUP BY catalog_name
13621368
)",
13631369
table_name_filter, table_type_condition, db_schema_filter, catalog_filter);
@@ -1392,7 +1398,7 @@ AdbcStatusCode ConnectionGetObjects(struct AdbcConnection *connection, int depth
13921398
xdbc_is_generatedcolumn: NULL::BOOLEAN,
13931399
}) table_columns
13941400
FROM information_schema.columns
1395-
WHERE column_name LIKE '%s'
1401+
WHERE column_name LIKE %s
13961402
GROUP BY table_catalog, table_schema, table_name
13971403
),
13981404
constraints AS (
@@ -1421,7 +1427,7 @@ AdbcStatusCode ConnectionGetObjects(struct AdbcConnection *connection, int depth
14211427
constraint_column_names,
14221428
list_filter(
14231429
constraint_column_names,
1424-
lambda name: name LIKE '%s'
1430+
lambda name: name LIKE %s
14251431
)
14261432
)
14271433
GROUP BY database_name, schema_name, table_name
@@ -1441,7 +1447,7 @@ AdbcStatusCode ConnectionGetObjects(struct AdbcConnection *connection, int depth
14411447
USING (table_catalog, table_schema, table_name)
14421448
LEFT JOIN constraints
14431449
USING (table_catalog, table_schema, table_name)
1444-
WHERE table_name LIKE '%s'%s
1450+
WHERE table_name LIKE %s%s
14451451
GROUP BY table_catalog, table_schema
14461452
),
14471453
db_schemas AS (
@@ -1452,7 +1458,7 @@ AdbcStatusCode ConnectionGetObjects(struct AdbcConnection *connection, int depth
14521458
FROM information_schema.schemata
14531459
LEFT JOIN tables
14541460
USING (catalog_name, schema_name)
1455-
WHERE schema_name LIKE '%s'
1461+
WHERE schema_name LIKE %s
14561462
)
14571463
14581464
SELECT
@@ -1465,7 +1471,7 @@ AdbcStatusCode ConnectionGetObjects(struct AdbcConnection *connection, int depth
14651471
information_schema.schemata
14661472
LEFT JOIN db_schemas dbs
14671473
USING (catalog_name, schema_name)
1468-
WHERE catalog_name LIKE '%s'
1474+
WHERE catalog_name LIKE %s
14691475
GROUP BY catalog_name
14701476
)",
14711477
column_name_filter, column_name_filter, table_name_filter,

src/duckdb/src/execution/operator/aggregate/physical_streaming_window.cpp

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ PhysicalStreamingWindow::PhysicalStreamingWindow(PhysicalPlan &physical_plan, ve
1717

1818
class StreamingWindowGlobalState : public GlobalOperatorState {
1919
public:
20-
StreamingWindowGlobalState() : row_number(1) {
21-
}
20+
explicit StreamingWindowGlobalState(ClientContext &client);
2221

2322
//! The next row number.
2423
std::atomic<int64_t> row_number;
24+
//! The single local state
25+
unique_ptr<OperatorState> local_state;
2526
};
2627

2728
class StreamingWindowState : public OperatorState {
@@ -340,6 +341,10 @@ class StreamingWindowState : public OperatorState {
340341
DataChunk shifted;
341342
};
342343

344+
StreamingWindowGlobalState::StreamingWindowGlobalState(ClientContext &client) : row_number(1) {
345+
local_state = make_uniq<StreamingWindowState>(client);
346+
}
347+
343348
bool PhysicalStreamingWindow::IsStreamingFunction(ClientContext &context, unique_ptr<Expression> &expr) {
344349
auto &wexpr = expr->Cast<BoundWindowExpression>();
345350
if (!wexpr.partitions.empty() || !wexpr.orders.empty() || wexpr.ignore_nulls || !wexpr.arg_orders.empty() ||
@@ -374,12 +379,8 @@ bool PhysicalStreamingWindow::IsStreamingFunction(ClientContext &context, unique
374379
}
375380
}
376381

377-
unique_ptr<GlobalOperatorState> PhysicalStreamingWindow::GetGlobalOperatorState(ClientContext &context) const {
378-
return make_uniq<StreamingWindowGlobalState>();
379-
}
380-
381-
unique_ptr<OperatorState> PhysicalStreamingWindow::GetOperatorState(ExecutionContext &context) const {
382-
return make_uniq<StreamingWindowState>(context.client);
382+
unique_ptr<GlobalOperatorState> PhysicalStreamingWindow::GetGlobalOperatorState(ClientContext &client) const {
383+
return make_uniq<StreamingWindowGlobalState>(client);
383384
}
384385

385386
void StreamingWindowState::AggregateState::Execute(ExecutionContext &context, DataChunk &input, Vector &result) {
@@ -486,9 +487,9 @@ void StreamingWindowState::AggregateState::Execute(ExecutionContext &context, Da
486487
}
487488

488489
void PhysicalStreamingWindow::ExecuteFunctions(ExecutionContext &context, DataChunk &output, DataChunk &delayed,
489-
GlobalOperatorState &gstate_p, OperatorState &state_p) const {
490+
GlobalOperatorState &gstate_p) const {
490491
auto &gstate = gstate_p.Cast<StreamingWindowGlobalState>();
491-
auto &state = state_p.Cast<StreamingWindowState>();
492+
auto &state = gstate.local_state->Cast<StreamingWindowState>();
492493

493494
// Compute window functions
494495
const idx_t count = output.size();
@@ -530,9 +531,9 @@ void PhysicalStreamingWindow::ExecuteFunctions(ExecutionContext &context, DataCh
530531
}
531532

532533
void PhysicalStreamingWindow::ExecuteInput(ExecutionContext &context, DataChunk &delayed, DataChunk &input,
533-
DataChunk &output, GlobalOperatorState &gstate_p,
534-
OperatorState &state_p) const {
535-
auto &state = state_p.Cast<StreamingWindowState>();
534+
DataChunk &output, GlobalOperatorState &gstate_p) const {
535+
auto &gstate = gstate_p.Cast<StreamingWindowGlobalState>();
536+
auto &state = gstate.local_state->Cast<StreamingWindowState>();
536537

537538
// Put payload columns in place
538539
for (idx_t col_idx = 0; col_idx < input.data.size(); col_idx++) {
@@ -548,13 +549,13 @@ void PhysicalStreamingWindow::ExecuteInput(ExecutionContext &context, DataChunk
548549
}
549550
output.SetCardinality(count);
550551

551-
ExecuteFunctions(context, output, state.delayed, gstate_p, state_p);
552+
ExecuteFunctions(context, output, state.delayed, gstate_p);
552553
}
553554

554555
void PhysicalStreamingWindow::ExecuteShifted(ExecutionContext &context, DataChunk &delayed, DataChunk &input,
555-
DataChunk &output, GlobalOperatorState &gstate_p,
556-
OperatorState &state_p) const {
557-
auto &state = state_p.Cast<StreamingWindowState>();
556+
DataChunk &output, GlobalOperatorState &gstate_p) const {
557+
auto &gstate = gstate_p.Cast<StreamingWindowGlobalState>();
558+
auto &state = gstate.local_state->Cast<StreamingWindowState>();
558559
auto &shifted = state.shifted;
559560

560561
idx_t out = output.size();
@@ -576,25 +577,25 @@ void PhysicalStreamingWindow::ExecuteShifted(ExecutionContext &context, DataChun
576577
}
577578
delayed.SetCardinality(delay - out + in);
578579

579-
ExecuteFunctions(context, output, delayed, gstate_p, state_p);
580+
ExecuteFunctions(context, output, delayed, gstate_p);
580581
}
581582

582583
void PhysicalStreamingWindow::ExecuteDelayed(ExecutionContext &context, DataChunk &delayed, DataChunk &input,
583-
DataChunk &output, GlobalOperatorState &gstate_p,
584-
OperatorState &state_p) const {
584+
DataChunk &output, GlobalOperatorState &gstate_p) const {
585585
// Put payload columns in place
586586
for (idx_t col_idx = 0; col_idx < delayed.data.size(); col_idx++) {
587587
output.data[col_idx].Reference(delayed.data[col_idx]);
588588
}
589589
idx_t count = delayed.size();
590590
output.SetCardinality(count);
591591

592-
ExecuteFunctions(context, output, input, gstate_p, state_p);
592+
ExecuteFunctions(context, output, input, gstate_p);
593593
}
594594

595595
OperatorResultType PhysicalStreamingWindow::Execute(ExecutionContext &context, DataChunk &input, DataChunk &output,
596-
GlobalOperatorState &gstate_p, OperatorState &state_p) const {
597-
auto &state = state_p.Cast<StreamingWindowState>();
596+
GlobalOperatorState &gstate_p, OperatorState &) const {
597+
auto &gstate = gstate_p.Cast<StreamingWindowGlobalState>();
598+
auto &state = gstate.local_state->Cast<StreamingWindowState>();
598599
if (!state.initialized) {
599600
state.Initialize(context.client, input, select_list);
600601
}
@@ -615,27 +616,27 @@ OperatorResultType PhysicalStreamingWindow::Execute(ExecutionContext &context, D
615616
// If we can't consume all of the delayed values,
616617
// we need to split them instead of referencing them all
617618
output.SetCardinality(input.size());
618-
ExecuteShifted(context, delayed, input, output, gstate_p, state_p);
619+
ExecuteShifted(context, delayed, input, output, gstate_p);
619620
// We delayed the unused input so ask for more
620621
return OperatorResultType::NEED_MORE_INPUT;
621622
} else if (delayed.size()) {
622623
// We have enough delayed rows so flush them
623-
ExecuteDelayed(context, delayed, input, output, gstate_p, state_p);
624+
ExecuteDelayed(context, delayed, input, output, gstate_p);
624625
// Defer resetting delayed as it may be referenced.
625626
delayed.SetCardinality(0);
626627
// Come back to process the input
627628
return OperatorResultType::HAVE_MORE_OUTPUT;
628629
} else {
629630
// No delayed rows, so emit what we can and delay the rest.
630-
ExecuteInput(context, delayed, input, output, gstate_p, state_p);
631+
ExecuteInput(context, delayed, input, output, gstate_p);
631632
return OperatorResultType::NEED_MORE_INPUT;
632633
}
633634
}
634635

635636
OperatorFinalizeResultType PhysicalStreamingWindow::FinalExecute(ExecutionContext &context, DataChunk &output,
636-
GlobalOperatorState &gstate_p,
637-
OperatorState &state_p) const {
638-
auto &state = state_p.Cast<StreamingWindowState>();
637+
GlobalOperatorState &gstate_p, OperatorState &) const {
638+
auto &gstate = gstate_p.Cast<StreamingWindowGlobalState>();
639+
auto &state = gstate.local_state->Cast<StreamingWindowState>();
639640

640641
if (state.initialized && state.lead_count) {
641642
auto &delayed = state.delayed;
@@ -646,10 +647,10 @@ OperatorFinalizeResultType PhysicalStreamingWindow::FinalExecute(ExecutionContex
646647
if (output.GetCapacity() < delayed.size()) {
647648
// More than one output buffer was delayed, so shift in what we can
648649
output.SetCardinality(output.GetCapacity());
649-
ExecuteShifted(context, delayed, input, output, gstate_p, state_p);
650+
ExecuteShifted(context, delayed, input, output, gstate_p);
650651
return OperatorFinalizeResultType::HAVE_MORE_OUTPUT;
651652
}
652-
ExecuteDelayed(context, delayed, input, output, gstate_p, state_p);
653+
ExecuteDelayed(context, delayed, input, output, gstate_p);
653654
}
654655

655656
return OperatorFinalizeResultType::FINISHED;

src/duckdb/src/execution/operator/persistent/physical_merge_into.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -473,10 +473,17 @@ SourceResultType PhysicalMergeInto::GetData(ExecutionContext &context, DataChunk
473473
// no action to scan from
474474
continue;
475475
}
476+
// found a good one
477+
break;
478+
}
479+
if (lstate.index < actions.size()) {
480+
auto &action = *actions[lstate.index];
481+
476482
auto &child_gstate = *gstate.global_states[lstate.index];
477483
auto &child_lstate = *lstate.local_states[lstate.index];
478484
OperatorSourceInput source_input {child_gstate, child_lstate, input.interrupt_state};
479485

486+
lstate.scan_chunk.Reset();
480487
auto result = action.op->GetData(context, lstate.scan_chunk, source_input);
481488
if (lstate.scan_chunk.size() > 0) {
482489
// construct the result chunk
@@ -505,9 +512,13 @@ SourceResultType PhysicalMergeInto::GetData(ExecutionContext &context, DataChunk
505512

506513
if (result != SourceResultType::FINISHED) {
507514
return result;
508-
}
509-
if (chunk.size() != 0) {
510-
return SourceResultType::HAVE_MORE_OUTPUT;
515+
} else {
516+
lstate.index++;
517+
if (lstate.index < actions.size()) {
518+
return SourceResultType::HAVE_MORE_OUTPUT;
519+
} else {
520+
return SourceResultType::FINISHED;
521+
}
511522
}
512523
}
513524
return SourceResultType::FINISHED;

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 "4-dev34"
2+
#define DUCKDB_PATCH_VERSION "4-dev55"
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.4-dev34"
11+
#define DUCKDB_VERSION "v1.4.4-dev55"
1212
#endif
1313
#ifndef DUCKDB_SOURCE_ID
14-
#define DUCKDB_SOURCE_ID "6e4e3391db"
14+
#define DUCKDB_SOURCE_ID "7f217607e4"
1515
#endif
1616
#include "duckdb/function/table/system_functions.hpp"
1717
#include "duckdb/main/database.hpp"

src/duckdb/src/include/duckdb/execution/operator/aggregate/physical_streaming_window.hpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ class PhysicalStreamingWindow : public PhysicalOperator {
3030

3131
public:
3232
unique_ptr<GlobalOperatorState> GetGlobalOperatorState(ClientContext &context) const override;
33-
unique_ptr<OperatorState> GetOperatorState(ExecutionContext &context) const override;
3433

3534
OperatorResultType Execute(ExecutionContext &context, DataChunk &input, DataChunk &chunk,
3635
GlobalOperatorState &gstate, OperatorState &state) const override;
@@ -50,13 +49,13 @@ class PhysicalStreamingWindow : public PhysicalOperator {
5049

5150
private:
5251
void ExecuteFunctions(ExecutionContext &context, DataChunk &chunk, DataChunk &delayed,
53-
GlobalOperatorState &gstate_p, OperatorState &state_p) const;
52+
GlobalOperatorState &gstate_p) const;
5453
void ExecuteInput(ExecutionContext &context, DataChunk &delayed, DataChunk &input, DataChunk &chunk,
55-
GlobalOperatorState &gstate, OperatorState &state) const;
54+
GlobalOperatorState &gstate) const;
5655
void ExecuteDelayed(ExecutionContext &context, DataChunk &delayed, DataChunk &input, DataChunk &chunk,
57-
GlobalOperatorState &gstate, OperatorState &state) const;
56+
GlobalOperatorState &gstate) const;
5857
void ExecuteShifted(ExecutionContext &context, DataChunk &delayed, DataChunk &input, DataChunk &chunk,
59-
GlobalOperatorState &gstate, OperatorState &state) const;
58+
GlobalOperatorState &gstate) const;
6059
};
6160

6261
} // namespace duckdb

0 commit comments

Comments
 (0)