You are viewing a plain text version of this content. The canonical link for it is here.
Posted to github@arrow.apache.org by "mustafasrepo (via GitHub)" <gi...@apache.org> on 2023/07/14 13:17:43 UTC

[GitHub] [arrow-datafusion] mustafasrepo opened a new pull request, #6965: [MINOR] Remove global sort rule from planner

mustafasrepo opened a new pull request, #6965:
URL: https://github.com/apache/arrow-datafusion/pull/6965

   # Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. For example `Closes #123` indicates that this PR will close issue #123.
   -->
   
   Closes #.
   
   # Rationale for this change
   With `EnforceSorting` rule, `GlobalSortSelection` is no longer necessary. With minor changes in SortEnforcement rule,
   all of the existing test pass without `GlobalSortSelection` rule.
   <!--
    Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed.
    Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes.  
   -->
   
   # What changes are included in this PR?
   
   <!--
   There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR.
   -->
   
   # Are these changes tested?
   
   <!--
   We typically require tests for all PRs in order to:
   1. Prevent the code from being accidentally broken by subsequent changes
   2. Serve as another way to document the expected behavior of the code
   
   If tests are not included in your PR, please explain why (for example, are they covered by existing tests)?
   -->
   
   # Are there any user-facing changes?
   
   <!--
   If there are user-facing changes then we may require documentation to be updated before approving the PR.
   -->
   
   <!--
   If there are any breaking changes to public APIs, please add the `api change` label.
   -->


-- 
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: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-datafusion] alamb commented on a diff in pull request #6965: [MINOR] Remove global sort rule from planner

Posted by "alamb (via GitHub)" <gi...@apache.org>.
alamb commented on code in PR #6965:
URL: https://github.com/apache/arrow-datafusion/pull/6965#discussion_r1264069846


##########
datafusion/core/src/physical_optimizer/global_sort_selection.rs:
##########
@@ -1,94 +0,0 @@
-// Licensed to the Apache Software Foundation (ASF) under one
-// or more contributor license agreements.  See the NOTICE file
-// distributed with this work for additional information
-// regarding copyright ownership.  The ASF licenses this file
-// to you under the Apache License, Version 2.0 (the
-// "License"); you may not use this file except in compliance
-// with the License.  You may obtain a copy of the License at
-//
-//   http://www.apache.org/licenses/LICENSE-2.0
-//
-// Unless required by applicable law or agreed to in writing,
-// software distributed under the License is distributed on an
-// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-// KIND, either express or implied.  See the License for the
-// specific language governing permissions and limitations
-// under the License.
-
-//! Select the efficient global sort implementation based on sort details.
-
-use std::sync::Arc;
-
-use crate::config::ConfigOptions;
-use crate::error::Result;
-use crate::physical_optimizer::PhysicalOptimizerRule;
-use crate::physical_plan::sorts::sort::SortExec;
-use crate::physical_plan::sorts::sort_preserving_merge::SortPreservingMergeExec;
-use crate::physical_plan::ExecutionPlan;
-use datafusion_common::tree_node::{Transformed, TreeNode};
-
-/// Currently for a sort operator, if
-/// - there are more than one input partitions
-/// - and there's some limit which can be pushed down to each of its input partitions
-/// then [SortPreservingMergeExec] with local sort with a limit pushed down will be preferred;
-/// Otherwise, the normal global sort [SortExec] will be used.
-/// Later more intelligent statistics-based decision can also be introduced.
-/// For example, for a small data set, the global sort may be efficient enough
-#[derive(Default)]
-pub struct GlobalSortSelection {}
-
-impl GlobalSortSelection {
-    #[allow(missing_docs)]
-    pub fn new() -> Self {
-        Self {}
-    }
-}
-
-impl PhysicalOptimizerRule for GlobalSortSelection {
-    fn optimize(
-        &self,
-        plan: Arc<dyn ExecutionPlan>,
-        config: &ConfigOptions,
-    ) -> Result<Arc<dyn ExecutionPlan>> {
-        plan.transform_up(&|plan| {
-            let transformed =
-                plan.as_any()
-                    .downcast_ref::<SortExec>()
-                    .and_then(|sort_exec| {
-                        if sort_exec.input().output_partitioning().partition_count() > 1
-                        // It's already preserving the partitioning so that it can be regarded as a local sort
-                        && !sort_exec.preserve_partitioning()
-                        && (sort_exec.fetch().is_some() ||  config.optimizer.repartition_sorts)
-                    {
-                            let sort = SortExec::new(
-                                sort_exec.expr().to_vec(),
-                                sort_exec.input().clone()
-                            )
-                            .with_fetch(sort_exec.fetch())
-                            .with_preserve_partitioning(true);
-                            let global_sort: Arc<dyn ExecutionPlan> =
-                                Arc::new(SortPreservingMergeExec::new(
-                                    sort_exec.expr().to_vec(),
-                                    Arc::new(sort),
-                                ).with_fetch(sort_exec.fetch()));
-                            Some(global_sort)
-                        } else {
-                            None
-                        }
-                    });
-            Ok(if let Some(transformed) = transformed {
-                Transformed::Yes(transformed)
-            } else {
-                Transformed::No(plan)
-            })
-        })
-    }
-
-    fn name(&self) -> &str {

Review Comment:
   it is interesting that there were no specific tests for this module



-- 
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: github-unsubscribe@arrow.apache.org

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


[GitHub] [arrow-datafusion] Dandandan merged pull request #6965: [MINOR] Remove global sort rule from planner

Posted by "Dandandan (via GitHub)" <gi...@apache.org>.
Dandandan merged PR #6965:
URL: https://github.com/apache/arrow-datafusion/pull/6965


-- 
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: github-unsubscribe@arrow.apache.org

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