DonnyZone opened a new pull request #1675: [CALCITE-3563] Convert function operand type to match implementation if necessary in runtime URL: https://github.com/apache/calcite/pull/1675 Current now, Calcite's runtime for method call is not efficient and "intelligent" enough. For some cases, a query run successfully just "by chance". In general, there are mainly two approaches to implement a method call, `MethodImplementor` and `MethodNameImplementor`. `MethodImplementor` relies user-specified method with fixed parameter types, while `MethodNameImplementor` looks up an appropriate method according to method name and argument types dynamically. (1) `MethodImplementor` skips to check argument types in runtime. Sometimes, the method called may be different with the one defined in BuiltInMethod. What's more, even the arguments are illegal, we can only get the exception in the compilation time after codegen. It is too late. (2) `MethodNameImplementor` fails to find the suitable method in some cases. For example, the following test fails with exception > java.lang.RuntimeException: while resolving method 'mod[class java.math.BigDecimal, long]' in class class org.apache.calcite.runtime.SqlFunctions ``` @Test public void tes() { CalciteAssert.that() .query("SELECT mod(12.5, cast(3 as bigint))") .returns("EXPR$0=0.5\n"); } ``` However, there is already an implementation `mod(decimal, decimal)` in SqlFunctions that can accept assignable long typed argument. As we discussed in CALCITE-3565, though decimal type is assignable from other types, we need to make cast explicitly. This PR makes changes on: (1) A stronger interface for method call expression in Calcite core. (2) Both `MethodImplementor` and `MethodNameImplementor` use this interface. (3) Fix some trivial issues exposed during the implementation.
---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
