Hi,
I was using kylin JDBC driver to fetch data. 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.
Also if hive schema is anything other than default, then <schema
name>.<table name> in from clause works. But with default schema it fails.
Ex. If tables are in *test *schema of hive, then *select * from
test.kylin_sales *works. But when the tables are in *default *schema of
hive, then *select * from default.kylin_sales *fails.
Please let me know if I'm doing something wrong.
Best Regards,
Hari