You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Gunnar Morling <gu...@googlemail.com.INVALID> on 2021/12/28 21:45:35 UTC

How to obtain metadata for tables in sub-schemas?

Hi,

I have created a custom Calcite schema factory which produces a parent
schema which in turn contains multiple sub-schemas. I can query those
tables as intended, e.g. SELECT * FROM schemaname.tablename.

I am struggling though to obtain all the tables via JDBC metadata, the
following doesn't return any subschema tables (note how the schema filter
is null):

  DatabaseMetaData md = connection.getMetaData();
  ResultSet rs = md.getTables(null, null, "%", null));

Is this an expected behavior? If so, what would I have to do in order to
obtain the metadata for tables in any sub-schema? I don't think I should
return any sub-schema tables from getTable() in the parent schema, or
should I?

Thanks a lot for any advice,

--Gunnar

Re: How to obtain metadata for tables in sub-schemas?

Posted by Julian Hyde <jh...@gmail.com>.
In JDBC, tables always occur at depth = 2 (inside a schema inside a catalog). I forget the details, but if your model is of the wrong depth (e.g. the tables occur at depth = 1, inside a schema directly inside the root schema, or if the tables occur at depth = 3) it’s possible that they will never appear via the JDBC APIs.

If that’s the problem you are running into, we ought to make it easier to configure the JDBC server for different depths.

> On Dec 29, 2021, at 1:18 AM, Gunnar Morling <gu...@googlemail.com.INVALID> wrote:
> 
> Am Di., 28. Dez. 2021 um 23:13 Uhr schrieb Julian Hyde <
> jhyde.apache@gmail.com>:
> 
>> That looks right. So we may have a bug. Also try
>> 
>>  md.getTables(null, null, "%", new String[] {“TABLE”}));
>> 
>> and
>> 
>>  md.getTables(“", null, "%", new String[] {“TABLE”}));
>> 
> 
> Same result, no sub-schema tables are returned.
> 
> I've logged https://issues.apache.org/jira/browse/CALCITE-4969 for this.
> 
> Julian
>> 
> 
> Thanks,
> 
> --Gunnar
> 
> 
>> 
>> 
>>> On Dec 28, 2021, at 1:45 PM, Gunnar Morling
>> <gu...@googlemail.com.INVALID> wrote:
>>> 
>>> Hi,
>>> 
>>> I have created a custom Calcite schema factory which produces a parent
>>> schema which in turn contains multiple sub-schemas. I can query those
>>> tables as intended, e.g. SELECT * FROM schemaname.tablename.
>>> 
>>> I am struggling though to obtain all the tables via JDBC metadata, the
>>> following doesn't return any subschema tables (note how the schema filter
>>> is null):
>>> 
>>> DatabaseMetaData md = connection.getMetaData();
>>> ResultSet rs = md.getTables(null, null, "%", null));
>>> 
>>> Is this an expected behavior? If so, what would I have to do in order to
>>> obtain the metadata for tables in any sub-schema? I don't think I should
>>> return any sub-schema tables from getTable() in the parent schema, or
>>> should I?
>>> 
>>> Thanks a lot for any advice,
>>> 
>>> --Gunnar
>> 
>> 


Re: How to obtain metadata for tables in sub-schemas?

Posted by Gunnar Morling <gu...@googlemail.com.INVALID>.
Am Di., 28. Dez. 2021 um 23:13 Uhr schrieb Julian Hyde <
jhyde.apache@gmail.com>:

> That looks right. So we may have a bug. Also try
>
>   md.getTables(null, null, "%", new String[] {“TABLE”}));
>
> and
>
>   md.getTables(“", null, "%", new String[] {“TABLE”}));
>

Same result, no sub-schema tables are returned.

I've logged https://issues.apache.org/jira/browse/CALCITE-4969 for this.

Julian
>

Thanks,

--Gunnar


>
>
> > On Dec 28, 2021, at 1:45 PM, Gunnar Morling
> <gu...@googlemail.com.INVALID> wrote:
> >
> > Hi,
> >
> > I have created a custom Calcite schema factory which produces a parent
> > schema which in turn contains multiple sub-schemas. I can query those
> > tables as intended, e.g. SELECT * FROM schemaname.tablename.
> >
> > I am struggling though to obtain all the tables via JDBC metadata, the
> > following doesn't return any subschema tables (note how the schema filter
> > is null):
> >
> >  DatabaseMetaData md = connection.getMetaData();
> >  ResultSet rs = md.getTables(null, null, "%", null));
> >
> > Is this an expected behavior? If so, what would I have to do in order to
> > obtain the metadata for tables in any sub-schema? I don't think I should
> > return any sub-schema tables from getTable() in the parent schema, or
> > should I?
> >
> > Thanks a lot for any advice,
> >
> > --Gunnar
>
>

Re: How to obtain metadata for tables in sub-schemas?

Posted by Julian Hyde <jh...@gmail.com>.
That looks right. So we may have a bug. Also try

  md.getTables(null, null, "%", new String[] {“TABLE”}));

and

  md.getTables(“", null, "%", new String[] {“TABLE”}));

Julian


> On Dec 28, 2021, at 1:45 PM, Gunnar Morling <gu...@googlemail.com.INVALID> wrote:
> 
> Hi,
> 
> I have created a custom Calcite schema factory which produces a parent
> schema which in turn contains multiple sub-schemas. I can query those
> tables as intended, e.g. SELECT * FROM schemaname.tablename.
> 
> I am struggling though to obtain all the tables via JDBC metadata, the
> following doesn't return any subschema tables (note how the schema filter
> is null):
> 
>  DatabaseMetaData md = connection.getMetaData();
>  ResultSet rs = md.getTables(null, null, "%", null));
> 
> Is this an expected behavior? If so, what would I have to do in order to
> obtain the metadata for tables in any sub-schema? I don't think I should
> return any sub-schema tables from getTable() in the parent schema, or
> should I?
> 
> Thanks a lot for any advice,
> 
> --Gunnar