17 package com.mapd.parser.extension.ddl;
19 import com.google.common.base.Preconditions;
20 import com.google.common.collect.ImmutableList;
22 import org.apache.calcite.rel.type.RelDataType;
23 import org.apache.calcite.sql.SqlAggFunction;
24 import org.apache.calcite.sql.SqlFunctionCategory;
25 import org.apache.calcite.sql.SqlKind;
26 import org.apache.calcite.sql.SqlOperatorBinding;
27 import org.apache.calcite.sql.type.*;
28 import org.apache.calcite.util.Optionality;
30 import java.util.List;
35 OperandTypes.or(OperandTypes.ANY,
36 OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.NUMERIC),
37 OperandTypes.and(OperandTypes.family(SqlTypeFamily.ANY,
38 SqlTypeFamily.NUMERIC,
41 new SameOperandTypeChecker(3) {
43 protected List<Integer> getOperandList(
int operandCount) {
44 return ImmutableList.of(0, 2);
58 SqlFunctionCategory.NUMERIC,
61 Optionality.FORBIDDEN);
62 Preconditions.checkArgument(kind == SqlKind.LEAD || kind == SqlKind.LAG);
68 binding.getOperandCount() < 3 || binding.getOperandType(2).isNullable()
69 ? SqlTypeTransforms.FORCE_NULLABLE
70 : SqlTypeTransforms.TO_NOT_NULLABLE;
71 return transform.transformType(binding, type);
static final SqlSingleOperandTypeChecker OPERAND_TYPES
boolean allowsNullTreatment()
OUTPUT transform(INPUT const &input, FUNC const &func)
static final SqlReturnTypeInference RETURN_TYPE
static RelDataType transformType(SqlOperatorBinding binding, RelDataType type)
SqlLeadLag(String functionName, SqlKind kind)