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)));
}
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;
}
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;
}
}
Aggregations