So I have a custom SqlFunction
:
public static final class SqlApproximatePercentileFunction extends SqlAggFunction {
public SqlApproximatePercentileFunction() {
super(
"APPROX_PERCENTILE",
null,
SqlKind.OTHER_FUNCTION,
ReturnTypes.DOUBLE,
null,
family(SqlTypeFamily.NUMERIC, SqlTypeFamily.NUMERIC),
SqlFunctionCategory.USER_DEFINED_FUNCTION,
false,
false);
}
}
The details of APPROX_PERCENTILE
is not so relevant, just FYI:
https://prestodb.io/docs/current/functions/aggregate.html#approximate-aggregate-functions
I want to detect there is an error when a user query swaps arguments
sql = "select approx_percentile(l.price, 0.6) from lineitem l"; // correct inputs
sql = "select approx_percentile(0.6, l.price) from lineitem l"; // incorrect inputs
The problem is that in my record type definition, column price
from table l
is of SqlTypeName.NUMERIC
which is the same as the SqlTypeName
for 0.6
.
What can we do in calcite to differentiate a numerical column from a numerical literal?