java - table not found with apache calcite -


i trying basic things calcite understand framework. have setup simple example supposed read 2 json files. model looks

{   version: '1.0',   defaultschema: 'people',   schemas: [     {       name: 'people',       type: 'custom',       factory: 'demo.jsonschemafactory',       operand: {         directory: '/..../calcite-json/src/test/resources/files'       }     }   ] } 

in test, seems model being loaded fine because when pull database metadata information, can see file being loaded table under people schema. right after statement trying select * table , error table not found.

> -- null people table --> jun 29, 2015 8:53:30 org.apache.calcite.sql.validate.sqlvalidatorexception <init> severe: org.apache.calcite.sql.validate.sqlvalidatorexception: table 'a' not found jun 29, 2015 8:53:30 org.apache.calcite.runtime.calciteexception <init> severe: org.apache.calcite.runtime.calcitecontextexception: @ line 1, column 26: table 'a' not found 

the first line in output shows tables database metadata "-- null people table -->". shows table "a" present under schema "people" , of type "table".

my test code looks this

@test public void testmodel() throws sqlexception {     properties props = new properties();     props.put("model", getpath("/model.json"));     system.out.println("model = " + props.get("model"));     connection conn = drivermanager.getconnection("jdbc:calcite:", props);      databasemetadata md = conn.getmetadata();     resultset tables = md.gettables(null, "people", "%", null);     while (tables.next()) {         system.out.println("--");         system.out.println(tables.getstring(1));         system.out.println(tables.getstring(2));         system.out.println(tables.getstring(3));         system.out.println(tables.getstring(4));         system.out.println("-->");     }      statement stat = conn.createstatement();     stat.execute("select _map['name'] a");      stat.close();     conn.close(); } 

any ideas why not able select on loaded table?

another interesting thing noticed 1 file, schema.gettablemap being called 4 times.

the complete code project can found on github

the problem case-sensitivity. because did not enclose table name in double-quotes, calcite's sql parser converted upper case. because file called 'a.json', table called 'a', whereas query looking table called 'a'.

the solution write query follows:

select _map['name'] "a" 

this becomes:

stat.execute("select _map['name'] \"a\""); 

when embed in java.


Comments

Popular posts from this blog

java - Andrioid studio start fail: Fatal error initializing 'null' -

android - Gradle sync Error:Configuration with name 'default' not found -

StringGrid issue in Delphi XE8 firemonkey mobile app -