use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlFunction in project drill by axbaretto.
the class DrillOperatorTable method populateWrappedCalciteOperators.
private void populateWrappedCalciteOperators() {
for (SqlOperator calciteOperator : inner.getOperatorList()) {
final SqlOperator wrapper;
if (calciteOperator instanceof SqlAggFunction) {
wrapper = new DrillCalciteSqlAggFunctionWrapper((SqlAggFunction) calciteOperator, getFunctionListWithInference(calciteOperator.getName()));
} else if (calciteOperator instanceof SqlFunction) {
wrapper = new DrillCalciteSqlFunctionWrapper((SqlFunction) calciteOperator, getFunctionListWithInference(calciteOperator.getName()));
} else {
final String drillOpName = FunctionCallFactory.replaceOpWithFuncName(calciteOperator.getName());
final List<DrillFuncHolder> drillFuncHolders = getFunctionListWithInference(drillOpName);
if (drillFuncHolders.isEmpty() || calciteOperator == SqlStdOperatorTable.UNARY_MINUS || calciteOperator == SqlStdOperatorTable.UNARY_PLUS) {
continue;
}
wrapper = new DrillCalciteSqlOperatorWrapper(calciteOperator, drillOpName, drillFuncHolders);
}
calciteToWrapper.put(calciteOperator, wrapper);
}
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlFunction in project flink by apache.
the class SqlValidatorImpl method validateCall.
public void validateCall(SqlCall call, SqlValidatorScope scope) {
final SqlOperator operator = call.getOperator();
if ((call.operandCount() == 0) && (operator.getSyntax() == SqlSyntax.FUNCTION_ID) && !call.isExpanded() && !this.config.sqlConformance().allowNiladicParentheses()) {
// SqlIdentifier.)
throw handleUnresolvedFunction(call, (SqlFunction) operator, ImmutableList.of(), null);
}
SqlValidatorScope operandScope = scope.getOperandScope(call);
if (operator instanceof SqlFunction && ((SqlFunction) operator).getFunctionType() == SqlFunctionCategory.MATCH_RECOGNIZE && !(operandScope instanceof MatchRecognizeScope)) {
throw newValidationError(call, Static.RESOURCE.functionMatchRecognizeOnly(call.toString()));
}
// Delegate validation to the operator.
operator.validateCall(call, this, scope, operandScope);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlFunction in project flink by apache.
the class LegacyScalarFunctionConvertRule method convert.
@Override
public Optional<RexNode> convert(CallExpression call, ConvertContext context) {
FunctionDefinition def = call.getFunctionDefinition();
if (def instanceof ScalarFunctionDefinition) {
ScalarFunction scalaFunc = ((ScalarFunctionDefinition) def).getScalarFunction();
FunctionIdentifier identifier = call.getFunctionIdentifier().orElse(FunctionIdentifier.of(generateInlineFunctionName(scalaFunc)));
SqlFunction sqlFunction = UserDefinedFunctionUtils.createScalarSqlFunction(identifier, scalaFunc.toString(), scalaFunc, context.getTypeFactory());
return Optional.of(context.getRelBuilder().call(sqlFunction, toRexNodes(context, call.getChildren())));
}
return Optional.empty();
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlFunction in project druid by druid-io.
the class ExpressionsTest method testRoundWithNanShouldRoundTo0.
@Test
public void testRoundWithNanShouldRoundTo0() {
final SqlFunction roundFunction = new RoundOperatorConversion().calciteOperator();
testHelper.testExpression(roundFunction, testHelper.makeInputRef("nan"), DruidExpression.ofExpression(ColumnType.DOUBLE, DruidExpression.functionCall("round"), ImmutableList.of(DruidExpression.ofColumn(ColumnType.DOUBLE, "nan"))), 0D);
testHelper.testExpression(roundFunction, testHelper.makeInputRef("fnan"), DruidExpression.ofExpression(ColumnType.FLOAT, DruidExpression.functionCall("round"), ImmutableList.of(DruidExpression.ofColumn(ColumnType.FLOAT, "fnan"))), 0D);
}
use of org.apache.beam.vendor.calcite.v1_28_0.org.apache.calcite.sql.SqlFunction in project druid by druid-io.
the class ExpressionsTest method testRoundWithInfinityShouldRoundTo0.
@Test
public void testRoundWithInfinityShouldRoundTo0() {
final SqlFunction roundFunction = new RoundOperatorConversion().calciteOperator();
// CHECKSTYLE.OFF: Regexp
testHelper.testExpression(roundFunction, testHelper.makeInputRef("inf"), DruidExpression.ofExpression(ColumnType.DOUBLE, DruidExpression.functionCall("round"), ImmutableList.of(DruidExpression.ofColumn(ColumnType.DOUBLE, "inf"))), Double.MAX_VALUE);
testHelper.testExpression(roundFunction, testHelper.makeInputRef("-inf"), DruidExpression.ofExpression(ColumnType.DOUBLE, DruidExpression.functionCall("round"), ImmutableList.of(DruidExpression.ofColumn(ColumnType.DOUBLE, "-inf"))), -1 * Double.MAX_VALUE);
testHelper.testExpression(roundFunction, testHelper.makeInputRef("finf"), DruidExpression.ofExpression(ColumnType.FLOAT, DruidExpression.functionCall("round"), ImmutableList.of(DruidExpression.ofColumn(ColumnType.FLOAT, "finf"))), Double.MAX_VALUE);
testHelper.testExpression(roundFunction, testHelper.makeInputRef("-finf"), DruidExpression.ofExpression(ColumnType.FLOAT, DruidExpression.functionCall("round"), ImmutableList.of(DruidExpression.ofColumn(ColumnType.FLOAT, "-finf"))), -1 * Double.MAX_VALUE);
// CHECKSTYLE.ON: Regexp
}
Aggregations