diff --git a/read_buffer/src/chunk.rs b/read_buffer/src/chunk.rs index 4b27dc00f9..e0ed0286d4 100644 --- a/read_buffer/src/chunk.rs +++ b/read_buffer/src/chunk.rs @@ -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 { + self.table.validate_predicate(predicate).context(TableError) + } + /// Determines if one of more rows in the provided table could possibly /// match the provided predicate. /// diff --git a/read_buffer/src/table.rs b/read_buffer/src/table.rs index d8992c2601..b0d98d8d50 100644 --- a/read_buffer/src/table.rs +++ b/read_buffer/src/table.rs @@ -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 { + 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 {