feat: add API for validating a predicate against a chunk:

pull/24376/head
Edd Robinson 2021-09-29 14:42:42 +01:00
parent 0a3ca90809
commit 8b458e2c2b
2 changed files with 15 additions and 0 deletions

View File

@ -210,6 +210,13 @@ impl Chunk {
// ---- Schema queries
//
/// Validates if the predicate can be applied to the table based on the
/// schema and the predicate's expressions. Returns an error if the
/// predicate cannot be applied.
pub fn validate_predicate(&self, predicate: Predicate) -> Result<Predicate, Error> {
self.table.validate_predicate(predicate).context(TableError)
}
/// Determines if one of more rows in the provided table could possibly
/// match the provided predicate.
///

View File

@ -234,6 +234,14 @@ impl Table {
Arc::clone(&self.table_data.read().meta)
}
/// Validates if the predicate can be applied to the table based on the
/// schema and the predicate's expressions. Returns an error if the
/// predicate cannot be applied.
pub fn validate_predicate(&self, predicate: Predicate) -> Result<Predicate, Error> {
let table_data = self.table_data.read();
Ok(table_data.meta.validate_exprs(predicate)?.into())
}
/// Determines if one of more row groups in the `Table` could possibly
/// contain one or more rows that satisfy the provided predicate.
pub fn could_pass_predicate(&self, predicate: &Predicate) -> bool {