use of io.prestosql.spi.function.OperatorType.ADD in project hetu-core by openlookeng.
the class DecimalOperators method decimalAddOperator.
private static SqlScalarFunction decimalAddOperator() {
TypeSignature decimalLeftSignature = parseTypeSignature("decimal(a_precision, a_scale)", ImmutableSet.of("a_precision", "a_scale"));
TypeSignature decimalRightSignature = parseTypeSignature("decimal(b_precision, b_scale)", ImmutableSet.of("b_precision", "b_scale"));
TypeSignature decimalResultSignature = parseTypeSignature("decimal(r_precision, r_scale)", ImmutableSet.of("r_precision", "r_scale"));
Signature signature = Signature.builder().kind(SCALAR).operatorType(ADD).longVariableConstraints(longVariableExpression("r_precision", "min(38, max(a_precision - a_scale, b_precision - b_scale) + max(a_scale, b_scale) + 1)"), longVariableExpression("r_scale", "max(a_scale, b_scale)")).argumentTypes(decimalLeftSignature, decimalRightSignature).returnType(decimalResultSignature).build();
return SqlScalarFunction.builder(DecimalOperators.class, ADD).signature(signature).deterministic(true).choice(choice -> choice.implementation(methodsGroup -> methodsGroup.methods("addShortShortShort").withExtraParameters(DecimalOperators::calculateShortRescaleParameters)).implementation(methodsGroup -> methodsGroup.methods("addShortShortLong", "addLongLongLong", "addShortLongLong", "addLongShortLong").withExtraParameters(DecimalOperators::calculateLongRescaleParameters))).build();
}
use of io.prestosql.spi.function.OperatorType.ADD in project hetu-core by openlookeng.
the class TestPolymorphicScalarFunction method testSetsHiddenToTrueForOperators.
@Test
public void testSetsHiddenToTrueForOperators() {
Signature signature = Signature.builder().operatorType(ADD).kind(SCALAR).returnType(parseTypeSignature("varchar(x)", ImmutableSet.of("x"))).argumentTypes(parseTypeSignature("varchar(x)", ImmutableSet.of("x"))).build();
SqlScalarFunction function = SqlScalarFunction.builder(TestMethods.class).signature(signature).calledOnNullInput(ADD.isCalledOnNullInput()).deterministic(true).choice(choice -> choice.implementation(methodsGroup -> methodsGroup.methods("varcharToVarchar"))).build();
BuiltInScalarFunctionImplementation functionImplementation = function.specialize(BOUND_VARIABLES, 1, METADATA.getFunctionAndTypeManager());
}
Aggregations