You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@kylin.apache.org by "XiaoXiang Yu (JIRA)" <ji...@apache.org> on 2018/09/26 01:24:00 UTC

[jira] [Commented] (KYLIN-3594) Select with Catalog fails

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

XiaoXiang Yu commented on KYLIN-3594:
-------------------------------------

 

Refer to user mail :

http://mail-archives.apache.org/mod_mbox/kylin-user/201809.mbox/%3cB67DE14C-5295-4FF5-AC8A-C8114F5566D1@kyligence.io%3e

> Select with Catalog fails
> -------------------------
>
>                 Key: KYLIN-3594
>                 URL: https://issues.apache.org/jira/browse/KYLIN-3594
>             Project: Kylin
>          Issue Type: Bug
>            Reporter: Hosur Narahari
>            Assignee: XiaoXiang Yu
>            Priority: Major
>
> By using DatabaseMetaData if we get catalog using getCatalogs() method, it return value "defaultCatalog". It returns actual hive schema when we execute getSchemas().
> According to JDBC contract, catalog.schema.table should be valid from clause and many query layers use that. But kylin fails when we execute that query.
> I've tried to write sample code piece for that below.
>  
>         _DatabaseMetaData db = conn.getMetaData();_
>         _ResultSet catalogSet = db.getCatalogs();_
>         _String catalog = "";_
>         _if(catalogSet.next()) {_
>             _catalog = catalogSet.getString("TABLE_CAT");_
>         _}_
>         _ResultSet schemaSet = db.getSchemas();_
>         _String schema = "";_
>         _if(schemaSet.next()) {_
>             _schema = schemaSet.getString("TABLE_SCHEM");_
>         _}_
>         _StringBuilder sb = new StringBuilder("SELECT * FROM ");_
>         _if(!catalog.isEmpty()) {_
>             _sb.append(catalog + ".");_
>         _}_
>         _if(!schema.isEmpty()) {_
>             _sb.append(schema + ".");_
>         _}_
>         _sb.append("kylin_sales limit 10");_
>         _String query = sb.toString();_
>         _Statement stat = conn.createStatement();_
>         _ResultSet rs = stat.executeQuery(query);_
>         _while(rs.next()) {_
>             _System.out.println(rs.getObject("trans_id"));_
>         _}_
> In short, the above snippet is executing the query,
> _select * from defaultCatalog.DEFAULT.kylin_sales._
>  
> Same thing happens even with different schemas if we have like,
> _select * from defaultCatalog.test.kylin_sales_ also fails.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)