alamb commented on code in PR #8437: URL: https://github.com/apache/arrow-datafusion/pull/8437#discussion_r1417234411
########## datafusion/physical-expr/src/utils/guarantee.rs: ########## @@ -0,0 +1,507 @@ +// 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. + +//! [`LiteralGuarantee`] predicate analysis to determine if a column is a +//! constant. + +use crate::utils::split_disjunction; +use crate::{split_conjunction, PhysicalExpr}; +use datafusion_common::{Column, ScalarValue}; +use datafusion_expr::Operator; +use std::collections::{HashMap, HashSet}; +use std::sync::Arc; + +/// Represents a known guarantee that a column is either one of a set of values +/// or not one of a set of values. +/// +/// `LiteralGuarantee`s can be used to simplify expressions and skip data files +/// (or row groups in parquet files). For example, if we know that `a = 1` then +/// we can skip any partition that does not contain `a = 1`. +/// +/// See [`LiteralGuarantee::analyze`] to extract literal guarantees from a +/// predicate. +/// +/// # Details +/// A guarantee can be one of two forms: +/// +/// 1. One of particular set of values. For example, `(a = 1)`, `(a = 1 OR a = +/// 2) or `a IN (1, 2, 3)` +/// +/// 2. NOT one of a particular set of values. For example, `(a != 1)`, `(a != 1 +/// AND a != 2)` or `a NOT IN (1, 2, 3)` +/// +#[derive(Debug, Clone, PartialEq)] +pub struct LiteralGuarantee { Review Comment: This is a generalization of the [code in the BloomFilterPruningPredicate](https://github.com/apache/arrow-datafusion/blob/0d7cab055cb39d6df751e070af5a0bf5444e3849/datafusion/core/src/datasource/physical_plan/parquet/row_groups.rs#L182-L197) -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
