First of all, you don’t need to extend the Dialect
to contribute functions. In fact, it is very much discouraged to do so. The way to go is to define a custom FunctionContributor
which is loaded through the ServiceLoader
mechanism.
In that, you can acquire the current dialect and register the functions for the respective dialect, all within one block of code, instead of sprinkling that code across different dialect subclasses.
You can override the arguments validator by registering the function like this:
functionContributions.getFunctionRegistry().patternDescriptorBuilder("convert_tz", "convert_tz(?1, ?2, ?3) ")
.setInvariantType( functionContributions.getTypeConfiguration().getBasicTypeRegistry().resolve(StandardBasicTypes.DATE) )
.setArgumentsValidator(StandardArgumentsValidators.NONE)
.register();