duckdb 0.7.2-dev333.0 → 0.7.2-dev457.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/binding.gyp +1 -0
- package/lib/duckdb.d.ts +42 -0
- package/package.json +1 -1
- package/src/connection.cpp +1 -2
- package/src/database.cpp +1 -1
- package/src/duckdb/extension/icu/icu-extension.cpp +2 -0
- package/src/duckdb/extension/icu/icu-list-range.cpp +207 -0
- package/src/duckdb/extension/icu/include/icu-list-range.hpp +17 -0
- package/src/duckdb/extension/json/json_functions/read_json.cpp +6 -5
- package/src/duckdb/extension/parquet/include/parquet_timestamp.hpp +0 -1
- package/src/duckdb/extension/parquet/parquet_timestamp.cpp +8 -6
- package/src/duckdb/src/common/exception.cpp +15 -1
- package/src/duckdb/src/common/preserved_error.cpp +7 -5
- package/src/duckdb/src/execution/operator/scan/physical_positional_scan.cpp +20 -5
- package/src/duckdb/src/execution/physical_plan/plan_aggregate.cpp +9 -1
- package/src/duckdb/src/execution/physical_plan/plan_distinct.cpp +5 -8
- package/src/duckdb/src/execution/physical_plan/plan_positional_join.cpp +14 -5
- package/src/duckdb/src/function/aggregate/distributive/bool.cpp +2 -0
- package/src/duckdb/src/function/aggregate/distributive/count.cpp +1 -0
- package/src/duckdb/src/function/aggregate/distributive/minmax.cpp +2 -0
- package/src/duckdb/src/function/aggregate/distributive/sum.cpp +8 -0
- package/src/duckdb/src/function/aggregate/holistic/quantile.cpp +15 -0
- package/src/duckdb/src/function/aggregate/sorted_aggregate_function.cpp +42 -11
- package/src/duckdb/src/function/cast/time_casts.cpp +2 -2
- package/src/duckdb/src/function/function_binder.cpp +1 -8
- package/src/duckdb/src/function/scalar/date/current.cpp +0 -2
- package/src/duckdb/src/function/table/version/pragma_version.cpp +2 -2
- package/src/duckdb/src/include/duckdb/common/exception.hpp +38 -2
- package/src/duckdb/src/include/duckdb/common/preserved_error.hpp +3 -1
- package/src/duckdb/src/include/duckdb/execution/physical_plan_generator.hpp +0 -3
- package/src/duckdb/src/include/duckdb/function/aggregate_function.hpp +6 -3
- package/src/duckdb/src/include/duckdb/function/function_binder.hpp +3 -6
- package/src/duckdb/src/include/duckdb/main/prepared_statement.hpp +2 -0
- package/src/duckdb/src/include/duckdb/main/relation/explain_relation.hpp +2 -1
- package/src/duckdb/src/include/duckdb/main/relation.hpp +2 -1
- package/src/duckdb/src/include/duckdb/optimizer/rule/list.hpp +1 -0
- package/src/duckdb/src/include/duckdb/optimizer/rule/ordered_aggregate_optimizer.hpp +24 -0
- package/src/duckdb/src/include/duckdb/parser/expression/function_expression.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/expression/star_expression.hpp +2 -2
- package/src/duckdb/src/include/duckdb/parser/transformer.hpp +2 -0
- package/src/duckdb/src/include/duckdb/planner/binder.hpp +4 -3
- package/src/duckdb/src/include/duckdb/planner/bound_result_modifier.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression/bound_aggregate_expression.hpp +3 -0
- package/src/duckdb/src/include/duckdb/planner/expression_binder/order_binder.hpp +4 -1
- package/src/duckdb/src/include/duckdb/planner/operator/logical_distinct.hpp +3 -0
- package/src/duckdb/src/main/extension/extension_install.cpp +2 -2
- package/src/duckdb/src/main/prepared_statement.cpp +4 -0
- package/src/duckdb/src/main/relation/explain_relation.cpp +3 -3
- package/src/duckdb/src/main/relation.cpp +3 -2
- package/src/duckdb/src/optimizer/optimizer.cpp +1 -0
- package/src/duckdb/src/optimizer/rule/ordered_aggregate_optimizer.cpp +30 -0
- package/src/duckdb/src/parser/expression/star_expression.cpp +6 -6
- package/src/duckdb/src/parser/parsed_expression_iterator.cpp +7 -1
- package/src/duckdb/src/parser/transform/expression/transform_columnref.cpp +17 -2
- package/src/duckdb/src/parser/transform/expression/transform_function.cpp +45 -40
- package/src/duckdb/src/parser/transform/helpers/transform_groupby.cpp +7 -0
- package/src/duckdb/src/parser/transform/helpers/transform_orderby.cpp +0 -7
- package/src/duckdb/src/planner/bind_context.cpp +2 -25
- package/src/duckdb/src/planner/binder/expression/bind_aggregate_expression.cpp +6 -4
- package/src/duckdb/src/planner/binder/expression/bind_lambda.cpp +3 -2
- package/src/duckdb/src/planner/binder/expression/bind_star_expression.cpp +176 -0
- package/src/duckdb/src/planner/binder/query_node/bind_select_node.cpp +57 -82
- package/src/duckdb/src/planner/binder/query_node/plan_query_node.cpp +11 -0
- package/src/duckdb/src/planner/binder/statement/bind_delete.cpp +1 -1
- package/src/duckdb/src/planner/binder/statement/bind_insert.cpp +2 -2
- package/src/duckdb/src/planner/binder/statement/bind_update.cpp +1 -1
- package/src/duckdb/src/planner/binder.cpp +12 -23
- package/src/duckdb/src/planner/bound_result_modifier.cpp +26 -0
- package/src/duckdb/src/planner/expression/bound_aggregate_expression.cpp +9 -2
- package/src/duckdb/src/planner/expression_iterator.cpp +5 -0
- package/src/duckdb/src/planner/logical_operator_visitor.cpp +5 -0
- package/src/duckdb/src/planner/operator/logical_distinct.cpp +3 -0
- package/src/duckdb/src/storage/storage_info.cpp +1 -1
- package/src/duckdb/third_party/libpg_query/include/nodes/parsenodes.hpp +1 -1
- package/src/duckdb/third_party/libpg_query/src_backend_parser_gram.cpp +8141 -8313
- package/src/duckdb/ub_src_optimizer_rule.cpp +2 -0
- package/src/duckdb/ub_src_planner_binder_expression.cpp +2 -0
- package/src/duckdb_node.hpp +2 -1
- package/src/statement.cpp +5 -5
- package/src/utils.cpp +15 -2
- package/test/syntax_error.test.ts +3 -1
@@ -19,8 +19,7 @@
|
|
19
19
|
#include "duckdb/planner/expression_binder/select_binder.hpp"
|
20
20
|
#include "duckdb/planner/expression_binder/where_binder.hpp"
|
21
21
|
#include "duckdb/planner/query_node/bound_select_node.hpp"
|
22
|
-
#include "duckdb/
|
23
|
-
#include "duckdb/parser/parsed_expression_iterator.hpp"
|
22
|
+
#include "duckdb/parser/expression/conjunction_expression.hpp"
|
24
23
|
|
25
24
|
namespace duckdb {
|
26
25
|
|
@@ -136,31 +135,39 @@ void Binder::BindModifiers(OrderBinder &order_binder, QueryNode &statement, Boun
|
|
136
135
|
auto bound_order = make_unique<BoundOrderModifier>();
|
137
136
|
auto &config = DBConfig::GetConfig(context);
|
138
137
|
D_ASSERT(!order.orders.empty());
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
new_orders
|
149
|
-
|
138
|
+
auto &order_binders = order_binder.GetBinders();
|
139
|
+
if (order.orders.size() == 1 && order.orders[0].expression->type == ExpressionType::STAR) {
|
140
|
+
auto star = (StarExpression *)order.orders[0].expression.get();
|
141
|
+
if (star->exclude_list.empty() && star->replace_list.empty() && !star->expr) {
|
142
|
+
// ORDER BY ALL
|
143
|
+
// replace the order list with the all elements in the SELECT list
|
144
|
+
auto order_type = order.orders[0].type;
|
145
|
+
auto null_order = order.orders[0].null_order;
|
146
|
+
|
147
|
+
vector<OrderByNode> new_orders;
|
148
|
+
for (idx_t i = 0; i < order_binder.MaxCount(); i++) {
|
149
|
+
new_orders.emplace_back(order_type, null_order,
|
150
|
+
make_unique<ConstantExpression>(Value::INTEGER(i + 1)));
|
151
|
+
}
|
152
|
+
order.orders = std::move(new_orders);
|
150
153
|
}
|
151
|
-
order.orders = std::move(new_orders);
|
152
154
|
}
|
153
155
|
for (auto &order_node : order.orders) {
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
}
|
156
|
+
vector<unique_ptr<ParsedExpression>> order_list;
|
157
|
+
order_binders[0]->ExpandStarExpression(std::move(order_node.expression), order_list);
|
158
|
+
|
158
159
|
auto type =
|
159
160
|
order_node.type == OrderType::ORDER_DEFAULT ? config.options.default_order_type : order_node.type;
|
160
161
|
auto null_order = order_node.null_order == OrderByNullType::ORDER_DEFAULT
|
161
162
|
? config.options.default_null_order
|
162
163
|
: order_node.null_order;
|
163
|
-
|
164
|
+
for (auto &order_expr : order_list) {
|
165
|
+
auto bound_expr = BindOrderExpression(order_binder, std::move(order_expr));
|
166
|
+
if (!bound_expr) {
|
167
|
+
continue;
|
168
|
+
}
|
169
|
+
bound_order->orders.emplace_back(type, null_order, std::move(bound_expr));
|
170
|
+
}
|
164
171
|
}
|
165
172
|
if (!bound_order->orders.empty()) {
|
166
173
|
bound_modifier = std::move(bound_order);
|
@@ -264,69 +271,6 @@ void Binder::BindModifierTypes(BoundQueryNode &result, const vector<LogicalType>
|
|
264
271
|
}
|
265
272
|
}
|
266
273
|
|
267
|
-
bool Binder::FindStarExpression(ParsedExpression &expr, StarExpression **star) {
|
268
|
-
if (expr.GetExpressionClass() == ExpressionClass::STAR) {
|
269
|
-
auto current_star = (StarExpression *)&expr;
|
270
|
-
if (*star) {
|
271
|
-
// we can have multiple
|
272
|
-
if (!StarExpression::Equal(*star, current_star)) {
|
273
|
-
throw BinderException(
|
274
|
-
FormatError(expr, "Multiple different STAR/COLUMNS in the same expression are not supported"));
|
275
|
-
}
|
276
|
-
return true;
|
277
|
-
}
|
278
|
-
*star = current_star;
|
279
|
-
return true;
|
280
|
-
}
|
281
|
-
bool has_star = false;
|
282
|
-
ParsedExpressionIterator::EnumerateChildren(expr, [&](ParsedExpression &child_expr) {
|
283
|
-
if (FindStarExpression(child_expr, star)) {
|
284
|
-
has_star = true;
|
285
|
-
}
|
286
|
-
});
|
287
|
-
return has_star;
|
288
|
-
}
|
289
|
-
|
290
|
-
void Binder::ReplaceStarExpression(unique_ptr<ParsedExpression> &expr, unique_ptr<ParsedExpression> &replacement) {
|
291
|
-
D_ASSERT(expr);
|
292
|
-
if (expr->GetExpressionClass() == ExpressionClass::STAR) {
|
293
|
-
D_ASSERT(replacement);
|
294
|
-
expr = replacement->Copy();
|
295
|
-
return;
|
296
|
-
}
|
297
|
-
ParsedExpressionIterator::EnumerateChildren(
|
298
|
-
*expr, [&](unique_ptr<ParsedExpression> &child_expr) { ReplaceStarExpression(child_expr, replacement); });
|
299
|
-
}
|
300
|
-
|
301
|
-
void Binder::ExpandStarExpression(unique_ptr<ParsedExpression> expr,
|
302
|
-
vector<unique_ptr<ParsedExpression>> &new_select_list) {
|
303
|
-
StarExpression *star = nullptr;
|
304
|
-
if (!FindStarExpression(*expr, &star)) {
|
305
|
-
// no star expression: add it as-is
|
306
|
-
D_ASSERT(!star);
|
307
|
-
new_select_list.push_back(std::move(expr));
|
308
|
-
return;
|
309
|
-
}
|
310
|
-
D_ASSERT(star);
|
311
|
-
vector<unique_ptr<ParsedExpression>> star_list;
|
312
|
-
// we have star expressions! expand the list of star expressions
|
313
|
-
bind_context.GenerateAllColumnExpressions(*star, star_list);
|
314
|
-
|
315
|
-
// now perform the replacement
|
316
|
-
for (idx_t i = 0; i < star_list.size(); i++) {
|
317
|
-
auto new_expr = expr->Copy();
|
318
|
-
ReplaceStarExpression(new_expr, star_list[i]);
|
319
|
-
new_select_list.push_back(std::move(new_expr));
|
320
|
-
}
|
321
|
-
}
|
322
|
-
|
323
|
-
void Binder::ExpandStarExpressions(vector<unique_ptr<ParsedExpression>> &select_list,
|
324
|
-
vector<unique_ptr<ParsedExpression>> &new_select_list) {
|
325
|
-
for (auto &select_element : select_list) {
|
326
|
-
ExpandStarExpression(std::move(select_element), new_select_list);
|
327
|
-
}
|
328
|
-
}
|
329
|
-
|
330
274
|
unique_ptr<BoundQueryNode> Binder::BindNode(SelectNode &statement) {
|
331
275
|
D_ASSERT(statement.from_table);
|
332
276
|
// first bind the FROM table statement
|
@@ -335,6 +279,34 @@ unique_ptr<BoundQueryNode> Binder::BindNode(SelectNode &statement) {
|
|
335
279
|
return BindSelectNode(statement, std::move(from_table));
|
336
280
|
}
|
337
281
|
|
282
|
+
void Binder::BindWhereStarExpression(unique_ptr<ParsedExpression> &expr) {
|
283
|
+
// expand any expressions in the upper AND recursively
|
284
|
+
if (expr->type == ExpressionType::CONJUNCTION_AND) {
|
285
|
+
auto &conj = (ConjunctionExpression &)*expr;
|
286
|
+
for (auto &child : conj.children) {
|
287
|
+
BindWhereStarExpression(child);
|
288
|
+
}
|
289
|
+
return;
|
290
|
+
}
|
291
|
+
if (expr->type == ExpressionType::STAR) {
|
292
|
+
auto &star = (StarExpression &)*expr;
|
293
|
+
if (!star.columns) {
|
294
|
+
throw ParserException("STAR expression is not allowed in the WHERE clause. Use COLUMNS(*) instead.");
|
295
|
+
}
|
296
|
+
}
|
297
|
+
// expand the stars for this expression
|
298
|
+
vector<unique_ptr<ParsedExpression>> new_conditions;
|
299
|
+
ExpandStarExpression(std::move(expr), new_conditions);
|
300
|
+
|
301
|
+
// set up an AND conjunction between the expanded conditions
|
302
|
+
expr = std::move(new_conditions[0]);
|
303
|
+
for (idx_t i = 1; i < new_conditions.size(); i++) {
|
304
|
+
auto and_conj = make_unique<ConjunctionExpression>(ExpressionType::CONJUNCTION_AND, std::move(expr),
|
305
|
+
std::move(new_conditions[i]));
|
306
|
+
expr = std::move(and_conj);
|
307
|
+
}
|
308
|
+
}
|
309
|
+
|
338
310
|
unique_ptr<BoundQueryNode> Binder::BindSelectNode(SelectNode &statement, unique_ptr<BoundTableRef> from_table) {
|
339
311
|
D_ASSERT(from_table);
|
340
312
|
D_ASSERT(!statement.from_table);
|
@@ -381,6 +353,9 @@ unique_ptr<BoundQueryNode> Binder::BindSelectNode(SelectNode &statement, unique_
|
|
381
353
|
// first visit the WHERE clause
|
382
354
|
// the WHERE clause happens before the GROUP BY, PROJECTION or HAVING clauses
|
383
355
|
if (statement.where_clause) {
|
356
|
+
// bind any star expressions in the WHERE clause
|
357
|
+
BindWhereStarExpression(statement.where_clause);
|
358
|
+
|
384
359
|
ColumnAliasBinder alias_binder(*result, alias_map);
|
385
360
|
WhereBinder where_binder(*this, context, &alias_binder);
|
386
361
|
unique_ptr<ParsedExpression> condition = std::move(statement.where_clause);
|
@@ -4,6 +4,7 @@
|
|
4
4
|
#include "duckdb/planner/operator/logical_limit.hpp"
|
5
5
|
#include "duckdb/planner/operator/logical_limit_percent.hpp"
|
6
6
|
#include "duckdb/planner/operator/logical_order.hpp"
|
7
|
+
#include "duckdb/planner/bound_result_modifier.hpp"
|
7
8
|
|
8
9
|
namespace duckdb {
|
9
10
|
|
@@ -20,6 +21,16 @@ unique_ptr<LogicalOperator> Binder::VisitQueryNode(BoundQueryNode &node, unique_
|
|
20
21
|
}
|
21
22
|
case ResultModifierType::ORDER_MODIFIER: {
|
22
23
|
auto &bound = (BoundOrderModifier &)*mod;
|
24
|
+
if (root->type == LogicalOperatorType::LOGICAL_DISTINCT) {
|
25
|
+
auto &distinct = (LogicalDistinct &)*root;
|
26
|
+
if (!distinct.distinct_targets.empty()) {
|
27
|
+
auto order_by = make_unique<BoundOrderModifier>();
|
28
|
+
for (auto &order_node : bound.orders) {
|
29
|
+
order_by->orders.push_back(order_node.Copy());
|
30
|
+
}
|
31
|
+
distinct.order_by = std::move(order_by);
|
32
|
+
}
|
33
|
+
}
|
23
34
|
auto order = make_unique<LogicalOrder>(std::move(bound.orders));
|
24
35
|
order->AddChild(std::move(root));
|
25
36
|
root = std::move(order);
|
@@ -83,7 +83,7 @@ BoundStatement Binder::Bind(DeleteStatement &stmt) {
|
|
83
83
|
del->table_index = update_table_index;
|
84
84
|
|
85
85
|
unique_ptr<LogicalOperator> del_as_logicaloperator = std::move(del);
|
86
|
-
return BindReturning(std::move(stmt.returning_list), table, update_table_index,
|
86
|
+
return BindReturning(std::move(stmt.returning_list), table, stmt.table->alias, update_table_index,
|
87
87
|
std::move(del_as_logicaloperator), std::move(result));
|
88
88
|
}
|
89
89
|
result.plan = std::move(del);
|
@@ -505,8 +505,8 @@ BoundStatement Binder::Bind(InsertStatement &stmt) {
|
|
505
505
|
insert->table_index = insert_table_index;
|
506
506
|
unique_ptr<LogicalOperator> index_as_logicaloperator = std::move(insert);
|
507
507
|
|
508
|
-
return BindReturning(std::move(stmt.returning_list), table,
|
509
|
-
std::move(index_as_logicaloperator), std::move(result));
|
508
|
+
return BindReturning(std::move(stmt.returning_list), table, stmt.table_ref ? stmt.table_ref->alias : string(),
|
509
|
+
insert_table_index, std::move(index_as_logicaloperator), std::move(result));
|
510
510
|
}
|
511
511
|
|
512
512
|
D_ASSERT(result.types.size() == result.names.size());
|
@@ -251,7 +251,7 @@ BoundStatement Binder::Bind(UpdateStatement &stmt) {
|
|
251
251
|
if (!stmt.returning_list.empty()) {
|
252
252
|
unique_ptr<LogicalOperator> update_as_logicaloperator = std::move(update);
|
253
253
|
|
254
|
-
return BindReturning(std::move(stmt.returning_list), table, update_table_index,
|
254
|
+
return BindReturning(std::move(stmt.returning_list), table, stmt.table->alias, update_table_index,
|
255
255
|
std::move(update_as_logicaloperator), std::move(result));
|
256
256
|
}
|
257
257
|
|
@@ -438,8 +438,8 @@ void VerifyNotExcluded(ParsedExpression &expr) {
|
|
438
438
|
}
|
439
439
|
|
440
440
|
BoundStatement Binder::BindReturning(vector<unique_ptr<ParsedExpression>> returning_list, TableCatalogEntry *table,
|
441
|
-
|
442
|
-
BoundStatement result) {
|
441
|
+
const string &alias, idx_t update_table_index,
|
442
|
+
unique_ptr<LogicalOperator> child_operator, BoundStatement result) {
|
443
443
|
|
444
444
|
vector<LogicalType> types;
|
445
445
|
vector<std::string> names;
|
@@ -457,31 +457,20 @@ BoundStatement Binder::BindReturning(vector<unique_ptr<ParsedExpression>> return
|
|
457
457
|
column_count++;
|
458
458
|
}
|
459
459
|
|
460
|
-
binder->bind_context.AddBaseTable(update_table_index, table->name, names, types,
|
460
|
+
binder->bind_context.AddBaseTable(update_table_index, alias.empty() ? table->name : alias, names, types,
|
461
|
+
bound_columns, table, false);
|
461
462
|
ReturningBinder returning_binder(*binder, context);
|
462
463
|
|
463
464
|
vector<unique_ptr<Expression>> projection_expressions;
|
464
465
|
LogicalType result_type;
|
465
|
-
|
466
|
-
|
467
|
-
|
468
|
-
|
469
|
-
|
470
|
-
|
471
|
-
|
472
|
-
|
473
|
-
result.types.push_back(result_type);
|
474
|
-
result.names.push_back(star_expr->GetName());
|
475
|
-
projection_expressions.push_back(std::move(star_expr));
|
476
|
-
}
|
477
|
-
} else {
|
478
|
-
// TODO: accept 'excluded' in the RETURNING clause
|
479
|
-
VerifyNotExcluded(*returning_expr);
|
480
|
-
auto expr = returning_binder.Bind(returning_expr, &result_type);
|
481
|
-
result.names.push_back(expr->GetName());
|
482
|
-
result.types.push_back(result_type);
|
483
|
-
projection_expressions.push_back(std::move(expr));
|
484
|
-
}
|
466
|
+
vector<unique_ptr<ParsedExpression>> new_returning_list;
|
467
|
+
binder->ExpandStarExpressions(returning_list, new_returning_list);
|
468
|
+
for (auto &returning_expr : new_returning_list) {
|
469
|
+
VerifyNotExcluded(*returning_expr);
|
470
|
+
auto expr = returning_binder.Bind(returning_expr, &result_type);
|
471
|
+
result.names.push_back(expr->GetName());
|
472
|
+
result.types.push_back(result_type);
|
473
|
+
projection_expressions.push_back(std::move(expr));
|
485
474
|
}
|
486
475
|
|
487
476
|
auto projection = make_unique<LogicalProjection>(GenerateTableIndex(), std::move(projection_expressions));
|
@@ -80,6 +80,32 @@ BoundOrderByNode BoundOrderByNode::Deserialize(Deserializer &source, PlanDeseria
|
|
80
80
|
return BoundOrderByNode(type, null_order, std::move(expression));
|
81
81
|
}
|
82
82
|
|
83
|
+
unique_ptr<BoundOrderModifier> BoundOrderModifier::Copy() const {
|
84
|
+
auto result = make_unique<BoundOrderModifier>();
|
85
|
+
for (auto &order : orders) {
|
86
|
+
result->orders.push_back(order.Copy());
|
87
|
+
}
|
88
|
+
return result;
|
89
|
+
}
|
90
|
+
|
91
|
+
bool BoundOrderModifier::Equals(const BoundOrderModifier *left, const BoundOrderModifier *right) {
|
92
|
+
if (left == right) {
|
93
|
+
return true;
|
94
|
+
}
|
95
|
+
if (!left || !right) {
|
96
|
+
return false;
|
97
|
+
}
|
98
|
+
if (left->orders.size() != right->orders.size()) {
|
99
|
+
return false;
|
100
|
+
}
|
101
|
+
for (idx_t i = 0; i < left->orders.size(); i++) {
|
102
|
+
if (!left->orders[i].Equals(right->orders[i])) {
|
103
|
+
return false;
|
104
|
+
}
|
105
|
+
}
|
106
|
+
return true;
|
107
|
+
}
|
108
|
+
|
83
109
|
BoundLimitModifier::BoundLimitModifier() : BoundResultModifier(ResultModifierType::LIMIT_MODIFIER) {
|
84
110
|
}
|
85
111
|
|
@@ -19,8 +19,8 @@ BoundAggregateExpression::BoundAggregateExpression(AggregateFunction function, v
|
|
19
19
|
}
|
20
20
|
|
21
21
|
string BoundAggregateExpression::ToString() const {
|
22
|
-
return FunctionExpression::ToString<BoundAggregateExpression, Expression
|
23
|
-
|
22
|
+
return FunctionExpression::ToString<BoundAggregateExpression, Expression, BoundOrderModifier>(
|
23
|
+
*this, string(), function.name, false, IsDistinct(), filter.get(), order_bys.get());
|
24
24
|
}
|
25
25
|
|
26
26
|
hash_t BoundAggregateExpression::Hash() const {
|
@@ -55,6 +55,9 @@ bool BoundAggregateExpression::Equals(const BaseExpression *other_p) const {
|
|
55
55
|
if (!FunctionData::Equals(bind_info.get(), other->bind_info.get())) {
|
56
56
|
return false;
|
57
57
|
}
|
58
|
+
if (!BoundOrderModifier::Equals(order_bys.get(), other->order_bys.get())) {
|
59
|
+
return false;
|
60
|
+
}
|
58
61
|
return true;
|
59
62
|
}
|
60
63
|
|
@@ -74,12 +77,16 @@ unique_ptr<Expression> BoundAggregateExpression::Copy() {
|
|
74
77
|
auto copy = make_unique<BoundAggregateExpression>(function, std::move(new_children), std::move(new_filter),
|
75
78
|
std::move(new_bind_info), aggr_type);
|
76
79
|
copy->CopyProperties(*this);
|
80
|
+
copy->order_bys = order_bys ? order_bys->Copy() : nullptr;
|
77
81
|
return std::move(copy);
|
78
82
|
}
|
79
83
|
|
80
84
|
void BoundAggregateExpression::Serialize(FieldWriter &writer) const {
|
81
85
|
writer.WriteField(IsDistinct());
|
82
86
|
writer.WriteOptional(filter);
|
87
|
+
if (order_bys) {
|
88
|
+
throw NotImplementedException("Serialization of ORDER BY aggregate not yet supported");
|
89
|
+
}
|
83
90
|
FunctionSerializer::Serialize<AggregateFunction>(writer, function, return_type, children, bind_info.get());
|
84
91
|
}
|
85
92
|
|
@@ -29,6 +29,11 @@ void ExpressionIterator::EnumerateChildren(Expression &expr,
|
|
29
29
|
if (aggr_expr.filter) {
|
30
30
|
callback(aggr_expr.filter);
|
31
31
|
}
|
32
|
+
if (aggr_expr.order_bys) {
|
33
|
+
for (auto &order : aggr_expr.order_bys->orders) {
|
34
|
+
callback(order.expression);
|
35
|
+
}
|
36
|
+
}
|
32
37
|
break;
|
33
38
|
}
|
34
39
|
case ExpressionClass::BOUND_BETWEEN: {
|
@@ -48,6 +48,11 @@ void LogicalOperatorVisitor::EnumerateExpressions(LogicalOperator &op,
|
|
48
48
|
for (auto &target : distinct.distinct_targets) {
|
49
49
|
callback(&target);
|
50
50
|
}
|
51
|
+
if (distinct.order_by) {
|
52
|
+
for (auto &order : distinct.order_by->orders) {
|
53
|
+
callback(&order.expression);
|
54
|
+
}
|
55
|
+
}
|
51
56
|
break;
|
52
57
|
}
|
53
58
|
case LogicalOperatorType::LOGICAL_INSERT: {
|
@@ -15,6 +15,9 @@ string LogicalDistinct::ParamsToString() const {
|
|
15
15
|
}
|
16
16
|
void LogicalDistinct::Serialize(FieldWriter &writer) const {
|
17
17
|
writer.WriteSerializableList(distinct_targets);
|
18
|
+
if (order_by) {
|
19
|
+
throw NotImplementedException("Serializing ORDER BY not yet supported");
|
20
|
+
}
|
18
21
|
}
|
19
22
|
|
20
23
|
unique_ptr<LogicalOperator> LogicalDistinct::Deserialize(LogicalDeserializationState &state, FieldReader &reader) {
|
@@ -307,7 +307,7 @@ typedef struct PGFuncCall {
|
|
307
307
|
typedef struct PGAStar {
|
308
308
|
PGNodeTag type;
|
309
309
|
char *relation; /* relation name (optional) */
|
310
|
-
|
310
|
+
PGNode *expr; /* optional: the expression (regex or list) to select columns */
|
311
311
|
PGList *except_list; /* optional: EXCLUDE list */
|
312
312
|
PGList *replace_list; /* optional: REPLACE list */
|
313
313
|
bool columns; /* whether or not this is a columns list */
|