[ 
https://issues.apache.org/jira/browse/CALCITE-5068?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17516183#comment-17516183
 ] 

Julian Hyde commented on CALCITE-5068:
--------------------------------------

I think that behavior is probably OK. If DBMS doesn't have a notion of catalog 
(e.g. Oracle has only schemas) then the {{Connection.setCatalog}} method will 
assign to the 'current catalog' variable but it will be ignored. The 
{{TABLE_CATALOG}} field in the output of {{{}getSchemas{}}}, {{{}getTables{}}}, 
{{getColumns}} etc. is correctly the empty string because the objects don't 
have a catalog (or, more precisely, belong to the one and only catalog, whose 
name is "").

Perhaps Calcite or CalciteMetaImpl could allow you to specify whether you want 
to be a catalog-less DB (only schemas), or a schema-less DB (only catalogs), a 
two-level DB (catalogs and schemas but no sub-schemas), or a ragged DB (no 
depth restriction on schemas, and tables can occur at any depth, but only 
tables at depth 2 are visible through JDBC.

> There are some problems with the use of catalog
> -----------------------------------------------
>
>                 Key: CALCITE-5068
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5068
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: itxiangkui
>            Priority: Major
>
> when i use under sqlline
> ````shell
> !schema
> !tables
> !metadata getSchemas
> ````
> When I wait for the command, I find that the catalog seems to be a wrong meta 
> information, and it is always empty, even after I call 
> connection.setCatalog().
> Looking at the source code, found org.apache.calcite.jdbc.CalciteMetaImpl's
>  
> ```java
>    Enumerable<MetaSchema> schemas(final String catalog) {
>     return Linq4j.asEnumerable(
>         getConnection().rootSchema.getSubSchemaMap().values())
>         .select((Function1<CalciteSchema, MetaSchema>) calciteSchema ->
>             new CalciteMetaSchema(calciteSchema, catalog,
>                 calciteSchema.getName()))
>         .orderBy((Function1<MetaSchema, Comparable>) metaSchema ->
>             (Comparable) FlatLists.of(Util.first(metaSchema.tableCatalog, ""),
>                 metaSchema.tableSchem));
>   }
> ```
> Obviously, the parameters of the catalog are not used for filtering, and 
> there is no context information of the catalog in the rootSchema. The catalog 
> is directly passed to the CalciteMetaSchema object.



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to