Build-in functions currently must have a single type signature. This is not very convenient, as there are a couple of SQL functions, that actually can cope with different types. Mainly, these are date & time related functions as extract or date_trunc. In order to support these functions for different types, the function registration and retrieval has to cope with type signature sets. Currently, the extract function looks like
ExtractFunction::ExtractFunction()
: Function("EXTRACT", INT, Types({INT, TIMESTAMP}))
{
}
It should be changed to
ExtractFunction::ExtractFunction()
: Function("EXTRACT", {INT,INT,INT}, Types({INT, DATE},{INT, TIME},{INT, TIMESTAMP}))
{
}
Here we have exactly the same number of return types as signature sets. Each signature set corresponds to one overload. The stack machine now has to evaluate all overloads and call the overload with the best matching signature. If no signature matches perfectly, type casting has to be used to find a match.
Build-in functions currently must have a single type signature. This is not very convenient, as there are a couple of SQL functions, that actually can cope with different types. Mainly, these are date & time related functions as extract or date_trunc. In order to support these functions for different types, the function registration and retrieval has to cope with type signature sets. Currently, the extract function looks like
It should be changed to
Here we have exactly the same number of return types as signature sets. Each signature set corresponds to one overload. The stack machine now has to evaluate all overloads and call the overload with the best matching signature. If no signature matches perfectly, type casting has to be used to find a match.