Skip to content

Commit

Permalink
remove PowerReturnTypeResolver
Browse files Browse the repository at this point in the history
You can't do "exact decimal" exponentiation. For the same reason that
sqrt() is of type Double in the JPA, pow(decimal, 0.5) is also of type
Double.

Yes, yes, I know that some dbs (Postgres!) claim that the return type is
NUMERIC for NUMERIC arguments. But go on, try it: yes, the return type of
typed NUMERIC, but then it has a very suspicious number of digits. Hrrm....
17 decimal digits, now why does that specific number ring a bell?
  • Loading branch information
gavinking committed Jan 31, 2022
1 parent 5b5c76a commit 385cba7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1982,9 +1982,11 @@ public static void math(QueryEngine queryEngine) {
.register();

queryEngine.getSqmFunctionRegistry().namedDescriptorBuilder( "power" )
.setInvariantType(
queryEngine.getTypeConfiguration().getBasicTypeRegistry().resolve( StandardBasicTypes.DOUBLE )
)
.setExactArgumentCount( 2 )
.setParameterTypes(NUMERIC, NUMERIC)
.setReturnTypeResolver( new PowerReturnTypeResolver( queryEngine.getTypeConfiguration() ) )
.register();
}

Expand All @@ -2000,9 +2002,11 @@ public static void mod_operator(QueryEngine queryEngine) {

public static void power_expLn(QueryEngine queryEngine) {
queryEngine.getSqmFunctionRegistry().patternDescriptorBuilder( "power", "exp(ln(?1)*?2)" )
.setInvariantType(
queryEngine.getTypeConfiguration().getBasicTypeRegistry().resolve( StandardBasicTypes.DOUBLE )
)
.setExactArgumentCount( 2 )
.setParameterTypes(NUMERIC, NUMERIC)
.setReturnTypeResolver( new PowerReturnTypeResolver( queryEngine.getTypeConfiguration() ) )
.register();
}

Expand Down

This file was deleted.

0 comments on commit 385cba7

Please sign in to comment.