use of io.confluent.ksql.function.udf.UdfSchemaProvider in project ksql by confluentinc.
the class Round method provideDecimalSchemaWithDecimalPlaces.
// Invoked via reflection
@SuppressWarnings("unused")
@UdfSchemaProvider
public static SqlType provideDecimalSchemaWithDecimalPlaces(final List<SqlArgument> params) {
final SqlType s0 = params.get(0).getSqlTypeOrThrow();
if (s0.baseType() != SqlBaseType.DECIMAL) {
throw new KsqlException("The schema provider method for round expects a BigDecimal parameter" + "type as first parameter.");
}
final SqlType s1 = params.get(1).getSqlTypeOrThrow();
if (s1.baseType() != SqlBaseType.INTEGER) {
throw new KsqlException("The schema provider method for round expects an Integer parameter" + "type as second parameter.");
}
// the scale of the return type. See https://github.com/confluentinc/ksql/issues/6235.
return s0;
}
use of io.confluent.ksql.function.udf.UdfSchemaProvider in project ksql by confluentinc.
the class Round method provideDecimalSchema.
// Invoked via reflection
@SuppressWarnings("unused")
@UdfSchemaProvider
public static SqlType provideDecimalSchema(final List<SqlArgument> params) {
final SqlType s0 = params.get(0).getSqlTypeOrThrow();
if (s0.baseType() != SqlBaseType.DECIMAL) {
throw new KsqlException("The schema provider method for round expects a BigDecimal parameter" + "type as a parameter.");
}
final SqlDecimal param = (SqlDecimal) s0;
return SqlDecimal.of(param.getPrecision() - param.getScale(), 0);
}
Aggregations