Apache calcite geode JDBC adapte not working with

2019-08-20 09:35发布

I am trying to connect Gemfire 8.2 using apache calcite geode adopter. As per following logs its connectied properly but while try to execute query getting exception .

Note : http://calcite.apache.org/news/2018/03/19/release-1.16.0/

Moreover, a new adapter to read data from Apache Geode was added in this release. In addition, more progress has been made for the existing adapters

1) Connection class

package com.khan.vaquar;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.Properties;

import com.google.common.collect.ImmutableMap;

public class GemfireJDBCTest1 {

    public static void main(String[] args) {
        //
        new GemfireJDBCTest1().connection1();
        //
        //new GemfireJDBCTest1().connection2();
    }

    /***
     * 
     */
    public void connection1() {
        try {
            Class.forName(org.apache.calcite.jdbc.Driver.class.getName());
        } catch (ClassNotFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
        Properties info = new Properties();
        info.setProperty("lex", "JAVA"); // Enables case sensitivity
        info.setProperty("model",
                "C://Users//vkhan//Documents//scala-workspace//CalciteGemfire//src//com//khan//vaquar//myModel.json "); // See
                                                                                                                            // section
                                                                                                                            // below
        try {
            Connection connection = DriverManager.getConnection("jdbc:calcite:", info);

            Statement statement = connection.createStatement();

            ResultSet resultset = statement.executeQuery("select * from account"); //("select * from \"account\"");

            final StringBuilder buf = new StringBuilder();

            while (resultset.next()) {

                ResultSetMetaData metaData = resultset.getMetaData();
                /*
                for (int i = 1; i <= metaData.getColumnCount(); i++) {

                }
                */
            }

            System.out.println("Conected---------------------------");
        } catch (SQLException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }


}

2) JSON "myModel.json"

{
  "version": "1.0",
  "defaultSchema": "geode",
  "schemas": [
    {
      "name": "geode_raw",
      "type": "custom",
      "factory": "org.apache.calcite.adapter.geode.rel.GeodeSchemaFactory",
      "operand": {
        "locatorHost": "localhost",
        "locatorPort": "10334",
        "regions": "account",
        "pdxSerializablePackagePath": ".*"
      }
    }
  ]
}

Jars

aggdesigner-algorithm-6.0.jar
antlr-2.7.7.jar
avatica-core-1.11.0.jar
avatica-metrics-1.11.0.jar
calcite-core-1.16.0.jar
calcite-geode-1.16.0.jar
calcite-linq4j-1.16.0.jar
commons-beanutils-1.9.3.jar
commons-codec-1.9.jar
commons-collections-3.2.2.jar
commons-compiler-2.7.6.jar
commons-dbcp-1.4.jar
commons-digester-2.1.jar
commons-io-2.5.jar
commons-lang-2.6.jar
commons-lang3-3.2.jar
commons-logging-1.1.3.jar
commons-pool-1.5.4.jar
commons-validator-1.6.jar
esri-geometry-api-2.0.0.jar
fast-classpath-scanner-2.0.11.jar
fastutil-7.1.0.jar
findbugs-annotations-1.3.9-1.jar
geode-common-1.3.0.jar
geode-core-1.3.0.jar
geode-json-1.3.0.jar
guava-19.0.jar
httpclient-4.5.2.jar
httpcore-4.4.4.jar
jackson-annotations-2.9.4.jar
jackson-core-2.9.4.jar
jackson-databind-2.9.4.jar
janino-2.7.6.jar
javax.resource-api-1.7.jar
javax.transaction-api-1.2.jar
jgroups-3.6.10.Final.jar
jna-4.0.0.jar
jopt-simple-5.0.3.jar
jsr305-3.0.1.jar
log4j-api-2.8.2.jar
log4j-core-2.8.2.jar
memory-0.9.0.jar
protobuf-java-3.3.0.jar
shiro-core-1.3.2.jar
sketches-core-0.9.0.jar
slf4j-api-1.7.13.jar

Gemfire 8.2 (Geode)

enter image description here

When using this query getting following exception

(1) ResultSet resultset = statement.executeQuery("select * from account");

Exception :

Build-Date: 2017-10-26 21:57:38 +0530
Build-Id: sbawaskar 0
Build-Java-Version: 1.8.0_121
Build-Platform: Mac OS X 10.12.6 x86_64
Product-Name: Apache Geode
Product-Version: 1.3.0
Source-Date: 2017-10-18 22:02:15 +0530
Source-Repository: release/1.3.0
Source-Revision: 59f2a73d108101744ed7b2d88e8d1c948d19781c
Native version: native code unavailable
Running on: /3.142.66.67, 4 cpu(s), amd64 Windows 7 6.1 
Communications version: 70
Process ID: 16120
User: VKhan
Current dir: C:\Users\VKhan\Documents\scala-workspace\CalciteGemfire
Home dir: C:\Users\VKhan
Command Line Parameters:
  -Dfile.encoding=Cp1252
Class Path:
  C:\Users\VKhan\Documents\scala-workspace\CalciteGemfire\bin
  C:\jars\aggdesigner-algorithm-6.0.jar
  C:\jars\antlr-2.7.7.jar
  C:\jars\avatica-core-1.11.0.jar
  C:\jars\avatica-metrics-1.11.0.jar
  C:\jars\calcite-core-1.16.0.jar
  C:\jars\calcite-geode-1.16.0.jar
  C:\jars\calcite-linq4j-1.16.0.jar
  C:\jars\commons-beanutils-1.9.3.jar
  C:\jars\commons-codec-1.9.jar
  C:\jars\commons-collections-3.2.2.jar
  C:\jars\commons-compiler-2.7.6.jar
  C:\jars\commons-dbcp-1.4.jar
  C:\jars\commons-digester-2.1.jar
  C:\jars\commons-io-2.5.jar
  C:\jars\commons-lang-2.6.jar
  C:\jars\commons-lang3-3.2.jar
  C:\jars\commons-logging-1.1.3.jar
  C:\jars\commons-pool-1.5.4.jar
  C:\jars\commons-validator-1.6.jar
  C:\jars\esri-geometry-api-2.0.0.jar
  C:\jars\fast-classpath-scanner-2.0.11.jar
  C:\jars\fastutil-7.1.0.jar
  C:\jars\findbugs-annotations-1.3.9-1.jar
  C:\jars\geode-common-1.3.0.jar
  C:\jars\geode-core-1.3.0.jar
  C:\jars\geode-json-1.3.0.jar
  C:\jars\guava-19.0.jar
  C:\jars\httpclient-4.5.2.jar
  C:\jars\httpcore-4.4.4.jar
  C:\jars\jackson-annotations-2.9.4.jar
  C:\jars\jackson-core-2.9.4.jar
  C:\jars\jackson-databind-2.9.4.jar
  C:\jars\janino-2.7.6.jar
  C:\jars\javax.resource-api-1.7.jar
  C:\jars\javax.transaction-api-1.2.jar
  C:\jars\jgroups-3.6.10.Final.jar
  C:\jars\jna-4.0.0.jar
  C:\jars\jopt-simple-5.0.3.jar
  C:\jars\jsr305-3.0.1.jar
  C:\jars\log4j-api-2.8.2.jar
  C:\jars\log4j-core-2.8.2.jar
  C:\jars\memory-0.9.0.jar
  C:\jars\protobuf-java-3.3.0.jar
  C:\jars\shiro-core-1.3.2.jar
  C:\jars\sketches-core-0.9.0.jar
  C:\jars\slf4j-api-1.7.13.jar
Library Path:
  C:\Program Files\Java\jdk1.8.0_131\jre\bin
  C:\WINDOWS\Sun\Java\bin
  C:\WINDOWS\system32
  C:\WINDOWS
  C:/Program Files (x86)/Java/jre1.8.0_161/bin/client
  C:/Program Files (x86)/Java/jre1.8.0_161/bin
  C:/Program Files (x86)/Java/jre1.8.0_161/lib/i386
  C:\ProgramData\Oracle\Java\javapath
  C:\Program Files (x86)\RSA SecurID Token Common
  C:\WINDOWS\system32
  C:\WINDOWS
  C:\WINDOWS\System32\Wbem
  C:\WINDOWS\System32\WindowsPowerShell\v1.0\
  C:\Program Files (x86)\WebEx\Productivity Tools
  C:\Program Files (x86)\Extra!\
  C:\Program Files (x86)\WebEx\PTools020000000
  C:\SUPPORT\apache-maven-3.3.9\bin
  C:\Program Files\TortoiseSVN\bin
  C:\Program Files\Cloud Foundry
  C:\Users\VKhan\AppData\Roaming\Cloud Foundry
  C:\Program Files (x86)\Sennheiser\SoftphoneSDK\
  C:\Program Files (x86)\PuTTY\
  C:\Program Files\Git\cmd
  C:\spark\video\softwareandcode\Spark\bin
  C:\hadoop\bin
  C:\Program Files (x86)\sbt\bin
  C:\vaquarkhan\sts-bundle\sts-3.8.4.RELEASE
  .
System Properties:
    awt.toolkit = sun.awt.windows.WToolkit
    file.encoding = Cp1252
    file.encoding.pkg = sun.io
    file.separator = \
    java.awt.graphicsenv = sun.awt.Win32GraphicsEnvironment
    java.awt.printerjob = sun.awt.windows.WPrinterJob
    java.class.version = 52.0
    java.endorsed.dirs = C:\Program Files\Java\jdk1.8.0_131\jre\lib\endorsed
    java.ext.dirs = C:\Program Files\Java\jdk1.8.0_131\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext
    java.home = C:\Program Files\Java\jdk1.8.0_131\jre
    java.io.tmpdir = C:\Users\VKhan\AppData\Local\Temp\
    java.runtime.name = Java(TM) SE Runtime Environment
    java.runtime.version = 1.8.0_131-b11
    java.specification.name = Java Platform API Specification
    java.specification.vendor = Oracle Corporation
    java.specification.version = 1.8
    java.vendor = Oracle Corporation
    java.vendor.url = http://java.oracle.com/
    java.vendor.url.bug = http://bugreport.sun.com/bugreport/
    java.version = 1.8.0_131
    java.vm.info = mixed mode
    java.vm.name = Java HotSpot(TM) 64-Bit Server VM
    java.vm.specification.name = Java Virtual Machine Specification
    java.vm.specification.vendor = Oracle Corporation
    java.vm.specification.version = 1.8
    java.vm.vendor = Oracle Corporation
    java.vm.version = 25.131-b11
    line.separator = 
    os.version = 6.1
    path.separator = ;
    sun.arch.data.model = 64
    sun.boot.class.path = C:\Program Files\Java\jdk1.8.0_131\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\rt.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_131\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_131\jre\classes
    sun.boot.library.path = C:\Program Files\Java\jdk1.8.0_131\jre\bin
    sun.cpu.endian = little
    sun.cpu.isalist = amd64
    sun.desktop = windows
    sun.io.unicode.encoding = UnicodeLittle
    sun.java.command = com.khan.vaquar.GemfireJDBCTest1
    sun.java.launcher = SUN_STANDARD
    sun.jnu.encoding = Cp1252
    sun.management.compiler = HotSpot 64-Bit Tiered Compilers
    sun.nio.ch.bugLevel = 
    sun.os.patch.level = Service Pack 1
    user.country = US
    user.language = en
    user.script = 
    user.timezone = America/Chicago
    user.variant = 
Log4J 2 Configuration:
    jar:file:/C:/jars/geode-core-1.3.0.jar!/log4j2.xml
---------------------------------------------------------------------------


[info 2018/03/21 10:41:02.553 CDT <main> tid=0x1] Running in client mode

[info 2018/03/21 10:41:02.646 CDT <main> tid=0x1] Requesting cluster configuration

[info 2018/03/21 10:41:02.646 CDT <main> tid=0x1] Loading previously deployed jars

[info 2018/03/21 10:41:02.709 CDT <main> tid=0x1] AutoConnectionSource UpdateLocatorListTask started with interval=10,000 ms.

[info 2018/03/21 10:41:02.709 CDT <main> tid=0x1] Pool DEFAULT started with multiuser-authentication=false

java.sql.SQLException: Error while executing SQL "select * from account": From line 1, column 15 to line 1, column 21: Object 'account' not found
    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:156)
    at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218)
    at com.khan.vaquar.GemfireJDBCTest1.connection1(GemfireJDBCTest1.java:43)
    at com.khan.vaquar.GemfireJDBCTest1.main(GemfireJDBCTest1.java:17)
Caused by: org.apache.calcite.runtime.CalciteContextException: From line 1, column 15 to line 1, column 21: Object 'account' not found
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463)
    at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:803)
    at org.apache.calcite.sql.SqlUtil.newContextException(SqlUtil.java:788)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.newValidationError(SqlValidatorImpl.java:4706)
    at org.apache.calcite.sql.validate.IdentifierNamespace.resolveImpl(IdentifierNamespace.java:172)
    at org.apache.calcite.sql.validate.IdentifierNamespace.validateImpl(IdentifierNamespace.java:177)
    at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:947)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:928)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:2975)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validateFrom(SqlValidatorImpl.java:2960)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validateSelect(SqlValidatorImpl.java:3219)
    at org.apache.calcite.sql.validate.SelectNamespace.validateImpl(SelectNamespace.java:60)
    at org.apache.calcite.sql.validate.AbstractNamespace.validate(AbstractNamespace.java:84)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validateNamespace(SqlValidatorImpl.java:947)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validateQuery(SqlValidatorImpl.java:928)
    at org.apache.calcite.sql.SqlSelect.validate(SqlSelect.java:226)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validateScopedExpression(SqlValidatorImpl.java:903)
    at org.apache.calcite.sql.validate.SqlValidatorImpl.validate(SqlValidatorImpl.java:613)
    at org.apache.calcite.sql2rel.SqlToRelConverter.convertQuery(SqlToRelConverter.java:553)
    at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:264)
    at org.apache.calcite.prepare.Prepare.prepareSql(Prepare.java:230)
    at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:781)
    at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:640)
    at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:610)
    at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:221)
    at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:603)
    at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:638)
    at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:149)
    ... 3 more
Caused by: org.apache.calcite.sql.validate.SqlValidatorException: Object 'account' not found
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.apache.calcite.runtime.Resources$ExInstWithCause.ex(Resources.java:463)
    at org.apache.calcite.runtime.Resources$ExInst.ex(Resources.java:572)
    ... 31 more
[info 2018/03/21 10:41:03.427 CDT <Distributed system shutdown hook> tid=0xc] VM is exiting - shutting down distributed system

[info 2018/03/21 10:41:03.427 CDT <Distributed system shutdown hook> tid=0xc] GemFireCache[id = 657069980; isClosing = true; isShutDownAll = false; created = Wed Mar 21 10:41:02 CDT 2018; server = false; copyOnRead = false; lockLease = 120; lockTimeout = 60]: Now closing.

[info 2018/03/21 10:41:03.505 CDT <Distributed system shutdown hook> tid=0xc] Destroying connection pool DEFAULT

[info 2018/03/21 10:41:05.581 CDT <poolTimer-DEFAULT-2> tid=0x18] AutoConnectionSource discovered new locators [XXXX/XXXX:10334]

[info 2018/03/21 10:41:05.613 CDT <poolTimer-DEFAULT-3> tid=0x19] Updating membership port.  Port changed from 0 to 64,781.  ID is now XXXXXX(16120:loner):0:8b803849

2) When using following style getting following exception

ResultSet resultset = statement.executeQuery("select * from \"account\"");

Exception :

[info 2018/03/21 11:00:09.274 CDT <main> tid=0x1] Running in client mode

[info 2018/03/21 11:00:09.352 CDT <main> tid=0x1] Requesting cluster configuration

[info 2018/03/21 11:00:09.368 CDT <main> tid=0x1] Loading previously deployed jars

[info 2018/03/21 11:00:09.430 CDT <main> tid=0x1] AutoConnectionSource UpdateLocatorListTask started with interval=10,000 ms.

[info 2018/03/21 11:00:09.430 CDT <main> tid=0x1] Pool DEFAULT started with multiuser-authentication=false

java.sql.SQLException: Error while executing SQL "select * from "account"": parse failed: Encountered "from \"" at line 1, column 10.
Was expecting one of:
    <EOF> 
    "ORDER" ...
    "LIMIT" ...
    "OFFSET" ...
    "FETCH" ...
    "FROM" <IDENTIFIER> ...
    "FROM" <QUOTED_IDENTIFIER> ...
    "FROM" <BACK_QUOTED_IDENTIFIER> ...
    "FROM" <BRACKET_QUOTED_IDENTIFIER> ...
    "FROM" <UNICODE_QUOTED_IDENTIFIER> ...
    "FROM" "LATERAL" ...
    "FROM" "(" ...
    "FROM" "UNNEST" ...
    "FROM" "TABLE" ...
    "," ...
    "AS" ...
    <IDENTIFIER> ...
    <QUOTED_IDENTIFIER> ...
    <BACK_QUOTED_IDENTIFIER> ...
    <BRACKET_QUOTED_IDENTIFIER> ...
    <UNICODE_QUOTED_IDENTIFIER> ...
    "UNION" ...
    "INTERSECT" ...
    "EXCEPT" ...
    "MINUS" ...

    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:156)
    at org.apache.calcite.avatica.AvaticaStatement.executeQuery(AvaticaStatement.java:218)
    at com.khan.vaquar.GemfireJDBCTest1.connection1(GemfireJDBCTest1.java:43)
    at com.khan.vaquar.GemfireJDBCTest1.main(GemfireJDBCTest1.java:17)
Caused by: java.lang.RuntimeException: parse failed: Encountered "from \"" at line 1, column 10.
Was expecting one of:
    <EOF> 
    "ORDER" ...
    "LIMIT" ...
    "OFFSET" ...
    "FETCH" ...
    "FROM" <IDENTIFIER> ...
    "FROM" <QUOTED_IDENTIFIER> ...
    "FROM" <BACK_QUOTED_IDENTIFIER> ...
    "FROM" <BRACKET_QUOTED_IDENTIFIER> ...
    "FROM" <UNICODE_QUOTED_IDENTIFIER> ...
    "FROM" "LATERAL" ...
    "FROM" "(" ...
    "FROM" "UNNEST" ...
    "FROM" "TABLE" ...
    "," ...
    "AS" ...
    <IDENTIFIER> ...
    <QUOTED_IDENTIFIER> ...
    <BACK_QUOTED_IDENTIFIER> ...
    <BRACKET_QUOTED_IDENTIFIER> ...
    <UNICODE_QUOTED_IDENTIFIER> ...
    "UNION" ...
    "INTERSECT" ...
    "EXCEPT" ...
    "MINUS" ...

    at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:760)
    at org.apache.calcite.prepare.CalcitePrepareImpl.prepare_(CalcitePrepareImpl.java:640)
    at org.apache.calcite.prepare.CalcitePrepareImpl.prepareSql(CalcitePrepareImpl.java:610)
    at org.apache.calcite.jdbc.CalciteConnectionImpl.parseQuery(CalciteConnectionImpl.java:221)
    at org.apache.calcite.jdbc.CalciteMetaImpl.prepareAndExecute(CalciteMetaImpl.java:603)
    at org.apache.calcite.avatica.AvaticaConnection.prepareAndExecuteInternal(AvaticaConnection.java:638)
    at org.apache.calcite.avatica.AvaticaStatement.executeInternal(AvaticaStatement.java:149)
    ... 3 more
Caused by: org.apache.calcite.sql.parser.SqlParseException: Encountered "from \"" at line 1, column 10.
Was expecting one of:
    <EOF> 
    "ORDER" ...
    "LIMIT" ...
    "OFFSET" ...
    "FETCH" ...
    "FROM" <IDENTIFIER> ...
    "FROM" <QUOTED_IDENTIFIER> ...
    "FROM" <BACK_QUOTED_IDENTIFIER> ...
    "FROM" <BRACKET_QUOTED_IDENTIFIER> ...
    "FROM" <UNICODE_QUOTED_IDENTIFIER> ...
    "FROM" "LATERAL" ...
    "FROM" "(" ...
    "FROM" "UNNEST" ...
    "FROM" "TABLE" ...
    "," ...
    "AS" ...
    <IDENTIFIER> ...
    <QUOTED_IDENTIFIER> ...
    <BACK_QUOTED_IDENTIFIER> ...
    <BRACKET_QUOTED_IDENTIFIER> ...
    <UNICODE_QUOTED_IDENTIFIER> ...
    "UNION" ...
    "INTERSECT" ...
    "EXCEPT" ...
    "MINUS" ...

    at org.apache.calcite.sql.parser.impl.SqlParserImpl.convertException(SqlParserImpl.java:350)
    at org.apache.calcite.sql.parser.impl.SqlParserImpl.normalizeException(SqlParserImpl.java:131)
    at org.apache.calcite.sql.parser.SqlParser.parseQuery(SqlParser.java:138)
    at org.apache.calcite.sql.parser.SqlParser.parseStmt(SqlParser.java:163)
    at org.apache.calcite.prepare.CalcitePrepareImpl.prepare2_(CalcitePrepareImpl.java:756)
    ... 9 more
Caused by: org.apache.calcite.sql.parser.impl.ParseException: Encountered "from \"" at line 1, column 10.
Was expecting one of:
    <EOF> 
    "ORDER" ...
    "LIMIT" ...
    "OFFSET" ...
    "FETCH" ...
    "FROM" <IDENTIFIER> ...
    "FROM" <QUOTED_IDENTIFIER> ...
    "FROM" <BACK_QUOTED_IDENTIFIER> ...
    "FROM" <BRACKET_QUOTED_IDENTIFIER> ...
    "FROM" <UNICODE_QUOTED_IDENTIFIER> ...
    "FROM" "LATERAL" ...
    "FROM" "(" ...
    "FROM" "UNNEST" ...
    "FROM" "TABLE" ...
    "," ...
    "AS" ...
    <IDENTIFIER> ...
    <QUOTED_IDENTIFIER> ...
    <BACK_QUOTED_IDENTIFIER> ...
    <BRACKET_QUOTED_IDENTIFIER> ...
    <UNICODE_QUOTED_IDENTIFIER> ...
    "UNION" ...
    "INTERSECT" ...
    "EXCEPT" ...
    "MINUS" ...

    at org.apache.calcite.sql.parser.impl.SqlParserImpl.generateParseException(SqlParserImpl.java:22776)
    at org.apache.calcite.sql.parser.impl.SqlParserImpl.jj_consume_token(SqlParserImpl.java:22593)
    at org.apache.calcite.sql.parser.impl.SqlParserImpl.SqlStmtEof(SqlParserImpl.java:873)
    at org.apache.calcite.sql.parser.impl.SqlParserImpl.parseSqlStmtEof(SqlParserImpl.java:187)
    at org.apache.calcite.sql.parser.SqlParser.parseQuery(SqlParser.java:131)
    ... 11 more
[info 2018/03/21 11:00:09.994 CDT <Distributed system shutdown hook> tid=0xc] VM is exiting - shutting down distributed system

Updated

I have tried old code and git example code provided by Christian with Gemfire 9.0 and 9.2.2 but getting same exception

enter image description here

enter image description here

1) Example in git

package com.khan.vaquar;



import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.Statement;
import java.util.Properties;

/**
 * Example of using Geode via JDBC.
 *
 * <p>Before using this example, you need to populate Geode, as follows:
 *
 * <blockquote><code>
 * git clone https://github.com/vlsi/calcite-test-dataset<br>
 * cd calcite-test-dataset<br>
 * mvn install
 * </code></blockquote>
 *
 * <p>This will create a virtual machine with Geode and the "bookshop" and "zips"
 * test data sets.
 */
public class RelationalJdbcExample {

  protected static final Logger LOGGER = LoggerFactory.getLogger(
      RelationalJdbcExample.class.getName());

  private RelationalJdbcExample() {
  }

  public static void main(String[] args) throws Exception {

    final String geodeModelJson =
        "inline:"
            + "{\n"
            + "  version: '1.0',\n"
            + "  schemas: [\n"
            + "     {\n"
            + "       type: 'custom',\n"
            + "       name: 'TEST',\n"
            + "       factory: 'org.apache.calcite.adapter.geode.rel.GeodeSchemaFactory',\n"
            + "       operand: {\n"
            + "         locatorHost: 'localhost', \n"
            + "         locatorPort: '10334', \n"
            + "         regions: 'account,BookMaster,BookCustomer,BookInventory,BookOrder', \n"
            + "         pdxSerializablePackagePath: 'org.apache.calcite.adapter.geode.domain.*' \n"
            + "       }\n"
            + "     }\n"
            + "   ]\n"
            + "}";

    Class.forName("org.apache.calcite.jdbc.Driver");

    Properties info = new Properties();
    info.put("model", geodeModelJson);

    Connection connection = DriverManager.getConnection("jdbc:calcite:", info);

    Statement statement = connection.createStatement();
    ResultSet resultSet = statement.executeQuery(
        /*"SELECT \"b\".\"author\", \"b\".\"retailCost\", \"i\".\"quantityInStock\"\n"
            + "FROM \"TEST\".\"BookMaster\" AS \"b\" "
            + " INNER JOIN \"TEST\".\"BookInventory\" AS \"i\""
            + "  ON \"b\".\"itemNumber\" = \"i\".\"itemNumber\"\n "
            + "WHERE  \"b\".\"retailCost\" > 0"
        */    

            "SELECT \"b\".\"*\"  FROM \"account\" AS \"b\" "



            );

    final StringBuilder buf = new StringBuilder();
    while (resultSet.next()) {
      ResultSetMetaData metaData = resultSet.getMetaData();
      for (int i = 1; i <= metaData.getColumnCount(); i++) {
        buf.append(i > 1 ? "; " : "")
            .append(metaData.getColumnLabel(i)).append("=").append(resultSet.getObject(i));
      }
      LOGGER.info("Result entry: " + buf.toString());
      buf.setLength(0);
    }
    resultSet.close();
    statement.close();
    connection.close();
  }
}

2) Example in git

package com.khan.vaquar;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Properties;

/**
 * Example of using Geode via JDBC.
 */
public class SimpleJdbcExample {

  protected static final Logger LOGGER =
      LoggerFactory.getLogger(SimpleJdbcExample.class.getName());

  private SimpleJdbcExample() {
  }

  public static void main(String[] args) throws Exception {

    Properties info = new Properties();
    final String model = "inline:"
        + "{\n"
        + "  version: '1.0',\n"
        + "  schemas: [\n"
        + "     {\n"
        + "       type: 'custom',\n"
        + "       name: 'TEST',\n"
        + "       factory: 'org.apache.calcite.adapter.geode.simple"
        + ".GeodeSimpleSchemaFactory',\n"
        + "       operand: {\n"
        + "         locatorHost: 'localhost',\n"
        + "         locatorPort: '10334',\n"
        + "         regions: 'account,BookMaster',\n"
        + "         pdxSerializablePackagePath: 'org.apache.calcite.adapter.geode.domain.*'\n"
        + "       }\n"
        + "     }\n"
        + "  ]\n"
        + "}";
    info.put("model", model);

    Class.forName("org.apache.calcite.jdbc.Driver");

    Connection connection = DriverManager.getConnection("jdbc:calcite:", info);

    Statement statement = connection.createStatement();

    ResultSet resultSet = statement.executeQuery("SELECT * FROM \"account\"");

    final StringBuilder buf = new StringBuilder();

    while (resultSet.next()) {

      int columnCount = resultSet.getMetaData().getColumnCount();

      for (int i = 1; i <= columnCount; i++) {

        buf.append(i > 1 ? "; " : "")
            .append(resultSet.getMetaData().getColumnLabel(i))
            .append("=")
            .append(resultSet.getObject(i));
      }

      LOGGER.info("Entry: " + buf.toString());

      buf.setLength(0);
    }

    resultSet.close();
    statement.close();
    connection.close();
  }
}

1条回答
兄弟一词,经得起流年.
2楼-- · 2019-08-20 09:56

The Geode Adapter is compiled with Geode version: 1.3 (https://github.com/apache/calcite/blob/master/pom.xml#L79) that corresponds to Gemfire 9.x.

Because the Gemfire 8.x is code incompatible with Gemfire 9.x. you would not be able to use the Geode Adapter on the Gemfire 8.x or older. Furthermore the OQL in Gemfire 8.x doesn't support GROUP BY construct either.

查看更多
登录 后发表回答