diff --git a/script/testing/junit/traces/nested-query.test b/script/testing/junit/traces/nested-query.test index e69dfdcec3..08e80f2807 100644 --- a/script/testing/junit/traces/nested-query.test +++ b/script/testing/junit/traces/nested-query.test @@ -307,6 +307,30 @@ SELECT sno FROM supplier WHERE sno >= (SELECT MIN(shipment.sno) FROM shipment IN ---- 1 values hashing to 1dcca23355272056f04fe8bf20edfce0 +query IIIT nosort +SELECT * FROM shipment WHERE pno IN (SELECT pno FROM part ORDER BY pno LIMIT 2); +---- +1 +1 +1 +item_11 +2 +1 +1 +item_11 +3 +1 +1 +item_11 +2 +1 +2 +item_12 +3 +1 +3 +item_13 + statement ok diff --git a/src/optimizer/child_property_deriver.cpp b/src/optimizer/child_property_deriver.cpp index f36f3fa61c..51cf29e61e 100644 --- a/src/optimizer/child_property_deriver.cpp +++ b/src/optimizer/child_property_deriver.cpp @@ -93,9 +93,15 @@ void ChildPropertyDeriver::Visit(const Limit *op) { // Limit fulfill the internal sort property std::vector child_input_properties{new PropertySet()}; auto provided_prop = new PropertySet(); - if (!op->GetSortExpressions().empty()) { - const std::vector> &exprs = op->GetSortExpressions(); - const std::vector &sorts{op->GetSortAscending()}; + auto sort_prop = requirements_->GetPropertyOfTypeAs(PropertyType::SORT); + if (sort_prop != nullptr) { + std::vector> exprs; + std::vector sorts; + auto sort_col_size = sort_prop->GetSortColumnSize(); + for (size_t idx = 0; idx < sort_col_size; idx++) { + exprs.push_back(sort_prop->GetSortColumn(idx)); + sorts.push_back(sort_prop->GetSortAscending(idx)); + } provided_prop->AddProperty(new PropertySort(exprs, sorts)); }