Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions .github/actions/setup-rust-runtime/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@ description: 'Setup Rust Runtime Environment'
runs:
using: "composite"
steps:
- name: Run sccache-cache
uses: mozilla-actions/[email protected]
# https://github.com/apache/datafusion/issues/15535
# disabled because neither version nor git hash works with apache github policy
#- name: Run sccache-cache
# uses: mozilla-actions/sccache-action@65101d47ea8028ed0c98a1cdea8dd9182e9b5133 # v0.0.8
- name: Configure runtime env
shell: bash
# do not produce debug symbols to keep memory usage down
Expand All @@ -30,9 +32,11 @@ runs:
#
# Set debuginfo=line-tables-only as debuginfo=0 causes immensely slow build
# See for more details: https://github.com/rust-lang/rust/issues/119560
#
# readd the following to the run below once sccache-cache is re-enabled
# echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
# echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
run: |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "SCCACHE_GHA_ENABLED=true" >> $GITHUB_ENV
echo "RUST_BACKTRACE=1" >> $GITHUB_ENV
echo "RUSTFLAGS=-C debuginfo=line-tables-only -C incremental=false" >> $GITHUB_ENV

24 changes: 19 additions & 5 deletions datafusion/optimizer/src/optimize_projections/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ use datafusion_common::{
use datafusion_expr::expr::Alias;
use datafusion_expr::Unnest;
use datafusion_expr::{
logical_plan::LogicalPlan, projection_schema, Aggregate, Distinct, Expr, Projection,
TableScan, Window,
logical_plan::LogicalPlan, Aggregate, Distinct, Expr, Projection, TableScan, Window,
};

use crate::optimize_projections::required_indices::RequiredIndicies;
Expand Down Expand Up @@ -780,9 +779,24 @@ fn rewrite_projection_given_requirements(
/// Projection is unnecessary, when
/// - input schema of the projection, output schema of the projection are same, and
/// - all projection expressions are either Column or Literal
fn is_projection_unnecessary(input: &LogicalPlan, proj_exprs: &[Expr]) -> Result<bool> {
Ok(&projection_schema(input, proj_exprs)? == input.schema()
&& proj_exprs.iter().all(is_expr_trivial))
pub fn is_projection_unnecessary(
input: &LogicalPlan,
proj_exprs: &[Expr],
) -> Result<bool> {
// First check if the number of expressions is equal to the number of fields in the input schema.
if proj_exprs.len() != input.schema().fields().len() {
return Ok(false);
}
Ok(input.schema().iter().zip(proj_exprs.iter()).all(
|((field_relation, field_name), expr)| {
// Check if the expression is a column and if it matches the field name
if let Expr::Column(col) = expr {
col.relation.as_ref() == field_relation && col.name.eq(field_name.name())
} else {
false
}
},
))
}

#[cfg(test)]
Expand Down
Loading