Github user shixuan-fan commented on a diff in the pull request: https://github.com/apache/incubator-quickstep/pull/39#discussion_r68454552 --- Diff: query_optimizer/resolver/Resolver.cpp --- @@ -1684,13 +1857,45 @@ L::LogicalPtr Resolver::resolveJoinedTableReference( THROW_SQL_ERROR_AT(&joined_table_reference) << "Full outer join is not supported yet"; } +L::LogicalPtr Resolver::resolveSortInWindow( + const L::LogicalPtr &logical_plan, + const E::WindowInfo &window_info) { + // Sort the table by (p_key, o_key) + std::vector<E::AttributeReferencePtr> sort_attributes(window_info.partition_by_attributes); + sort_attributes.insert(sort_attributes.end(), + window_info.order_by_attributes.begin(), + window_info.order_by_attributes.end()); + + std::vector<bool> sort_directions( + window_info.partition_by_attributes.size(), true); + sort_directions.insert(sort_directions.end(), + window_info.order_by_directions.begin(), + window_info.order_by_directions.end()); + + std::vector<bool> sort_nulls_first( + window_info.partition_by_attributes.size(), false); + sort_nulls_first.insert(sort_nulls_first.end(), + window_info.nulls_first.begin(), + window_info.nulls_first.end()); + + L::LogicalPtr sorted_logical_plan = + L::Sort::Create(logical_plan, + sort_attributes, + sort_directions, + sort_nulls_first, --- End diff -- In `quickstep::optimizer::logical::Sort::Create`, the argument is passed by const lvalue reference. So I just followed the code written before in this file.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---