Hi Xu, 
sorry for late response. I read the code in org.apache.calcite.test.ServerTest, 
along with help from Julian, now the problem has been solved.
According to Julian, I replaced the value of parserFactory 
"org.apache.calcite.sql.parser.ddl.SqlDdlParserImpl#FACTORY" with 
"org.apache.calcite.server.ServerDdlExecutor#PARSER_FACTORY", and then it works.
The property value is also in the connect() function in ServerTest Class:
static Connection connect() throws SQLException {
  return DriverManager.getConnection(URL,
        ...
          .set(CalciteConnectionProperty.PARSER_FACTORY,
              ServerDdlExecutor.class.getName() + "#PARSER_FACTORY")
         ...)
}
and it proves that Julian is right.

Thank you very much!
 
From: 徐仁和
Date: 2022-02-22 14:45
To: dev
Subject: RE: DDL support issues in Calcite
Hi Wang
The test case of `org.apache.calcite.test.ServerTest` may be what you want.
 
On 2022/02/21 08:17:55 "wang...@mchz.com.cn" wrote:
> Dear Calcite community:
>
> I am new Calcite user here. I noted in the document
https://calcite.apache.org/docs/adapter.html that Calcite does support DDL
operations,the only thing I need to do is 1) to include calcite-server.jar
in my classpath and 2) add
parserFactory=org.apache.calcite.sql.parser.ddl.SqlDdlParserImpl#FACTORY to
JDBC connect string.
> Now the problem is: I did so, but still I got the following error:
>
>
> java.sql.SQLException: Error while executing SQL "CREATE TABLE t (i
INTEGER, j VARCHAR(10))": DDL not supported: CREATE TABLE `T` (`I` INTEGER,
`J` VARCHAR(10)) 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.xxxx.CalciteResolverTest.testJdbc(CalciteResolverTest.java:259) at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native
Method) at
java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at
java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568) at
junit.framework.TestCase.runTest(TestCase.java:177) at
junit.framework.TestCase.runBare(TestCase.java:142) at
junit.framework.TestResult$1.protect(TestResult.java:122) at
junit.framework.TestResult.runProtected(TestResult.java:142) at
junit.framework.TestResult.run(TestResult.java:125) at
junit.framework.TestCase.run(TestCase.java:130) at
junit.framework.TestSuite.runTest(TestSuite.java:241) at
junit.framework.TestSuite.run(TestSuite.java:236) at
org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:90)
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:221)
at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54) Caused by:
java.lang.UnsupportedOperationException: DDL not supported: CREATE TABLE
`T` (`I` INTEGER, `J` VARCHAR(10)) at
org.apache.calcite.server.DdlExecutor.lambda$static$0(DdlExecutor.java:28)
at
org.apache.calcite.prepare.CalcitePrepareImpl.executeDdl(CalcitePrepareImpl.java:369)
at
org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:634)
at
org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:513)
at
org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:483)
at
org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:249)
at
org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:623)
at
org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:674)
at
org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:156)
... 20 more
>
> did I miss any other properties that needs to be set?
>
>
>
>
> Many thanks
> Sai Wang
>

Reply via email to