adriangb commented on code in PR #17273: URL: https://github.com/apache/datafusion/pull/17273#discussion_r2294839550
########## datafusion/optimizer/src/push_down_sort.rs: ########## @@ -0,0 +1,235 @@ +// 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. + +//! [`PushDownSort`] pushes `SORT` requirements into `TableScan` + +use std::sync::Arc; + +use crate::optimizer::ApplyOrder; +use crate::{OptimizerConfig, OptimizerRule}; + +use datafusion_common::tree_node::Transformed; +use datafusion_common::{ExprSchema, Result}; +use datafusion_expr::logical_plan::{LogicalPlan, Sort}; +use datafusion_expr::SortExpr; + +/// Optimization rule that tries to push down `SORT` ordering requirements into `TableScan`. +/// +/// This optimization allows table providers to potentially provide pre-sorted data, +/// eliminating the need for expensive Sort operations. +#[derive(Default, Debug)] +pub struct PushDownSort {} + +impl PushDownSort { + #[allow(missing_docs)] + pub fn new() -> Self { + Self {} + } + + /// Attempts to push sort expressions down to a TableScan + fn try_push_sort_to_table_scan( Review Comment: This is another place to pay attention -- 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-unsubscr...@datafusion.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: github-unsubscr...@datafusion.apache.org For additional commands, e-mail: github-h...@datafusion.apache.org