public static SqlScalarFunction modulusScalarFunction(Signature signature) { return SqlScalarFunction.builder(DecimalOperators.class) .signature(signature) .deterministic(true) .choice(choice -> choice .implementation(methodsGroup -> methodsGroup .methods("modulusShortShortShort", "modulusLongLongLong", "modulusShortLongLong", "modulusShortLongShort", "modulusLongShortShort", "modulusLongShortLong") .withExtraParameters(DecimalOperators::modulusRescaleParameters))) .build(); }
protected SqlOperator(OperatorType operatorType, List<TypeVariableConstraint> typeVariableConstraints, List<LongVariableConstraint> longVariableConstraints, TypeSignature returnType, List<TypeSignature> argumentTypes) { // TODO This should take Signature! super(new Signature( mangleOperatorName(operatorType), FunctionKind.SCALAR, typeVariableConstraints, longVariableConstraints, returnType, argumentTypes, false)); }
public InternalTable build() { flushPage(); return new InternalTable(columnIndexes, pages); }
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); }
public FunctionAssertions addScalarFunctions(Class<?> clazz) { metadata.addFunctions(new FunctionListBuilder().scalars(clazz).getFunctions()); return this; }
public static MetadataManager createTestMetadataManager(FeaturesConfig featuresConfig) { return createTestMetadataManager(new CatalogManager(), featuresConfig); }
private boolean appendConstraintSolversForReturnValue(ImmutableList.Builder<TypeConstraintSolver> resultBuilder, TypeSignatureProvider actualReturnType) { TypeSignature formalReturnTypeSignature = declaredSignature.getReturnType(); return appendTypeRelationshipConstraintSolver(resultBuilder, formalReturnTypeSignature, actualReturnType, false) && appendConstraintSolvers(resultBuilder, formalReturnTypeSignature, actualReturnType, false); }
public boolean canResolveOperator(OperatorType operatorType, Type returnType, List<? extends Type> argumentTypes) { Signature signature = internalOperator(operatorType, returnType, argumentTypes); return isRegistered(signature); }
public static Signature internalOperator(String name, TypeSignature returnType, List<TypeSignature> argumentTypes) { return internalScalarFunction(mangleOperatorName(name), returnType, argumentTypes); }
private InternalTable buildSchemata(Session session, String catalogName) { InternalTable.Builder table = InternalTable.builder(informationSchemaTableColumns(TABLE_SCHEMATA)); for (String schema : listSchemas(session, metadata, accessControl, catalogName)) { table.add(catalogName, schema); } return table.build(); }
public static SqlScalarFunction modulusScalarFunction(Signature signature) { return SqlScalarFunction.builder(DecimalOperators.class) .signature(signature) .deterministic(true) .choice(choice -> choice .implementation(methodsGroup -> methodsGroup .methods("modulusShortShortShort", "modulusLongLongLong", "modulusShortLongLong", "modulusShortLongShort", "modulusLongShortShort", "modulusLongShortLong") .withExtraParameters(DecimalOperators::modulusRescaleParameters))) .build(); }
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); }
public FunctionAssertions addScalarFunctions(Class<?> clazz) { metadata.addFunctions(new FunctionListBuilder().scalars(clazz).getFunctions()); return this; }
protected SqlOperator(OperatorType operatorType, List<TypeVariableConstraint> typeVariableConstraints, List<LongVariableConstraint> longVariableConstraints, TypeSignature returnType, List<TypeSignature> argumentTypes) { // TODO This should take Signature! super(new Signature( mangleOperatorName(operatorType), FunctionKind.SCALAR, typeVariableConstraints, longVariableConstraints, returnType, argumentTypes, false)); }
private boolean appendConstraintSolversForReturnValue(ImmutableList.Builder<TypeConstraintSolver> resultBuilder, TypeSignatureProvider actualReturnType) { TypeSignature formalReturnTypeSignature = declaredSignature.getReturnType(); return appendTypeRelationshipConstraintSolver(resultBuilder, formalReturnTypeSignature, actualReturnType, false) && appendConstraintSolvers(resultBuilder, formalReturnTypeSignature, actualReturnType, false); }
public boolean canResolveOperator(OperatorType operatorType, Type returnType, List<? extends Type> argumentTypes) { Signature signature = internalOperator(operatorType, returnType, argumentTypes); return isRegistered(signature); }
public InternalTable build() { flushPage(); return new InternalTable(columnIndexes, pages); }
@Test(expectedExceptions = {IllegalStateException.class}, expectedExceptionsMessageRegExp = "method foo was not found in class io.prestosql.metadata.TestPolymorphicScalarFunction\\$TestMethods") public void testFailIfNotAllMethodsPresent() { SqlScalarFunction.builder(TestMethods.class) .signature(SIGNATURE) .deterministic(true) .choice(choice -> choice .implementation(methodsGroup -> methodsGroup.methods("bigintToBigintReturnExtraParameter")) .implementation(methodsGroup -> methodsGroup.methods("foo"))) .build(); }
@Test(expectedExceptions = {IllegalStateException.class}, expectedExceptionsMessageRegExp = "method foo was not found in class io.prestosql.metadata.TestPolymorphicScalarFunction\\$TestMethods") public void testFailIfNotAllMethodsPresent() { SqlScalarFunction.builder(TestMethods.class) .signature(SIGNATURE) .deterministic(true) .choice(choice -> choice .implementation(methodsGroup -> methodsGroup.methods("bigintToBigintReturnExtraParameter")) .implementation(methodsGroup -> methodsGroup.methods("foo"))) .build(); }
@Test(expectedExceptions = {IllegalStateException.class}, expectedExceptionsMessageRegExp = "two matching methods \\(varcharToBigintReturnFirstExtraParameter and varcharToBigintReturnExtraParameter\\) for parameter types \\[varchar\\(10\\)\\]") public void testFailIfTwoMethodsWithSameArguments() { SqlScalarFunction function = SqlScalarFunction.builder(TestMethods.class) .signature(SIGNATURE) .deterministic(true) .choice(choice -> choice .implementation(methodsGroup -> methodsGroup.methods("varcharToBigintReturnFirstExtraParameter")) .implementation(methodsGroup -> methodsGroup.methods("varcharToBigintReturnExtraParameter"))) .build(); function.specialize(BOUND_VARIABLES, 1, TYPE_REGISTRY, REGISTRY); }