[jira] [Updated] (CALCITE-6246) Unable to find the correct function signature when using named parameters with omitting arguments
[ https://issues.apache.org/jira/browse/CALCITE-6246?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Feng Jin updated CALCITE-6246: -- Description: When we use named parameters, if a non-mandatory parameter is omitted, it will be automatically filled with a DEFAULT node. However, the default return type of the DEFAULT node is ANY. This will cause some issues when inferring the function signature. Take the unit test below as an example. org.apache.calcite.test.UdfTest#testScalarFunctionWithParameterWithOptional {code:java} // Some comments here @Test void testScalarFunctionWithParameterWithOptional() { final String sql = "select \"adhoc\".my_det_plus() as p\n" + "from \"adhoc\".EMPLOYEES"; final AtomicInteger c = Smalls.MyDeterministicPlusFunction.INSTANCE_COUNT.get(); final int before = c.get(); withUdf() .with("caseSensitive", false) .query(sql).returnsUnordered("P=110", "P=120", "P=110", "P=110"); final int after = c.get(); assertThat(after, is(before + 1)); } {code} We will get the following error: {code:shell} java.sql.SQLException: Error while executing SQL "select "adhoc".my_det_plus() as p from "adhoc".EMPLOYEES": From line 1, column 16 to line 1, column 28: No match found for function signature MY_DET_PLUS() at org.apache.calcite.avatica.Helper.createException(Helper.java:56) at org.apache.calcite.avatica.Helper.createException(Helper.java:41) at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:164) at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:228) at org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:543) at org.apache.calcite.test.CalciteAssert$AssertQuery.lambda$returns$1(CalciteAssert.java:1455) at org.apache.calcite.test.CalciteAssert$AssertQuery.withConnection(CalciteAssert.java:1394) at org.apache.calcite.test.CalciteAssert$AssertQuery.returns(CalciteAssert.java:1453) at org.apache.calcite.test.CalciteAssert$AssertQuery.returns(CalciteAssert.java:1443) at org.apache.calcite.test.CalciteAssert$AssertQuery.returnsUnordered(CalciteAssert.java:1465) at org.apache.calcite.test.UdfTest.testScalarFunctionWithParameterWithOptional(UdfTest.java:242) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498) at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727) at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131) at org.junit.jupiter.engine.extension.SameThreadTimeoutInvocation.proceed(SameThreadTimeoutInvocation.java:45) at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:156) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:147) at org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:86) at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(InterceptingExecutableInvoker.java:103) at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.lambda$invoke$0(InterceptingExecutableInvoker.java:93) at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45) at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37) at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:92) at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:86) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$7(TestMethodTestDescriptor.java:217) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:213) at org.junit.jupiter.engine.de
[jira] [Updated] (CALCITE-6246) Unable to find the correct function signature when using named parameters with omitting arguments
[ https://issues.apache.org/jira/browse/CALCITE-6246?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Feng Jin updated CALCITE-6246: -- Summary: Unable to find the correct function signature when using named parameters with omitting arguments (was: DEFAULT node returns argument type instead of ANY When using named parameter) > Unable to find the correct function signature when using named parameters > with omitting arguments > - > > Key: CALCITE-6246 > URL: https://issues.apache.org/jira/browse/CALCITE-6246 > Project: Calcite > Issue Type: Bug > Components: core >Reporter: Feng Jin >Assignee: Feng Jin >Priority: Major > > When we use named parameters, if a non-mandatory parameter is omitted, it > will be automatically filled with a DEFAULT node. However, the default return > type of the DEFAULT node is ANY. This will cause some issues when inferring > the function's type. > Take the unit test below as an example. > org.apache.calcite.test.UdfTest#testScalarFunctionWithParameterWithOptional > {code:java} > // Some comments here > @Test void testScalarFunctionWithParameterWithOptional() { > final String sql = "select \"adhoc\".my_det_plus() as p\n" > + "from \"adhoc\".EMPLOYEES"; > final AtomicInteger c = > Smalls.MyDeterministicPlusFunction.INSTANCE_COUNT.get(); > final int before = c.get(); > withUdf() > .with("caseSensitive", false) > .query(sql).returnsUnordered("P=110", > "P=120", > "P=110", > "P=110"); > final int after = c.get(); > assertThat(after, is(before + 1)); > } > {code} > We will get the following error: > {code:shell} > java.sql.SQLException: Error while executing SQL "select > "adhoc".my_det_plus() as p > from "adhoc".EMPLOYEES": From line 1, column 16 to line 1, column 28: No > match found for function signature MY_DET_PLUS() > at org.apache.calcite.avatica.Helper.createException(Helper.java:56) > at org.apache.calcite.avatica.Helper.createException(Helper.java:41) > at > org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:164) > at > org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:228) > at > org.apache.calcite.test.CalciteAssert.assertQuery(CalciteAssert.java:543) > at > org.apache.calcite.test.CalciteAssert$AssertQuery.lambda$returns$1(CalciteAssert.java:1455) > at > org.apache.calcite.test.CalciteAssert$AssertQuery.withConnection(CalciteAssert.java:1394) > at > org.apache.calcite.test.CalciteAssert$AssertQuery.returns(CalciteAssert.java:1453) > at > org.apache.calcite.test.CalciteAssert$AssertQuery.returns(CalciteAssert.java:1443) > at > org.apache.calcite.test.CalciteAssert$AssertQuery.returnsUnordered(CalciteAssert.java:1465) > at > org.apache.calcite.test.UdfTest.testScalarFunctionWithParameterWithOptional(UdfTest.java:242) > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at > sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) > at > sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) > at java.lang.reflect.Method.invoke(Method.java:498) > at > org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727) > at > org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131) > at > org.junit.jupiter.engine.extension.SameThreadTimeoutInvocation.proceed(SameThreadTimeoutInvocation.java:45) > at > org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:156) > at > org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:147) > at > org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:86) > at > org.junit.jupiter.engine.execution.InterceptingExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(InterceptingExecutableInvoker.java:103) > at > org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.lambda$invoke$0(InterceptingExecutableInvoker.java:93) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64) > at > org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45) >