pub trait ScalarQueryParser:
Debug
+ Send
+ Sync {
// Required methods
fn visit_between(
&self,
column: &str,
low: &Bound<ScalarValue>,
high: &Bound<ScalarValue>,
) -> Option<IndexedExpression>;
fn visit_in_list(
&self,
column: &str,
in_list: &[ScalarValue],
) -> Option<IndexedExpression>;
fn visit_is_bool(
&self,
column: &str,
value: bool,
) -> Option<IndexedExpression>;
fn visit_is_null(&self, column: &str) -> Option<IndexedExpression>;
fn visit_comparison(
&self,
column: &str,
value: &ScalarValue,
op: &Operator,
) -> Option<IndexedExpression>;
fn visit_scalar_function(
&self,
column: &str,
data_type: &DataType,
func: &ScalarUDF,
args: &[Expr],
) -> Option<IndexedExpression>;
// Provided method
fn is_valid_reference(
&self,
func: &Expr,
data_type: &DataType,
) -> Option<DataType> { ... }
}Required Methods§
Sourcefn visit_between(
&self,
column: &str,
low: &Bound<ScalarValue>,
high: &Bound<ScalarValue>,
) -> Option<IndexedExpression>
fn visit_between( &self, column: &str, low: &Bound<ScalarValue>, high: &Bound<ScalarValue>, ) -> Option<IndexedExpression>
Visit a between expression
Returns an IndexedExpression if the index can accelerate between expressions
Sourcefn visit_in_list(
&self,
column: &str,
in_list: &[ScalarValue],
) -> Option<IndexedExpression>
fn visit_in_list( &self, column: &str, in_list: &[ScalarValue], ) -> Option<IndexedExpression>
Visit an in list expression
Returns an IndexedExpression if the index can accelerate in list expressions
Sourcefn visit_is_bool(&self, column: &str, value: bool) -> Option<IndexedExpression>
fn visit_is_bool(&self, column: &str, value: bool) -> Option<IndexedExpression>
Visit an is bool expression
Returns an IndexedExpression if the index can accelerate is bool expressions
Sourcefn visit_is_null(&self, column: &str) -> Option<IndexedExpression>
fn visit_is_null(&self, column: &str) -> Option<IndexedExpression>
Visit an is null expression
Returns an IndexedExpression if the index can accelerate is null expressions
Sourcefn visit_comparison(
&self,
column: &str,
value: &ScalarValue,
op: &Operator,
) -> Option<IndexedExpression>
fn visit_comparison( &self, column: &str, value: &ScalarValue, op: &Operator, ) -> Option<IndexedExpression>
Visit a comparison expression
Returns an IndexedExpression if the index can accelerate comparison expressions
Sourcefn visit_scalar_function(
&self,
column: &str,
data_type: &DataType,
func: &ScalarUDF,
args: &[Expr],
) -> Option<IndexedExpression>
fn visit_scalar_function( &self, column: &str, data_type: &DataType, func: &ScalarUDF, args: &[Expr], ) -> Option<IndexedExpression>
Visit a scalar function expression
Returns an IndexedExpression if the index can accelerate the given scalar function. For example, an ngram index can accelerate the contains function.
Provided Methods§
Sourcefn is_valid_reference(
&self,
func: &Expr,
data_type: &DataType,
) -> Option<DataType>
fn is_valid_reference( &self, func: &Expr, data_type: &DataType, ) -> Option<DataType>
Visits a potential reference to a column
This function is a little different from the other visitors. It is used to test if a potential column reference is a reference the index handles.
Most indexes are designed to run on references to the indexed column. For example, if a query is “x = 7” and we have a scalar index on “x” then we apply the index to the “x” column reference.
However, some indexes are designed to run on projections of the indexed column. For example, if a query is “json_extract(json, ‘$.name’) = ‘books’” and we have a JSON index on the “json” column then we apply the index to the projection of the “json” column.
This function is used to test if a potential column reference is a reference the index handles. The default implementation matches column references but this can be overridden by indexes that handle projections.
The function is also passed in the data type of the column and should return the data type of the reference. Normally this is the same as the input for a direct column reference and possibly something different for a projection. E.g. a JSON column (LargeBinary) might be projected to a string or float
Note: higher logic in the expression parser already limits references to either Expr::Column or Expr::ScalarFunction where the first argument is an Expr::Column. If your projection doesn’t fit that mold then the expression parser will need to be modified.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".