Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/include/planner/operator/schema.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,10 @@ class FactorizationGroup {
double getMultiplier() const { return cardinalityMultiplier; }

void insertExpression(const std::shared_ptr<binder::Expression>& expression) {
DASSERT(!expressionNameToPos.contains(expression->getUniqueName()));
expressionNameToPos.insert({expression->getUniqueName(), expressions.size()});
// A projection keeps out-of-scope expressions in their groups, so one with the same unique
// name may already be here, e.g. an ORDER BY key a WITH dropped. The new expression gets
// its own position: the old one's is still written by the operator that produced it.
expressionNameToPos.insert_or_assign(expression->getUniqueName(), expressions.size());
expressions.push_back(expression);
}
binder::expression_vector getExpressions() const { return expressions; }
Expand Down
21 changes: 21 additions & 0 deletions test/test_files/order_by/order_by_key_repeated.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
-DATASET CSV empty

--

-CASE ProjectionRepeatsDiscardedOrderByKey
-LOOP i 1 2000
-STATEMENT UNWIND [10, 20, NULL, 5] AS x WITH x ORDER BY x + x SKIP 0 RETURN x + x AS y
-CHECK_ORDER
---- 4
10
20
40

-STATEMENT UNWIND [10, 20, NULL, 5] AS x WITH x ORDER BY x * x SKIP 0 RETURN x * x AS y
-CHECK_ORDER
---- 4
25
100
400

-ENDLOOP
Loading