The ‘!tables’ command calls into the JDBC DatabaseMetaData.getTables command, 
which lists tables in the current schema.

JDBC uses a “fixed” schema depth (there is always a current database, and 
always a current schema) whereas Calcite’s mechanism is hierarchical. The 
current schema, from a JDBC perspective, is not usually the root schema.

Calcite uses a hierarchical namespace for flexibility, and that flexibility 
comes in handy, but it is more flexibility than JDBC is equipped to handle. 
Maybe you can solve your problem by manually setting the JDBC connection’s 
current schema to the root schema, or by creating an artificial schema. (The 
analogy strikes me of file systems: in Linux, the root user’s home directory 
used to be ‘/‘, but for a bunch of pragmatic reasons is now usually ‘/root’.)

Julian


> On Sep 27, 2016, at 7:56 AM, Mark Christiaens <[email protected]> wrote:
> 
> In calcite 1.9.0, it seems I cannot list tables that are stored in the
> "root schema".  In sqline, when I do "!tables" I see the content of my sub
> schemas but none of the tables that were added directly under the root
> schema.  I suspect that the code responsible for this behaviour is this
> (org.apache.calcite.jdbc.CalciteMetaImpl#schemas):
> 
> Enumerable<MetaSchema> schemas(String catalog) {
>  return Linq4j.asEnumerable(
>      getConnection().rootSchema.getSubSchemaMap().values())
>      .select(
>          new Function1<CalciteSchema, MetaSchema>() {
>            public MetaSchema apply(CalciteSchema calciteSchema) {
>              return new CalciteMetaSchema(
>                  calciteSchema,
>                  connection.getCatalog(),
>                  calciteSchema.getName());
>            }
>          })
>      .orderBy(
>          new Function1<MetaSchema, Comparable>() {
>            public Comparable apply(MetaSchema metaSchema) {
>              return (Comparable) FlatLists.of(
>                  Util.first(metaSchema.tableCatalog, ""),
>                  metaSchema.tableSchem);
>            }
>          });
> }
> 
> It takes the rootSchema and analyzes only the sub schemas.  The root schema
> itself doesn't seem to be included in the schema list.  Is this
> intentional?  Is the root schema more of a placeholder not meant to store
> tables?
> 
> ----------------------------------------------------
> Mark Christiaens
> Senior R&D Engineer
> NGData
> Sint-Salvatorstraat 18/303 9000 Gent
> Belgium

Reply via email to