You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Jess Balint <jb...@gmail.com> on 2017/04/26 15:04:32 UTC

Root Schema

What is the function of the root schema? Why can't I use a JdbcSchema as
the root?

Thx.
Jess

Re: Root Schema

Posted by Julian Hyde <jh...@apache.org>.
Calcite’s schemas are hierarchical, very similar to a unix file-system. So yes, each schema is a “level”. The root schema is at level 0. A schema has a unique name within its parent, and because the the root schema has no parent, it has no name.

Another example. A second level directory in a unix file-system might be /mydb/foodmart. The corresponding second level schema would be “mydb”.”foodmart”.

Calcite is flexible enough to model systems that have a database and a schema, or just a schema, or whatever you want. Let’s suppose your system has both a database and a schema, and you connect using database = “mydb” and schema = “foodmart”. Then the default schema for the connection will be the 2nd level schema “mydb”.”foodmart”. Not the root schema.

Julian


> On May 1, 2017, at 6:58 PM, Jess Balint <jb...@gmail.com> wrote:
> 
> Isn't an instance of the schema a "level"? Is the root schema level 0? Why
> is it anonymous? Is it supposed to represent the current database/catalog?
> 
> Jess
> 
> On Wed, Apr 26, 2017 at 12:11 PM, Julian Hyde <jh...@apache.org> wrote:
> 
>> It would probably work. (Maybe you'd have to tweak the implementation
>> of getExpression.)
>> 
>> Databases traditionally don't have tables at level 0 (i.e. the root
>> directory). They usually have tables in level 1 (they belong to a
>> user, as in Oracle) or level 2 (they belong to a database and then a
>> schema, as in SQL Server). If you put tables at level 0 or level 7 you
>> run the risk of confusing the tools.
>> 
>> If you get it working please contribute a test case.
>> 
>> Julian
>> 
>> 
>> On Wed, Apr 26, 2017 at 8:04 AM, Jess Balint <jb...@gmail.com> wrote:
>>> What is the function of the root schema? Why can't I use a JdbcSchema as
>>> the root?
>>> 
>>> Thx.
>>> Jess
>> 


Re: Root Schema

Posted by Jess Balint <jb...@gmail.com>.
Isn't an instance of the schema a "level"? Is the root schema level 0? Why
is it anonymous? Is it supposed to represent the current database/catalog?

Jess

On Wed, Apr 26, 2017 at 12:11 PM, Julian Hyde <jh...@apache.org> wrote:

> It would probably work. (Maybe you'd have to tweak the implementation
> of getExpression.)
>
> Databases traditionally don't have tables at level 0 (i.e. the root
> directory). They usually have tables in level 1 (they belong to a
> user, as in Oracle) or level 2 (they belong to a database and then a
> schema, as in SQL Server). If you put tables at level 0 or level 7 you
> run the risk of confusing the tools.
>
> If you get it working please contribute a test case.
>
> Julian
>
>
> On Wed, Apr 26, 2017 at 8:04 AM, Jess Balint <jb...@gmail.com> wrote:
> > What is the function of the root schema? Why can't I use a JdbcSchema as
> > the root?
> >
> > Thx.
> > Jess
>

Re: Root Schema

Posted by Julian Hyde <jh...@apache.org>.
It would probably work. (Maybe you'd have to tweak the implementation
of getExpression.)

Databases traditionally don't have tables at level 0 (i.e. the root
directory). They usually have tables in level 1 (they belong to a
user, as in Oracle) or level 2 (they belong to a database and then a
schema, as in SQL Server). If you put tables at level 0 or level 7 you
run the risk of confusing the tools.

If you get it working please contribute a test case.

Julian


On Wed, Apr 26, 2017 at 8:04 AM, Jess Balint <jb...@gmail.com> wrote:
> What is the function of the root schema? Why can't I use a JdbcSchema as
> the root?
>
> Thx.
> Jess