[ https://issues.apache.org/jira/browse/IGNITE-20976?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Pavel Pereslegin updated IGNITE-20976: -------------------------------------- Description: Normalized statement cannot be obtained for 'DELETE' statement with dynamic parameters. It seems that after adjusting the dynamic parameters (see {{ScriptParseResult.SqlDynamicParamsAdjuster}}), the new tree cannot be converted to a string. Reproducer: {code:java} @Test public void testScriptDelete() { String query1 = "SELECT 1;"; String query2 = "DELETE FROM TEST WHERE ID=?"; // Parse separately - ok. StatementParseResult res1 = IgniteSqlParser.parse(query1, StatementParseResult.MODE); StatementParseResult res2 = IgniteSqlParser.parse(query2, StatementParseResult.MODE); System.out.println(res1.statement().toString()); System.out.println(res2.statement().toString()); // Parse script throws "UnsupportedOperationException" for `toString()` from `DELETE` statement. ScriptParseResult scriptRes = IgniteSqlParser.parse(query1 + query2, ScriptParseResult.MODE); for (StatementParseResult res : scriptRes.results()) { System.out.println(res.statement().toString()); } } {code} Output {noformat} SELECT 1 DELETE FROM `TEST` WHERE `ID` = ? SELECT 1 java.lang.UnsupportedOperationException: class org.apache.calcite.sql.SqlSyntax$7: SPECIAL at org.apache.calcite.util.Util.needToImplement(Util.java:1119) at org.apache.calcite.sql.SqlSyntax$7.unparse(SqlSyntax.java:129) at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:385) at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:466) at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:131) at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:156) at org.apache.calcite.sql.SqlNode.toString(SqlNode.java:131) at org.apache.ignite.internal.sql.engine.sql.IgniteSqlParserTest.testScriptDelete(IgniteSqlParserTest.java:59) {noformat} was: Normalized statement cannot be obtained for 'DELETE' statement with dynamic parameters. It seems that after adjusting the dynamic parameters (see {{ScriptParseResult.SqlDynamicParamsAdjuster}}), the new tree cannot be converted to a string. Reproducer: {code:java} @Test public void testScriptDelete() { String query1 = "SELECT 1;"; String query2 = "DELETE FROM TEST WHERE ID=?"; // Parse separately - ok. StatementParseResult res1 = IgniteSqlParser.parse(query1, StatementParseResult.MODE); StatementParseResult res2 = IgniteSqlParser.parse(query2, StatementParseResult.MODE); System.out.println(res1.toString()); System.out.println(res2.toString()); // Parse script throws "UnsupportedOperationException" by `toString()` for `DELETE` statement. ScriptParseResult scriptRes = IgniteSqlParser.parse(query1 + query2, ScriptParseResult.MODE); for (StatementParseResult res : scriptRes.results()) { System.out.println(res.toString()); } } {code} Output {noformat} StatementParseResult [statement=SELECT 1, statement=SELECT 1] StatementParseResult [statement=DELETE FROM `TEST` WHERE `ID` = ?, statement=DELETE FROM `TEST` WHERE `ID` = ?] StatementParseResult [statement=SELECT 1, statement=SELECT 1] org.apache.ignite.internal.lang.IgniteInternalException: IGN-CMN-65535 TraceId:8a5d938f-89f2-414f-bb83-6623b919b61f class org.apache.calcite.sql.SqlSyntax$7: SPECIAL at org.apache.ignite.internal.tostring.IgniteToStringBuilder.toStringImpl0(IgniteToStringBuilder.java:1810) at org.apache.ignite.internal.tostring.IgniteToStringBuilder.toStringImpl(IgniteToStringBuilder.java:1646) at org.apache.ignite.internal.tostring.IgniteToStringBuilder.toString(IgniteToStringBuilder.java:804) at org.apache.ignite.internal.tostring.IgniteToStringBuilder.toString(IgniteToStringBuilder.java:772) at org.apache.ignite.internal.sql.engine.sql.StatementParseResult.toString(StatementParseResult.java:70) at org.apache.ignite.internal.sql.engine.sql.IgniteSqlParserTest.testScriptDelete(IgniteSqlParserTest.java:59) 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.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.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.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:138) at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:68) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at java.base/java.util.ArrayList.forEach(ArrayList.java:1541) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141) at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137) at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139) at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73) at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138) at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95) at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35) at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57) at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:147) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:127) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:90) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:55) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:102) at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:54) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114) at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86) at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86) at org.junit.platform.launcher.core.SessionPerRequestLauncher.execute(SessionPerRequestLauncher.java:53) at com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:57) at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38) at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11) at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35) at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:232) at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:55) Caused by: java.lang.UnsupportedOperationException: class org.apache.calcite.sql.SqlSyntax$7: SPECIAL at org.apache.calcite.util.Util.needToImplement(Util.java:1119) at org.apache.calcite.sql.SqlSyntax$7.unparse(SqlSyntax.java:129) at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:385) at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:466) at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:131) at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:156) at org.apache.calcite.sql.SqlNode.toString(SqlNode.java:131) at java.base/java.lang.String.valueOf(String.java:2951) at java.base/java.lang.StringBuilder.append(StringBuilder.java:173) at org.apache.ignite.internal.lang.IgniteStringBuilder.app(IgniteStringBuilder.java:116) at org.apache.ignite.internal.tostring.StringBuilderLimitedLength.app(StringBuilderLimitedLength.java:108) at org.apache.ignite.internal.tostring.IgniteToStringBuilder.toString(IgniteToStringBuilder.java:926) at org.apache.ignite.internal.tostring.IgniteToStringBuilder.toString(IgniteToStringBuilder.java:883) at org.apache.ignite.internal.tostring.IgniteToStringBuilder.appendVals(IgniteToStringBuilder.java:1931) at org.apache.ignite.internal.tostring.IgniteToStringBuilder.toStringImpl0(IgniteToStringBuilder.java:1799) ... 75 more {noformat} > Sql. Multistatement dynamic parameters adjusting works incorrect for DELETE > operator. > ------------------------------------------------------------------------------------- > > Key: IGNITE-20976 > URL: https://issues.apache.org/jira/browse/IGNITE-20976 > Project: Ignite > Issue Type: Bug > Components: sql > Reporter: Pavel Pereslegin > Priority: Major > Labels: ignite-3 > > Normalized statement cannot be obtained for 'DELETE' statement with dynamic > parameters. > It seems that after adjusting the dynamic parameters (see > {{ScriptParseResult.SqlDynamicParamsAdjuster}}), the new tree cannot be > converted to a string. > Reproducer: > {code:java} > @Test > public void testScriptDelete() { > String query1 = "SELECT 1;"; > String query2 = "DELETE FROM TEST WHERE ID=?"; > // Parse separately - ok. > StatementParseResult res1 = IgniteSqlParser.parse(query1, > StatementParseResult.MODE); > StatementParseResult res2 = IgniteSqlParser.parse(query2, > StatementParseResult.MODE); > System.out.println(res1.statement().toString()); > System.out.println(res2.statement().toString()); > // Parse script throws "UnsupportedOperationException" for > `toString()` from `DELETE` statement. > ScriptParseResult scriptRes = IgniteSqlParser.parse(query1 + query2, > ScriptParseResult.MODE); > for (StatementParseResult res : scriptRes.results()) { > System.out.println(res.statement().toString()); > } > } > {code} > Output > {noformat} > SELECT 1 > DELETE FROM `TEST` > WHERE `ID` = ? > SELECT 1 > java.lang.UnsupportedOperationException: class > org.apache.calcite.sql.SqlSyntax$7: SPECIAL > at org.apache.calcite.util.Util.needToImplement(Util.java:1119) > at org.apache.calcite.sql.SqlSyntax$7.unparse(SqlSyntax.java:129) > at org.apache.calcite.sql.SqlOperator.unparse(SqlOperator.java:385) > at org.apache.calcite.sql.SqlDialect.unparseCall(SqlDialect.java:466) > at org.apache.calcite.sql.SqlCall.unparse(SqlCall.java:131) > at org.apache.calcite.sql.SqlNode.toSqlString(SqlNode.java:156) > at org.apache.calcite.sql.SqlNode.toString(SqlNode.java:131) > at > org.apache.ignite.internal.sql.engine.sql.IgniteSqlParserTest.testScriptDelete(IgniteSqlParserTest.java:59) > {noformat} -- This message was sent by Atlassian Jira (v8.20.10#820010)