Skip to content

Commit

Permalink
Add extra order condition to test
Browse files Browse the repository at this point in the history
  • Loading branch information
Mytherin committed Oct 17, 2024
1 parent 147cf95 commit dca9938
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 68 deletions.
38 changes: 0 additions & 38 deletions src/common/vector_operations/is_distinct_from.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,16 +502,6 @@ idx_t PositionComparator::Final<duckdb::DistinctLessThan>(Vector &left, Vector &
return VectorOperations::DistinctGreaterThan(right, left, &sel, count, true_sel, false_sel, null_mask);
}

template <>
idx_t PositionComparator::Final<duckdb::DistinctLessThanNullsFirst>(Vector &left, Vector &right,
const SelectionVector &sel, idx_t count,
optional_ptr<SelectionVector> true_sel,
optional_ptr<SelectionVector> false_sel,
optional_ptr<ValidityMask> null_mask) {
// DistinctGreaterThan has NULLs last
return VectorOperations::DistinctGreaterThan(right, left, &sel, count, true_sel, false_sel, null_mask);
}

template <>
idx_t PositionComparator::Final<duckdb::DistinctGreaterThan>(Vector &left, Vector &right, const SelectionVector &sel,
idx_t count, optional_ptr<SelectionVector> true_sel,
Expand All @@ -520,16 +510,6 @@ idx_t PositionComparator::Final<duckdb::DistinctGreaterThan>(Vector &left, Vecto
return VectorOperations::DistinctGreaterThan(left, right, &sel, count, true_sel, false_sel, null_mask);
}

template <>
idx_t PositionComparator::Final<duckdb::DistinctGreaterThanNullsFirst>(Vector &left, Vector &right,
const SelectionVector &sel, idx_t count,
optional_ptr<SelectionVector> true_sel,
optional_ptr<SelectionVector> false_sel,
optional_ptr<ValidityMask> null_mask) {
// DistinctLessThan has NULLs last
return VectorOperations::DistinctLessThan(right, left, &sel, count, true_sel, false_sel, null_mask);
}

using StructEntries = vector<unique_ptr<Vector>>;

static void ExtractNestedSelection(const SelectionVector &slice_sel, const idx_t count, const SelectionVector &sel,
Expand Down Expand Up @@ -1198,15 +1178,6 @@ idx_t VectorOperations::DistinctGreaterThan(Vector &left, Vector &right, optiona
null_mask);
}

// true := A > B with nulls being minimal
idx_t VectorOperations::DistinctGreaterThanNullsFirst(Vector &left, Vector &right,
optional_ptr<const SelectionVector> sel, idx_t count,
optional_ptr<SelectionVector> true_sel,
optional_ptr<SelectionVector> false_sel,
optional_ptr<ValidityMask> null_mask) {
return TemplatedDistinctSelectOperation<duckdb::DistinctGreaterThanNullsFirst>(left, right, sel, count, true_sel,
false_sel, null_mask);
}
// true := A >= B with nulls being maximal
idx_t VectorOperations::DistinctGreaterThanEquals(Vector &left, Vector &right, optional_ptr<const SelectionVector> sel,
idx_t count, optional_ptr<SelectionVector> true_sel,
Expand All @@ -1224,15 +1195,6 @@ idx_t VectorOperations::DistinctLessThan(Vector &left, Vector &right, optional_p
null_mask);
}

// true := A < B with nulls being minimal
idx_t VectorOperations::DistinctLessThanNullsFirst(Vector &left, Vector &right, optional_ptr<const SelectionVector> sel,
idx_t count, optional_ptr<SelectionVector> true_sel,
optional_ptr<SelectionVector> false_sel,
optional_ptr<ValidityMask> null_mask) {
return TemplatedDistinctSelectOperation<duckdb::DistinctGreaterThanNullsFirst>(right, left, sel, count, true_sel,
false_sel, nullptr);
}

// true := A <= B with nulls being maximal
idx_t VectorOperations::DistinctLessThanEquals(Vector &left, Vector &right, optional_ptr<const SelectionVector> sel,
idx_t count, optional_ptr<SelectionVector> true_sel,
Expand Down
8 changes: 4 additions & 4 deletions src/execution/operator/order/physical_top_n.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@ class TopNHeap {
return MaxValue<idx_t>(STANDARD_VECTOR_SIZE * 5ULL, 2ULL * heap_size);
}

idx_t MaxHeapSize() const {
return ReduceThreshold() + STANDARD_VECTOR_SIZE;
idx_t HeapAllocSize() const {
return MinValue<idx_t>(STANDARD_VECTOR_SIZE * 100ULL, ReduceThreshold()) + STANDARD_VECTOR_SIZE;
}
};

Expand All @@ -117,7 +117,7 @@ TopNHeap::TopNHeap(ClientContext &context, Allocator &allocator, const vector<Lo
}
vector<LogicalType> sort_keys_type {LogicalType::BLOB};
sort_keys.Initialize(allocator, sort_keys_type);
heap_data.Initialize(allocator, payload_types, MaxHeapSize());
heap_data.Initialize(allocator, payload_types, HeapAllocSize());
payload_chunk.Initialize(allocator, payload_types);
sort_chunk.Initialize(allocator, sort_types);
}
Expand Down Expand Up @@ -243,7 +243,7 @@ void TopNHeap::Reduce() {
// we have too many values in the heap - reduce them
StringHeap new_sort_heap;
DataChunk new_payload_chunk;
new_payload_chunk.Initialize(allocator, payload_types, MaxHeapSize());
new_payload_chunk.Initialize(allocator, payload_types, HeapAllocSize());

SelectionVector new_payload_sel(heap.size());
for (idx_t i = 0; i < heap.size(); i++) {
Expand Down
14 changes: 0 additions & 14 deletions src/include/duckdb/common/operator/comparison_operators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,6 @@ struct DistinctGreaterThan {
}
};

struct DistinctGreaterThanNullsFirst {
template <class T>
static inline bool Operation(const T &left, const T &right, bool left_null, bool right_null) {
return DistinctGreaterThan::Operation(left, right, right_null, left_null);
}
};

struct DistinctGreaterThanEquals {
template <class T>
static inline bool Operation(const T &left, const T &right, bool left_null, bool right_null) {
Expand All @@ -128,13 +121,6 @@ struct DistinctLessThan {
}
};

struct DistinctLessThanNullsFirst {
template <class T>
static inline bool Operation(const T &left, const T &right, bool left_null, bool right_null) {
return DistinctGreaterThan::Operation(right, left, left_null, right_null);
}
};

struct DistinctLessThanEquals {
template <class T>
static inline bool Operation(const T &left, const T &right, bool left_null, bool right_null) {
Expand Down
11 changes: 0 additions & 11 deletions src/include/duckdb/common/vector_operations/vector_operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,6 @@ struct VectorOperations {
optional_ptr<SelectionVector> false_sel,
optional_ptr<ValidityMask> null_mask = nullptr);

// true := A > B with nulls being minimal
static idx_t DistinctGreaterThanNullsFirst(Vector &left, Vector &right, optional_ptr<const SelectionVector> sel,
idx_t count, optional_ptr<SelectionVector> true_sel,
optional_ptr<SelectionVector> false_sel,
optional_ptr<ValidityMask> null_mask = nullptr);
// true := A < B with nulls being minimal
static idx_t DistinctLessThanNullsFirst(Vector &left, Vector &right, optional_ptr<const SelectionVector> sel,
idx_t count, optional_ptr<SelectionVector> true_sel,
optional_ptr<SelectionVector> false_sel,
optional_ptr<ValidityMask> null_mask = nullptr);

//===--------------------------------------------------------------------===//
// Nested Comparisons
//===--------------------------------------------------------------------===//
Expand Down
2 changes: 1 addition & 1 deletion test/sql/pivot/pivot_example.test
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,6 @@ UNPIVOT PivotedCities ON 2000, 2010, 2020 ORDER BY ALL LIMIT 1
NL Amsterdam 2000 1005

query IIII
UNPIVOT PivotedCities ON 2000, 2010, 2020 ORDER BY 1 LIMIT 1 OFFSET 1
UNPIVOT PivotedCities ON 2000, 2010, 2020 ORDER BY 1, 3 LIMIT 1 OFFSET 1
----
NL Amsterdam 2010 1065

0 comments on commit dca9938

Please sign in to comment.