Skip to content

Commit

Permalink
Minor: use DataType::is_nested (apache#3995)
Browse files Browse the repository at this point in the history
  • Loading branch information
alamb authored and Dandandan committed Nov 5, 2022
1 parent 490298a commit 0cfae0e
Showing 1 changed file with 2 additions and 16 deletions.
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 @@ -244,7 +244,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 @@ -380,20 +380,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

0 comments on commit 0cfae0e

Please sign in to comment.