I am using Apache Calcite to add some built-in functions. Now, I want to implement the GROUP_CONCAT
function like MySQL to concat one column with one separator.
SELECT GROUP_CONCAT(n_name, '|') FROM nation GROUP BY n_lang;
The function class as follows:
public class SqlGroupConcatFunction extends SqlAggFunction {
public SqlGroupConcatFunction() {
super(
"GROUP_CONCAT",
null,
SqlKind.GROUP_CONCAT,
ReturnTypes.VARCHAR_2000,
InferTypes.FIRST_KNOWN,
OperandTypes.family(SqlTypeFamily.ANY, SqlTypeFamily.STRING),
SqlFunctionCategory.STRING,
false,
false);
}
}
Now, I want this function can accept one parameter(without separator) or two parameters. When accept only one parameter, set the second parameter with default value.
I do not find any methods to set the default argument value in Calcite. Does have method to implement this feature?