Search in sources :

Example 26 with OperatorType

use of io.prestosql.spi.function.OperatorType in project hetu-core by openlookeng.

the class SpatialJoinUtils method getFlippedFunctionHandle.

public static FunctionHandle getFlippedFunctionHandle(CallExpression callExpression, FunctionAndTypeManager functionAndTypeManager) {
    FunctionMetadata callExpressionMetadata = functionAndTypeManager.getFunctionMetadata(callExpression.getFunctionHandle());
    checkArgument(callExpressionMetadata.getOperatorType().isPresent());
    OperatorType operatorType = flip(callExpressionMetadata.getOperatorType().get());
    List<TypeSignatureProvider> typeProviderList = fromTypes(callExpression.getArguments().stream().map(RowExpression::getType).collect(toImmutableList()));
    checkArgument(typeProviderList.size() == 2, "Expected there to be only two arguments in type provider");
    return functionAndTypeManager.resolveOperatorFunctionHandle(operatorType, ImmutableList.of(typeProviderList.get(1), typeProviderList.get(0)));
}
Also used : TypeSignatureProvider(io.prestosql.sql.analyzer.TypeSignatureProvider) FunctionMetadata(io.prestosql.spi.function.FunctionMetadata) RowExpression(io.prestosql.spi.relation.RowExpression) OperatorType(io.prestosql.spi.function.OperatorType)

Example 27 with OperatorType

use of io.prestosql.spi.function.OperatorType in project hetu-core by openlookeng.

the class SpatialJoinUtils method isSupportedSpatialComparison.

private static boolean isSupportedSpatialComparison(CallExpression expression, FunctionAndTypeManager functionAndTypeManager) {
    String functionName = functionAndTypeManager.getFunctionMetadata(expression.getFunctionHandle()).getName().getObjectName();
    if (!Signature.isMangleOperator(functionName)) {
        return false;
    }
    OperatorType operatorType = Signature.unmangleOperator(functionName);
    if (operatorType.equals(LESS_THAN) || operatorType.equals(LESS_THAN_OR_EQUAL)) {
        return isSTDistance(expression.getArguments().get(0), functionAndTypeManager);
    }
    if (operatorType.equals(GREATER_THAN) || operatorType.equals(GREATER_THAN_OR_EQUAL)) {
        return isSTDistance(expression.getArguments().get(1), functionAndTypeManager);
    }
    return false;
}
Also used : OperatorType(io.prestosql.spi.function.OperatorType)

Example 28 with OperatorType

use of io.prestosql.spi.function.OperatorType in project hetu-core by openlookeng.

the class CallExpression method absEquals.

@Override
public boolean absEquals(Object o) {
    if (this == o) {
        return true;
    }
    if (o == null || getClass() != o.getClass() || !(o instanceof CallExpression)) {
        return false;
    }
    try {
        CallExpression that = (CallExpression) o;
        OperatorType operator = OperatorType.valueOf(this.displayName.toUpperCase(Locale.ENGLISH));
        OperatorType operatorThat = OperatorType.valueOf(that.displayName.toUpperCase(Locale.ENGLISH));
        if (!operator.isComparisonOperator() || !operatorThat.isComparisonOperator() || this.getArguments().size() != 2 || that.getArguments().size() != 2) {
            return false;
        }
        RowExpression tempLeft = this.getArguments().get(0);
        RowExpression tempThatLeft = that.getArguments().get(0);
        if (tempLeft instanceof VariableReferenceExpression && tempThatLeft instanceof VariableReferenceExpression) {
            tempLeft = new VariableReferenceExpression(getActualColName(((VariableReferenceExpression) tempLeft).getName()), tempLeft.getType());
            tempThatLeft = new VariableReferenceExpression(getActualColName(((VariableReferenceExpression) tempThatLeft).getName()), tempThatLeft.getType());
        }
        // Need to check for right incase expr is 5=id
        return ((operator == operatorThat) && Objects.equals(tempLeft, tempThatLeft) && Objects.equals(this.getArguments().get(1), that.getArguments().get(1)));
    } catch (IllegalArgumentException e) {
        return false;
    }
}
Also used : OperatorType(io.prestosql.spi.function.OperatorType)

Aggregations

OperatorType (io.prestosql.spi.function.OperatorType)28 CallExpression (io.prestosql.spi.relation.CallExpression)11 PrestoException (io.prestosql.spi.PrestoException)10 Signature (io.prestosql.spi.function.Signature)9 ImmutableList (com.google.common.collect.ImmutableList)8 FunctionMetadata (io.prestosql.spi.function.FunctionMetadata)8 TypeSignature (io.prestosql.spi.type.TypeSignature)8 TypeSignature.parseTypeSignature (io.prestosql.spi.type.TypeSignature.parseTypeSignature)8 List (java.util.List)8 BuiltInFunctionHandle (io.prestosql.spi.function.BuiltInFunctionHandle)7 RowExpression (io.prestosql.spi.relation.RowExpression)7 FunctionHandle (io.prestosql.spi.function.FunctionHandle)6 Slice (io.airlift.slice.Slice)5 SqlType (io.prestosql.spi.function.SqlType)5 SpecialForm (io.prestosql.spi.relation.SpecialForm)5 Type (io.prestosql.spi.type.Type)5 Objects.requireNonNull (java.util.Objects.requireNonNull)5 ImmutableSet (com.google.common.collect.ImmutableSet)4 SqlScalarFunction (io.prestosql.metadata.SqlScalarFunction)4 UsedByGeneratedCode (io.prestosql.spi.annotation.UsedByGeneratedCode)4