Package org.apache.calcite.sql.fun
Class SqlRowOperator
java.lang.Object
org.apache.calcite.sql.SqlOperator
org.apache.calcite.sql.SqlSpecialOperator
org.apache.calcite.sql.fun.SqlRowOperator
public class SqlRowOperator
extends org.apache.calcite.sql.SqlSpecialOperator
Copied to keep null semantics of table api and sql in sync.
There are differences following:
1. The return value about R IS NULL and R IS NOT NULL.
At the same time SQL standard says that the next about `ROW`:
- The value of
R IS NULLis:- If the value of every field of V is the null value, then True.
- Otherwise, False.
- The value of
R IS NOT NULLis:- If the value of no field of V is the null value, then True.
- Otherwise, False.
Calcite applies that logic since CALCITE-3627 (1.30.0+).
- Thus, with Calcite 1.30.0+
SELECT ROW(CAST(NULL AS INT), CAST(NULL AS INT)) IS NOT NULL; -- returns FALSESELECT ROW(CAST(NULL AS INT), CAST(NULL AS INT)) IS NULL; -- returns TRUE.
- With Flink and Calcite before 1.30.0 (current behavior of this class)
SELECT ROW(CAST(NULL AS INT), CAST(NULL AS INT)) IS NOT NULL; -- returns TRUESELECT ROW(CAST(NULL AS INT), CAST(NULL AS INT)) IS NULL; -- returns FALSE
Once Flink applies same logic for both table api and sql, this first changes should be removed.
2. It uses StructKind.PEEK_FIELDS_NO_EXPAND with a nested struct type (Flink [[RowType]]).
See more at LogicalRelDataTypeConverter and
org.apache.flink.table.planner.calcite.FlinkTypeFactory.
Changed lines
- Line 106 ~ 137
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.calcite.sql.SqlSpecialOperator
org.apache.calcite.sql.SqlSpecialOperator.ReduceResult, org.apache.calcite.sql.SqlSpecialOperator.TokenSequence -
Field Summary
Fields inherited from class org.apache.calcite.sql.SqlOperator
kind, MDX_PRECEDENCE, NL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.calcite.rel.type.RelDataTypeinferReturnType(org.apache.calcite.sql.SqlOperatorBinding opBinding) booleanvoidunparse(org.apache.calcite.sql.SqlWriter writer, org.apache.calcite.sql.SqlCall call, int leftPrec, int rightPrec) Methods inherited from class org.apache.calcite.sql.SqlSpecialOperator
getSyntax, reduceExprMethods inherited from class org.apache.calcite.sql.SqlOperator
acceptCall, acceptCall, adjustType, allowsFraming, argumentMustBeScalar, checkOperandCount, checkOperandTypes, constructArgNameList, constructArgTypeList, constructOperandList, createCall, createCall, createCall, createCall, createCall, createCall, createCall, deriveOperandType, deriveType, equals, getAllowedSignatures, getAllowedSignatures, getKind, getLeftPrec, getMonotonicity, getMonotonicity, getName, getNameAsId, getOperandCountRange, getOperandTypeChecker, getOperandTypeInference, getReturnTypeInference, getRightPrec, getSignatureTemplate, getStrongPolicyInference, hashCode, inferReturnType, isAggregator, isDeterministic, isDynamicFunction, isGroup, isGroupAuxiliary, isName, isSymmetrical, leftPrec, not, preValidateCall, requiresOrder, requiresOver, reverse, rewriteCall, rightPrec, toString, unparseListClause, unparseListClause, validateCall, validateOperands, validRexOperands
-
Constructor Details
-
SqlRowOperator
-
-
Method Details
-
inferReturnType
public org.apache.calcite.rel.type.RelDataType inferReturnType(org.apache.calcite.sql.SqlOperatorBinding opBinding) - Overrides:
inferReturnTypein classorg.apache.calcite.sql.SqlOperator
-
unparse
public void unparse(org.apache.calcite.sql.SqlWriter writer, org.apache.calcite.sql.SqlCall call, int leftPrec, int rightPrec) - Overrides:
unparsein classorg.apache.calcite.sql.SqlOperator
-
requiresDecimalExpansion
public boolean requiresDecimalExpansion()- Overrides:
requiresDecimalExpansionin classorg.apache.calcite.sql.SqlOperator
-