promote log10() to standard function status

This commit is contained in:
Gavin King 2022-01-02 12:28:27 +01:00
parent c48be75d3b
commit fdd1a52e01
5 changed files with 22 additions and 1 deletions

View File

@ -777,6 +777,8 @@ public abstract class Dialect implements ConversionContext {
* </ul>
*
* <ul>
* <li> log10(arg)
* <li> sqrt(arg)
* <li> sign(arg)
* <li> sin(arg)
* <li> cos(arg)

View File

@ -136,6 +136,7 @@ public class OracleDialect extends Dialect {
CommonFunctionFactory.tanh( queryEngine );
CommonFunctionFactory.trunc( queryEngine );
CommonFunctionFactory.log( queryEngine );
CommonFunctionFactory.log10_log( queryEngine );
CommonFunctionFactory.soundex( queryEngine );
CommonFunctionFactory.trim2( queryEngine );
CommonFunctionFactory.initcap( queryEngine );

View File

@ -407,6 +407,12 @@ public class PostgreSQLDialect extends Dialect {
CommonFunctionFactory.degrees( queryEngine );
CommonFunctionFactory.trunc( queryEngine );
CommonFunctionFactory.log( queryEngine );
if ( getVersion().isSameOrAfter(12) ) {
CommonFunctionFactory.log10( queryEngine );
}
else {
queryEngine.getSqmFunctionRegistry().registerAlternateKey( "log10", "log" );
}
CommonFunctionFactory.cbrt( queryEngine );
CommonFunctionFactory.trim2( queryEngine );
CommonFunctionFactory.octetLength( queryEngine );

View File

@ -98,6 +98,18 @@ public class CommonFunctionFactory {
.register();
}
/**
* For Oracle
*/
public static void log10_log(QueryEngine queryEngine) {
queryEngine.getSqmFunctionRegistry().patternDescriptorBuilder( "log10", "log(10,?1)" )
.setExactArgumentCount( 1 )
.setInvariantType(
queryEngine.getTypeConfiguration().getBasicTypeRegistry().resolve( StandardBasicTypes.DOUBLE )
)
.register();
}
public static void log2(QueryEngine queryEngine) {
queryEngine.getSqmFunctionRegistry().namedDescriptorBuilder( "log2" )
.setInvariantType(

View File

@ -157,7 +157,7 @@ public class FunctionTests {
.list();
session.createQuery("select abs(e.theDouble), sign(e.theDouble), sqrt(e.theDouble) from EntityOfBasics e")
.list();
session.createQuery("select exp(e.theDouble), ln(e.theDouble + 1) from EntityOfBasics e")
session.createQuery("select exp(e.theDouble), ln(e.theDouble + 1), log10(e.theDouble) from EntityOfBasics e")
.list();
session.createQuery("select power(e.theDouble + 1, 2.5) from EntityOfBasics e")
.list();