[
https://issues.apache.org/jira/browse/CALCITE-5068?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17516405#comment-17516405
]
Julian Hyde commented on CALCITE-5068:
--------------------------------------
SQLLine's `!schemas`, `!tables`, etc. commands have a simple specification - to
call JDBC's `DatabaseMetaData.getSchemas`, `DatabaseMetaData.getTables`, etc.
with the given parameters, using defaults such as "" and "%" for parameters
that are not specified. The current catalog or schema of the connection does
not affect the result.
They are not intended to be particularly convenient, rather to just give the
raw truth as told by JDBC APIs.
Now, commands such as `show tables` or `describe table` that are implemented by
the underlying database (note that there is no preceding `!`) may try to be
more convenient. Those are more appropriate topics for a Calcite JIRA case.
> 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
> !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
> bc.
> 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)