private static SqlScalarFunction decimalModulusOperator() { Signature signature = modulusSignatureBuilder() .operatorType(MODULUS) .build(); return modulusScalarFunction(signature); }
private static SqlScalarFunction decimalModulusOperator() { Signature signature = modulusSignatureBuilder() .operatorType(MODULUS) .build(); return modulusScalarFunction(signature); }
private static SqlScalarFunction decimalModFunction() { Signature signature = modulusSignatureBuilder() .kind(SCALAR) .name("mod") .build(); return modulusScalarFunction(signature); }
private static SqlScalarFunction decimalModFunction() { Signature signature = modulusSignatureBuilder() .kind(SCALAR) .name("mod") .build(); return modulusScalarFunction(signature); }
public ResolveFunctionAssertion returns(SignatureBuilder functionSignature) { Signature expectedSignature = functionSignature.name(TEST_FUNCTION_NAME).build(); Signature actualSignature = resolveSignature(); assertEquals(actualSignature, expectedSignature); return this; }
public ResolveFunctionAssertion returns(SignatureBuilder functionSignature) { Signature expectedSignature = functionSignature.name(TEST_FUNCTION_NAME).build(); Signature actualSignature = resolveSignature(); assertEquals(actualSignature, expectedSignature); return this; }
@Test public void testBindUnparametrizedVarchar() { Signature function = functionSignature() .returnType(parseTypeSignature("boolean")) .argumentTypes(parseTypeSignature("varchar(x)", ImmutableSet.of("x"))) .build(); assertThat(function) .boundTo("varchar") .produces(new BoundVariables( ImmutableMap.of(), ImmutableMap.of("x", (long) Integer.MAX_VALUE))); }
private static PolymorphicScalarFunctionBuilder makeBinaryOperatorFunctionBuilder(OperatorType operatorType) { Signature signature = Signature.builder() .kind(SCALAR) .operatorType(operatorType) .argumentTypes(DECIMAL_SIGNATURE, DECIMAL_SIGNATURE) .returnType(parseTypeSignature(BOOLEAN)) .build(); return SqlScalarFunction.builder(DecimalInequalityOperators.class) .signature(signature) .deterministic(true); }
@Test public void testBindUnparametrizedVarchar() { Signature function = functionSignature() .returnType(parseTypeSignature("boolean")) .argumentTypes(parseTypeSignature("varchar(x)", ImmutableSet.of("x"))) .build(); assertThat(function) .boundTo("varchar") .produces(new BoundVariables( ImmutableMap.of(), ImmutableMap.of("x", (long) Integer.MAX_VALUE))); }
private static PolymorphicScalarFunctionBuilder makeBinaryOperatorFunctionBuilder(OperatorType operatorType) { Signature signature = Signature.builder() .kind(SCALAR) .operatorType(operatorType) .argumentTypes(DECIMAL_SIGNATURE, DECIMAL_SIGNATURE) .returnType(parseTypeSignature(BOOLEAN)) .build(); return SqlScalarFunction.builder(DecimalInequalityOperators.class) .signature(signature) .deterministic(true); }
@Test public void testBindDifferentLiteralParameters() { TypeSignature argType = parseTypeSignature("decimal(p,s)", ImmutableSet.of("p", "s")); Signature function = functionSignature() .returnType(parseTypeSignature(StandardTypes.BOOLEAN)) .argumentTypes(argType, argType) .build(); assertThat(function) .boundTo("decimal(2,1)", "decimal(3,1)") .fails(); }
@Test public void testBindDifferentLiteralParameters() { TypeSignature argType = parseTypeSignature("decimal(p,s)", ImmutableSet.of("p", "s")); Signature function = functionSignature() .returnType(parseTypeSignature(StandardTypes.BOOLEAN)) .argumentTypes(argType, argType) .build(); assertThat(function) .boundTo("decimal(2,1)", "decimal(3,1)") .fails(); }
@Test public void testBindUnknownToTypeParameter() { Signature function = functionSignature() .returnType(parseTypeSignature("T")) .argumentTypes(parseTypeSignature("T")) .typeVariableConstraints(ImmutableList.of(typeVariable("T"))) .build(); assertThat(function) .boundTo("unknown") .withCoercion() .produces(new BoundVariables( ImmutableMap.of("T", type("unknown")), ImmutableMap.of())); }
@Test public void testBindUnknownToConcreteArray() { Signature function = functionSignature() .returnType(parseTypeSignature(StandardTypes.BOOLEAN)) .argumentTypes(parseTypeSignature("array(boolean)")) .build(); assertThat(function) .boundTo("unknown") .withCoercion() .succeeds(); }
@Test public void testBindUnknownToConcreteArray() { Signature function = functionSignature() .returnType(parseTypeSignature(StandardTypes.BOOLEAN)) .argumentTypes(parseTypeSignature("array(boolean)")) .build(); assertThat(function) .boundTo("unknown") .withCoercion() .succeeds(); }
@Test public void testBindDoubleToBigint() { Signature function = functionSignature() .returnType(parseTypeSignature(StandardTypes.BOOLEAN)) .argumentTypes(parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.DOUBLE)) .build(); assertThat(function) .boundTo("double", "bigint") .withCoercion() .succeeds(); }
@Test public void testBindDoubleToBigint() { Signature function = functionSignature() .returnType(parseTypeSignature(StandardTypes.BOOLEAN)) .argumentTypes(parseTypeSignature(StandardTypes.DOUBLE), parseTypeSignature(StandardTypes.DOUBLE)) .build(); assertThat(function) .boundTo("double", "bigint") .withCoercion() .succeeds(); }
@Test public void testBindUnknown() { Signature function = functionSignature() .returnType(parseTypeSignature(StandardTypes.BOOLEAN)) .argumentTypes(parseTypeSignature("varchar(x)", ImmutableSet.of("x"))) .build(); assertThat(function) .boundTo("unknown") .fails(); assertThat(function) .boundTo("unknown") .withCoercion() .succeeds(); }
@Test public void testMismatchedArgumentCount() { Signature function = functionSignature() .returnType(parseTypeSignature(StandardTypes.BOOLEAN)) .argumentTypes(parseTypeSignature(StandardTypes.BIGINT), parseTypeSignature(StandardTypes.BIGINT)) .build(); assertThat(function) .boundTo("bigint", "bigint", "bigint") .fails(); assertThat(function) .boundTo("bigint") .fails(); }
@Test public void testMismatchedArgumentCount() { Signature function = functionSignature() .returnType(parseTypeSignature(StandardTypes.BOOLEAN)) .argumentTypes(parseTypeSignature(StandardTypes.BIGINT), parseTypeSignature(StandardTypes.BIGINT)) .build(); assertThat(function) .boundTo("bigint", "bigint", "bigint") .fails(); assertThat(function) .boundTo("bigint") .fails(); }