Package org.apache.calcite.rex
Class RexNormalize
java.lang.Object
org.apache.calcite.rex.RexNormalize
Context required to normalize a row-expression.
Currently, only simple normalization is supported, such as:
- $2 = $1 → $1 = $2
- $2 > $1 → $1 < $2
- 1.23 = $1 → $1 = 1.23
- OR(OR(udf($1), $2), $3) → OR($3, OR($2, udf($1)))
In the future, this component may extend to support more normalization cases for general promotion. e.g. the strategy to decide which operand is more complex should be more smart.
There is no one normalization strategy that works for all cases, and no consensus about what
the desired strategies should be. So by default, the normalization is disabled. We do force
normalization when computing the digest of RexCall
s during planner planning.
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
hashCode
(SqlOperator operator, List<RexNode> operands) Computes the hashCode of a rex call.static Pair<SqlOperator,
List<RexNode>> normalize
(SqlOperator operator, List<RexNode> operands) Normalizes the variables of a rex call.
-
Method Details
-
normalize
@API(since="1.24", status=EXPERIMENTAL) public static Pair<SqlOperator,List<RexNode>> normalize(SqlOperator operator, List<RexNode> operands) Normalizes the variables of a rex call.- Parameters:
operator
- The operatoroperands
- The operands- Returns:
- normalized variables of the call or the original if there is no need to normalize
-
hashCode
Computes the hashCode of a rex call. We ignore the operands sequence when the call is symmetrical.Note that the logic to decide whether operands need reordering should be strictly same with
normalize(org.apache.calcite.sql.SqlOperator, java.util.List<org.apache.calcite.rex.RexNode>)
.
-