本文整理汇总了Java中org.apache.calcite.sql.type.OperandTypes类的典型用法代码示例。如果您正苦于以下问题:Java OperandTypes类的具体用法?Java OperandTypes怎么用?Java OperandTypes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
OperandTypes类属于org.apache.calcite.sql.type包,在下文中一共展示了OperandTypes类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: SqlDatePartOperator
import org.apache.calcite.sql.type.OperandTypes; //导入依赖的package包/类
public SqlDatePartOperator() {
super(
"DATE_PART",
SqlKind.OTHER_FUNCTION,
ReturnTypes.BIGINT_NULLABLE,
null,
OperandTypes.sequence(
"<PERIOD LITERAL>, <DATE or TIMESTAMP or INTERVAL>",
new EnumeratedListChecker(VALID_PERIODS.keySet()),
OperandTypes.or(
OperandTypes.family(SqlTypeFamily.DATE),
OperandTypes.family(SqlTypeFamily.TIMESTAMP),
OperandTypes.family(SqlTypeFamily.DATETIME),
OperandTypes.family(SqlTypeFamily.DATETIME_INTERVAL),
OperandTypes.family(SqlTypeFamily.INTERVAL_DAY_TIME),
OperandTypes.family(SqlTypeFamily.INTERVAL_YEAR_MONTH))
),
SqlFunctionCategory.SYSTEM);
}
示例2: apply
import org.apache.calcite.sql.type.OperandTypes; //导入依赖的package包/类
@Override
public RexNode apply(RexBuilderContext context) {
RelOptCluster cluster = context.getCluster();
RelDataTypeFactory typeFactory = cluster.getTypeFactory();
final SqlFunction UDF =
new SqlUserDefinedFunction(
new SqlIdentifier("RESOLVE_SIMPLE", SqlParserPos.ZERO),
ReturnTypes.explicit(typeFactory.createJavaType(Object.class)),
null,
OperandTypes.ANY_ANY,
ImmutableList.of(typeFactory.createTypeWithNullability(typeFactory.createJavaType(IObject.class), false),
typeFactory.createJavaType(int.class)),
ScalarFunctionImpl.create(IObjectMethods.class, "resolveSimpleValue"));
RexBuilder b = context.getBuilder();
RexNode rexNode = b.makeCall(UDF, context.getIObject(), b.makeLiteral(name));
return b.makeCast(dataType, rexNode);
}
示例3: getSnapshot
import org.apache.calcite.sql.type.OperandTypes; //导入依赖的package包/类
@Override
public RexNode getSnapshot() {
if (snapshot == null) {
RelDataTypeFactory typeFactory = getCluster().getTypeFactory();
RexBuilder b = getBuilder();
final SqlFunction UDF =
new SqlUserDefinedFunction(
new SqlIdentifier("GET_SNAPSHOT", SqlParserPos.ZERO),
ReturnTypes.explicit(typeFactory.createTypeWithNullability(typeFactory.createJavaType(ISnapshot.class), false)),
null,
OperandTypes.NUMERIC,
ImmutableList.of(typeFactory.createJavaType(Integer.class)),
ScalarFunctionImpl.create(SnapshotHolder.class, "get"));
snapshot = b.makeCall(UDF, b.makeLiteral(snapshotId, typeFactory.createSqlType(SqlTypeName.INTEGER), false));
}
return snapshot;
}
示例4: getIObject
import org.apache.calcite.sql.type.OperandTypes; //导入依赖的package包/类
public RexNode getIObject() {
if (object == null) {
RelDataTypeFactory typeFactory = getCluster().getTypeFactory();
RexBuilder b = getBuilder();
final SqlFunction GET_IOBJECT =
new SqlUserDefinedFunction(
new SqlIdentifier("GET_IOBJECT", SqlParserPos.ZERO),
ReturnTypes.explicit(typeFactory.createTypeWithNullability(typeFactory.createJavaType(IObject.class), false)),
null,
OperandTypes.ANY_ANY,
ImmutableList.of(typeFactory.createTypeWithNullability(typeFactory.createJavaType(ISnapshot.class), false),
typeFactory.createJavaType(int.class)),
ScalarFunctionImpl.create(ISnapshotMethods.class, "getIObject"));
object = b.makeCall(GET_IOBJECT, getSnapshot(), getIObjectId());
}
return object;
}
示例5: SqlMinMaxAggFunction
import org.apache.calcite.sql.type.OperandTypes; //导入依赖的package包/类
/** Creates a SqlMinMaxAggFunction. */
public SqlMinMaxAggFunction(SqlKind kind) {
super(kind.name(),
null,
kind,
ReturnTypes.ARG0_NULLABLE_IF_EMPTY,
null,
OperandTypes.COMPARABLE_ORDERED,
SqlFunctionCategory.SYSTEM,
false,
false);
this.argTypes = ImmutableList.of();
this.minMaxKind = MINMAX_COMPARABLE;
Preconditions.checkArgument(kind == SqlKind.MIN
|| kind == SqlKind.MAX);
}
示例6: SqlLikeOperator
import org.apache.calcite.sql.type.OperandTypes; //导入依赖的package包/类
/**
* Creates a SqlLikeOperator.
*
* @param name Operator name
* @param kind Kind
* @param negated Whether this is 'NOT LIKE'
*/
SqlLikeOperator(
String name,
SqlKind kind,
boolean negated) {
// LIKE is right-associative, because that makes it easier to capture
// dangling ESCAPE clauses: "a like b like c escape d" becomes
// "a like (b like c escape d)".
super(
name,
kind,
32,
false,
ReturnTypes.BOOLEAN_NULLABLE,
InferTypes.FIRST_KNOWN,
OperandTypes.STRING_SAME_SAME_SAME);
this.negated = negated;
}
示例7: checkOperandTypes
import org.apache.calcite.sql.type.OperandTypes; //导入依赖的package包/类
public boolean checkOperandTypes(
SqlCallBinding callBinding,
boolean throwOnFailure) {
// check that the two operands are of same type.
switch (callBinding.getOperandCount()) {
case 2:
return OperandTypes.SAME_SAME.checkOperandTypes(
callBinding, throwOnFailure)
&& super.checkOperandTypes(callBinding, throwOnFailure);
case 3:
return OperandTypes.SAME_SAME_INTEGER.checkOperandTypes(
callBinding, throwOnFailure)
&& super.checkOperandTypes(callBinding, throwOnFailure);
default:
throw new AssertionError();
}
}
示例8: SqlCovarAggFunction
import org.apache.calcite.sql.type.OperandTypes; //导入依赖的package包/类
/**
* Creates a SqlCovarAggFunction.
*/
public SqlCovarAggFunction(SqlKind kind) {
super(kind.name(),
null,
kind,
ReturnTypes.COVAR_FUNCTION,
null,
OperandTypes.NUMERIC_NUMERIC,
SqlFunctionCategory.NUMERIC,
false,
false);
Preconditions.checkArgument(kind == SqlKind.COVAR_POP
|| kind == SqlKind.COVAR_SAMP
|| kind == SqlKind.REGR_SXX
|| kind == SqlKind.REGR_SYY);
}
示例9: getChecker
import org.apache.calcite.sql.type.OperandTypes; //导入依赖的package包/类
private SqlSingleOperandTypeChecker getChecker(RelDataType operandType) {
switch (operandType.getSqlTypeName()) {
case ARRAY:
return OperandTypes.family(SqlTypeFamily.INTEGER);
case MAP:
return OperandTypes.family(
operandType.getKeyType().getSqlTypeName().getFamily());
case ANY:
case DYNAMIC_STAR:
return OperandTypes.or(
OperandTypes.family(SqlTypeFamily.INTEGER),
OperandTypes.family(SqlTypeFamily.CHARACTER));
default:
throw new AssertionError(operandType.getSqlTypeName());
}
}
示例10: SqlSumCountAggFunction
import org.apache.calcite.sql.type.OperandTypes; //导入依赖的package包/类
public SqlSumCountAggFunction(RelDataType type) {
super("$SUM0",
SqlKind.OTHER_FUNCTION,
ReturnTypes.BIGINT, // use the inferred return type of SqlCountAggFunction
null,
OperandTypes.NUMERIC,
SqlFunctionCategory.NUMERIC);
this.type = type;
}
示例11: SqlHllAggFunction
import org.apache.calcite.sql.type.OperandTypes; //导入依赖的package包/类
public SqlHllAggFunction() {
super("HLL",
null,
SqlKind.OTHER_FUNCTION,
ReturnTypes.explicit(SqlTypeName.BINARY),
null,
OperandTypes.ANY,
SqlFunctionCategory.USER_DEFINED_FUNCTION,
false,
false
);
}
示例12: SqlHllMergeAggFunction
import org.apache.calcite.sql.type.OperandTypes; //导入依赖的package包/类
public SqlHllMergeAggFunction() {
super("NDV_MERGE",
null,
SqlKind.OTHER_FUNCTION,
ReturnTypes.BIGINT_FORCE_NULLABLE,
null,
OperandTypes.BINARY,
SqlFunctionCategory.USER_DEFINED_FUNCTION,
false,
false
);
}
示例13: SqlTimestampAddFunction
import org.apache.calcite.sql.type.OperandTypes; //导入依赖的package包/类
/** Creates a SqlTimestampAddFunction. */
SqlTimestampAddFunction() {
super("TIMESTAMPADD", SqlKind.TIMESTAMP_ADD, RETURN_TYPE_INFERENCE, null,
OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.INTEGER,
SqlTypeFamily.TIMESTAMP),
SqlFunctionCategory.TIMEDATE);
}
示例14: createCustomAggFunction
import org.apache.calcite.sql.type.OperandTypes; //导入依赖的package包/类
SqlAggFunction createCustomAggFunction(String funcName, RelDataType returnType, Class<?> customAggFuncClz) {
RelDataTypeFactory typeFactory = getCluster().getTypeFactory();
SqlIdentifier sqlIdentifier = new SqlIdentifier(funcName, new SqlParserPos(1, 1));
AggregateFunction aggFunction = AggregateFunctionImpl.create(customAggFuncClz);
List<RelDataType> argTypes = new ArrayList<RelDataType>();
List<SqlTypeFamily> typeFamilies = new ArrayList<SqlTypeFamily>();
for (FunctionParameter o : aggFunction.getParameters()) {
final RelDataType type = o.getType(typeFactory);
argTypes.add(type);
typeFamilies.add(Util.first(type.getSqlTypeName().getFamily(), SqlTypeFamily.ANY));
}
return new SqlUserDefinedAggFunction(sqlIdentifier, ReturnTypes.explicit(returnType),
InferTypes.explicit(argTypes), OperandTypes.family(typeFamilies), aggFunction, false, false);
}
示例15: SqlSetOperator
import org.apache.calcite.sql.type.OperandTypes; //导入依赖的package包/类
public SqlSetOperator(
String name,
SqlKind kind,
int prec,
boolean all) {
super(
name,
kind,
prec,
true,
ReturnTypes.LEAST_RESTRICTIVE,
null,
OperandTypes.SET_OP);
this.all = all;
}