title: table not found with apache calcite
body: <p>I am trying to do some basic things with calcite to understand the framework. I have setup a simple example that is supposed to read from 2 json files. My model looks like </p>
  
  <pre><code>{
    version: '1.0',
    defaultSchema: 'PEOPLE',
    schemas: [
      {
        name: 'PEOPLE',
        type: 'custom',
        factory: 'demo.JsonSchemaFactory',
        operand: {
          directory: '/..../calcite-json/src/test/resources/files'
        }
      }
    ]
  }
  </code></pre>
  
  <p>In my test, it seems that the model is being loaded fine because when I pull the database metadata information, I can see that my file is being loaded as a table under PEOPLE schema. But then right after that statement I am trying to do a <code>select *</code> from that table and I get an error that table was not found.</p>
  
  <blockquote>
  <pre><code>&gt; --
  null
  PEOPLE
  a
  TABLE
  --&gt;
  Jun 29, 2015 8:53:30 AM org.apache.calcite.sql.validate.SqlValidatorException &lt;init&gt;
  SEVERE: org.apache.calcite.sql.validate.SqlValidatorException: Table 'A' not found
  Jun 29, 2015 8:53:30 AM org.apache.calcite.runtime.CalciteException &lt;init&gt;
  SEVERE: org.apache.calcite.runtime.CalciteContextException: At line 1, column 26: Table 'A' not found
  </code></pre>
  </blockquote>
  
  <p>The first line in the output shows the tables from database metadata "--  null PEOPLE a TABLE -->". This shows that a table "a" is present under schema "people" and is of the type "table".</p>
  
  <p>My test code looks like this</p>
  
  <pre><code>@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("--&gt;");
      }
  
      Statement stat = conn.createStatement();
      stat.execute("select _MAP['name'] from a");
  
      stat.close();
      conn.close();
  }
  </code></pre>
  
  <p>Any ideas why I am not able to do a select on the loaded table?</p>
  
  <p>Another interesting thing I noticed is that for 1 file, <code>Schema.getTableMap</code> is being called 4 times.</p>
  
  <p>The complete code for the project can be found <a href="https://github.com/adeelmahmood/calcite-json" rel="nofollow">on github</a></p>