navis opened a new issue, #12779:
URL: https://github.com/apache/druid/issues/12779

   Doing https://github.com/metatron-app/metatron-discovery/issues/4061, I've 
found many of functions in apache calcite lacks operand type inferrer, throwing 
exception for dynamic parameters in validation stage. I've done some hacks for 
fixing them but have got curious how it works in apache druid.
   
   So I've tried in DruidAvaticaHandlerTest with modified SQL 
   ```
   @Test
   public void testParameterBinding() throws Exception
   {
     PreparedStatement statement = client.prepareStatement("SELECT 
replace(dim1, ?, ?) FROM druid.foo");
   }
   ```
   
   and got this
   
   ```
   org.apache.calcite.avatica.AvaticaSqlException: Error -1 (00000) : while 
preparing SQL: SELECT replace(dim1, ?, ?) FROM druid.foo
   
        at org.apache.calcite.avatica.Helper.createException(Helper.java:54)
        at org.apache.calcite.avatica.Helper.createException(Helper.java:41)
        at 
org.apache.calcite.avatica.AvaticaConnection.prepareStatement(AvaticaConnection.java:358)
        at 
org.apache.calcite.avatica.AvaticaConnection.prepareStatement(AvaticaConnection.java:175)
        at 
org.apache.druid.sql.avatica.DruidAvaticaHandlerTest.testParameterBinding(DruidAvaticaHandlerTest.java:1100)
        at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at 
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at 
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:566)
        at 
org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:59)
        at 
org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at 
org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:56)
        at 
org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at 
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
        at 
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
        at 
org.junit.rules.ExpectedException$ExpectedExceptionStatement.evaluate(ExpectedException.java:258)
        at 
org.apache.druid.sql.calcite.util.QueryLogHook$1.evaluate(QueryLogHook.java:95)
        at org.junit.rules.ExternalResource$1.evaluate(ExternalResource.java:54)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at 
org.junit.runners.BlockJUnit4ClassRunner$1.evaluate(BlockJUnit4ClassRunner.java:100)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:366)
        at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:103)
        at 
org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:63)
        at org.junit.runners.ParentRunner$4.run(ParentRunner.java:331)
        at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:79)
        at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:329)
        at org.junit.runners.ParentRunner.access$100(ParentRunner.java:66)
        at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:293)
        at 
org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
        at 
org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
        at org.junit.runners.ParentRunner$3.evaluate(ParentRunner.java:306)
        at org.junit.runners.ParentRunner.run(ParentRunner.java:413)
        at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
        at 
com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
        at 
com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
        at 
com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
        at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
   java.lang.RuntimeException: org.apache.druid.sql.SqlPlanningException: 
org.apache.calcite.runtime.CalciteContextException: At line 1, column 22: 
Illegal use of dynamic parameter
        at 
org.apache.druid.sql.avatica.ErrorHandler.sanitize(ErrorHandler.java:78)
        at org.apache.druid.sql.avatica.DruidMeta.prepare(DruidMeta.java:257)
        at 
org.apache.calcite.avatica.remote.LocalService.apply(LocalService.java:195)
        at 
org.apache.calcite.avatica.remote.Service$PrepareRequest.accept(Service.java:1215)
        at 
org.apache.calcite.avatica.remote.Service$PrepareRequest.accept(Service.java:1186)
        at 
org.apache.calcite.avatica.remote.AbstractHandler.apply(AbstractHandler.java:94)
        at 
org.apache.calcite.avatica.remote.JsonHandler.apply(JsonHandler.java:52)
        at 
org.apache.calcite.avatica.server.AvaticaJsonHandler.handle(AvaticaJsonHandler.java:133)
        at 
org.apache.druid.sql.avatica.DruidAvaticaJsonHandler.handle(DruidAvaticaJsonHandler.java:61)
        at 
org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
        at org.eclipse.jetty.server.Server.handle(Server.java:516)
        at 
org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:388)
        at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:633)
        at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:380)
        at 
org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277)
        at 
org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
        at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
        at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
        at 
org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
        at 
org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
        at 
org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
        at 
org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129)
        at 
org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:383)
        at 
org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:882)
        at 
org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1036)
        at java.base/java.lang.Thread.run(Thread.java:829)
   Caused by: org.apache.druid.sql.SqlPlanningException: 
org.apache.calcite.runtime.CalciteContextException: At line 1, column 22: 
Illegal use of dynamic parameter
        at org.apache.druid.sql.SqlLifecycle.validate(SqlLifecycle.java:247)
        at 
org.apache.druid.sql.SqlLifecycle.validateAndAuthorize(SqlLifecycle.java:198)
        at 
org.apache.druid.sql.avatica.DruidStatement.prepare(DruidStatement.java:182)
        at org.apache.druid.sql.avatica.DruidMeta.prepare(DruidMeta.java:249)
        ... 24 more
   ```
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to