Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor: use DataType::is_nested #3995

Merged
merged 1 commit into from
Oct 31, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 2 additions & 16 deletions datafusion/core/src/physical_plan/file_format/row_filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
// under the License.

use arrow::array::{Array, BooleanArray};
use arrow::datatypes::{DataType, Field, Schema};
use arrow::datatypes::{DataType, Schema};
use arrow::error::{ArrowError, Result as ArrowResult};
use arrow::record_batch::RecordBatch;
use datafusion_common::{Column, DataFusionError, Result, ScalarValue, ToDFSchema};
Expand Down Expand Up @@ -188,7 +188,7 @@ impl<'a> ExprRewriter for FilterCandidateBuilder<'a> {
if let Ok(idx) = self.file_schema.index_of(&column.name) {
self.required_column_indices.push(idx);

if !is_primitive_field(self.file_schema.field(idx)) {
if DataType::is_nested(self.file_schema.field(idx).data_type()) {
self.non_primitive_columns = true;
}
} else if self.table_schema.index_of(&column.name).is_err() {
Expand Down Expand Up @@ -307,20 +307,6 @@ pub fn build_row_filter(
}
}

/// return true if this is a non nested type.
// TODO remove after https://github.com/apache/arrow-rs/issues/2704 is done
fn is_primitive_field(field: &Field) -> bool {
!matches!(
field.data_type(),
DataType::List(_)
| DataType::FixedSizeList(_, _)
| DataType::LargeList(_)
| DataType::Struct(_)
| DataType::Union(_, _, _)
| DataType::Map(_, _)
)
}

#[cfg(test)]
mod test {
use crate::physical_plan::file_format::row_filter::FilterCandidateBuilder;
Expand Down