[ 
https://issues.apache.org/jira/browse/CALCITE-4028?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17118194#comment-17118194
 ] 

Julian Hyde edited comment on CALCITE-4028 at 5/28/20, 1:01 AM:
----------------------------------------------------------------

I added line-breaks. They make the error stack a bit more decipherable.

Sorry about the {{Baz}}. It's generated code. I think there's a tracing option 
to output the generated code with line numbers.

I have a couple of theories. One is that you should not be calling 
{{JdbcSchema.create}} or {{SchemaPlus.add}}, because it fails to link the 
schema to its parent, only to add the child to the parent's children.  
{{SchemaFactory.create}} would be better. 

Another is that MSSQL has 3 levels (database, catalog, table) compared to 
MySQL's two (database, table) and therefore you need to add your catalog 
"ivydb" to the hierarchy.

By the way, if these are not credentials you want the world to see, you should 
change them.


was (Author: julianhyde):
The error stack is a bit more decipherable with line-breaks.

Sorry about the {{Baz}}. It's generated code. I think there's a tracing option 
to output the generated code with line numbers.

I have a couple of theories. One is that you should not be calling 
{{JdbcSchema.create}} or {{SchemaPlus.add}}, because it fails to link the 
schema to its parent, only to add the child to the parent's children.  
{{SchemaFactory.create}} would be better. 

Another is that MSSQL has 3 levels (database, catalog, table) compared to 
MySQL's two (database, table) and therefore you need to add your catalog 
"ivydb" to the hierarchy.

By the way, if these are not credentials you want the world to see, you should 
change them.

> Unknown error in simple query from JDBCSchema connection to MS SqlServer
> ------------------------------------------------------------------------
>
>                 Key: CALCITE-4028
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4028
>             Project: Calcite
>          Issue Type: Bug
>          Components: jdbc-adapter
>    Affects Versions: 1.23.0
>            Reporter: David Hait
>            Priority: Major
>
> I tried to replicate the "Background" example, but with MSSQL instead of 
> MySql.  This is failing and it is not obvious why - the exception and message 
> do not give enough information.
> {code}
> BasicDataSource dataSource = new BasicDataSource();
> dataSource.setUrl("jdbc:sqlserver://tsql202.dc.optionmetrics.com");
> dataSource.setUsername("sa");
> dataSource.setPassword("singular1");
> dataSource.setDefaultCatalog("ivydb");
> dataSource.setDefaultSchema("dbo");
> Schema schema = JdbcSchema.create(rootSchema,"sql",dataSource,null,null);
> rootSchema.add("dbo",schema);
> Statement statement = calciteConnection.createStatement();
> var rs2 = statement.executeQuery("SELECT SecurityID from dbo.SECURITY");
> System.out.println(rs2);
> {code}
> This gave an undecipherable exception:
> (it's got that "Baz.bind" thing):
>  
> {noformat}
> java.sql.SQLException: Error while executing SQL "SELECT  SecurityID from 
> dbo.SECURITY": nulljava.sql.SQLException: Error while executing SQL "SELECT  
> SecurityID from dbo.SECURITY": null
>  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:163)
>  at 
> org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:227)
>  at 
> com.optionmetrics.adamo.AdamoApplicationTests.calciteDriverTest(AdamoApplicationTests.java:41)
>  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:686)
>  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:149)
>  at 
> org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestableMethod(TimeoutExtension.java:140)
>  at 
> org.junit.jupiter.engine.extension.TimeoutExtension.interceptTestMethod(TimeoutExtension.java:84)
>  at 
> org.junit.jupiter.engine.execution.ExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(ExecutableInvoker.java:115)
>  at 
> org.junit.jupiter.engine.execution.ExecutableInvoker.lambda$invoke$0(ExecutableInvoker.java:105)
>  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.ExecutableInvoker.invoke(ExecutableInvoker.java:104)
>  at 
> org.junit.jupiter.engine.execution.ExecutableInvoker.invoke(ExecutableInvoker.java:98)
>  at 
> org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeTestMethod$6(TestMethodTestDescriptor.java:212)
>  at 
> org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
>  at 
> org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeTestMethod(TestMethodTestDescriptor.java:208)
>  at 
> org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:137)
>  at 
> org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:71)
>  at 
> org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:135)
>  at 
> org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
>  at 
> org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
>  at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
>  at 
> org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
>  at 
> org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
>  at 
> org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
>  at 
> org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
>  at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
>  at 
> org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
>  at 
> org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
>  at 
> org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
>  at 
> org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
>  at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
>  at 
> org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
>  at 
> org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
>  at 
> org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
>  at 
> org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
>  at java.base/java.util.ArrayList.forEach(ArrayList.java:1540)
>  at 
> org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:38)
>  at 
> org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$5(NodeTestTask.java:139)
>  at 
> org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
>  at 
> org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$7(NodeTestTask.java:125)
>  at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:135)
>  at 
> org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:123)
>  at 
> org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
>  at 
> org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:122)
>  at 
> org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:80)
>  at 
> org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:32)
>  at 
> org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
>  at 
> org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:51)
>  at 
> org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:248)
>  at 
> org.junit.platform.launcher.core.DefaultLauncher.lambda$execute$5(DefaultLauncher.java:211)
>  at 
> org.junit.platform.launcher.core.DefaultLauncher.withInterceptedStreams(DefaultLauncher.java:226)
>  at 
> org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:199)
>  at 
> org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:132)
>  at 
> com.intellij.junit5.JUnit5IdeaTestRunner.startRunnerWithArgs(JUnit5IdeaTestRunner.java:69)
>  at 
> com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:33)
>  at 
> com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:230)
>  at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:58)
> Caused by: java.lang.NullPointerException
>  at Baz.bind(Unknown Source)
>  at 
> org.apache.calcite.jdbc.CalcitePrepare$CalciteSignature.enumerable(CalcitePrepare.java:355)
>  at 
> org.apache.calcite.jdbc.CalciteConnectionImpl.enumerable(CalciteConnectionImpl.java:315)
>  at 
> org.apache.calcite.jdbc.CalciteMetaImpl._createIterable(CalciteMetaImpl.java:507)
>  at 
> org.apache.calcite.jdbc.CalciteMetaImpl.createIterable(CalciteMetaImpl.java:498)
>  at 
> org.apache.calcite.avatica.AvaticaResultSet.execute(AvaticaResultSet.java:182)
>  at org.apache.calcite.jdbc.CalciteResultSet.execute(CalciteResultSet.java:64)
>  at org.apache.calcite.jdbc.CalciteResultSet.execute(CalciteResultSet.java:43)
>  at 
> org.apache.calcite.avatica.AvaticaConnection$1.execute(AvaticaConnection.java:667)
>  at 
> org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:567)
>  at 
> org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:675)
>  at 
> org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:156)
>  ... 65 more {noformat}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to