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
andR IS NOT NULL
.At the same time SQL standard says that the next about `ROW`:
- The value of
R IS NULL
is:- If the value of every field of V is the null value, then True.
- Otherwise, False.
- The value of
R IS NOT NULL
is:- 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 FALSE
SELECT 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 TRUE
SELECT 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
andFlinkTypeFactory
.Changed lines
- Line 106 ~ 137
- The value of
-
-
Constructor Summary
Constructors Constructor Description SqlRowOperator(String name)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description org.apache.calcite.rel.type.RelDataType
inferReturnType(org.apache.calcite.sql.SqlOperatorBinding opBinding)
boolean
requiresDecimalExpansion()
void
unparse(org.apache.calcite.sql.SqlWriter writer, org.apache.calcite.sql.SqlCall call, int leftPrec, int rightPrec)
-
Methods 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 Detail
-
SqlRowOperator
public SqlRowOperator(String name)
-
-
Method Detail
-
inferReturnType
public org.apache.calcite.rel.type.RelDataType inferReturnType(org.apache.calcite.sql.SqlOperatorBinding opBinding)
- Overrides:
inferReturnType
in 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:
unparse
in classorg.apache.calcite.sql.SqlOperator
-
requiresDecimalExpansion
public boolean requiresDecimalExpansion()
- Overrides:
requiresDecimalExpansion
in classorg.apache.calcite.sql.SqlOperator
-
-