use of org.apache.beam.sdk.extensions.sql.zetasql.translation.ZetaSqlScalarFunctionImpl in project beam by apache.
the class BeamCalcRelType method canImplement.
@Override
protected boolean canImplement(RexCall call) {
final SqlOperator operator = call.getOperator();
RexImpTable.RexCallImplementor implementor = RexImpTable.INSTANCE.get(operator);
if (implementor == null) {
// Reject methods with no implementation
return false;
}
if (operator instanceof SqlUserDefinedFunction) {
SqlUserDefinedFunction udf = (SqlUserDefinedFunction) call.op;
if (udf.function instanceof ZetaSqlScalarFunctionImpl) {
ZetaSqlScalarFunctionImpl scalarFunction = (ZetaSqlScalarFunctionImpl) udf.function;
if (!scalarFunction.functionGroup.equals(BeamZetaSqlCatalog.USER_DEFINED_JAVA_SCALAR_FUNCTIONS)) {
// Reject ZetaSQL Builtin Scalar Functions
return false;
}
for (RexNode operand : call.getOperands()) {
if (operand instanceof RexLocalRef) {
if (!supportsType(operand.getType())) {
LOG.error("User-defined function {} received unsupported operand type {}.", call.op.getName(), ((RexLocalRef) operand).getType());
return false;
}
} else {
LOG.error("User-defined function {} received unrecognized operand kind {}.", call.op.getName(), operand.getKind());
return false;
}
}
} else {
// Reject other UDFs
return false;
}
} else {
// Reject Calcite implementations
return false;
}
return true;
}
Aggregations