You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2023/01/03 15:24:55 UTC

[GitHub] [doris] xiaokang commented on a diff in pull request #15558: [Improvement](topn) runtime prune for topn query

xiaokang commented on code in PR #15558:
URL: https://github.com/apache/doris/pull/15558#discussion_r1060690642


##########
be/src/vec/exec/vsort_node.cpp:
##########
@@ -123,6 +126,33 @@ Status VSortNode::open(RuntimeState* state) {
                                   _children[0], std::placeholders::_1, std::placeholders::_2,
                                   std::placeholders::_3)),
                 child(0)->get_next_span(), eos);
+
+        if (upstream_block->rows() != 0) {
+            RETURN_IF_ERROR(_sorter->append_block(upstream_block.get()));
+            RETURN_IF_CANCELLED(state);
+            RETURN_IF_ERROR(state->check_query_state("vsort, while sorting input."));
+
+            // runtime predicate
+            // SCOPED_TIMER(_update_runtime_predicate_timer);
+            if (_use_topn_opt) {
+                Field new_top = _sorter->get_top_value();
+                if (!new_top.is_null() && new_top != old_top) {
+                    auto & sort_description = _sorter->get_sort_description();
+                    auto col = upstream_block->get_by_position(sort_description[0].column_number);
+                    auto type = remove_nullable(col.type)->get_type_id();
+                    bool is_reverse = sort_description[0].direction < 0;
+                    auto query_ctx = _runtime_state->get_query_fragments_ctx();
+                    std::vector<vectorized::Field> values = {new_top};

Review Comment:
   Using vector is for further processing for multiple sort columns in query like `ORDER BY a, b LIMIT n`. But now only values[0] is used.
   
   After more consideration, I think only the first column can be used for push down even for multiple sort columns. So I will change the vector to a single value.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org