Hi,
Firstly, Kylin does not support catalog, so you cannot create one. The name of
catalog you see is a static final filed of
org.apache.kylin.rest.constant.Constant as follow:
public final static String FakeCatalogName = "defaultCatalog";
You can also see getMetadata method of
org.apache.kylin.rest.service.QueryService.
So I think there are two solution :
First. Like MySQL jdbc, modify the code to return emtpy list when call
DatabaseMetaData.getCatalogs().
It is difficult because the real implmetation of DatabaseMetaData is delegated
to org.apache.calcite.avatica.AvaticaDatabaseMetaData. Considering the
complecity of calcite framework, change its behavior is not so easy.
Second. Remove the catalog automatically in your sql query before send it to
SQL parser.
This can be done by modifying the massageSql method of
org.apache.kylin.query.util.QueryUtil, add following code at the final line of
massageSql.
sql1 = removeCatalog(sql1);
Method removeCatalog is as follow. It just simply replace all 'a.b.c' to 'b.c'.
public static String removeCatalog(String sql) {
String catalogSchemaTable = "[\\w|\\d]+\\.[\\w|\\d]+\\.[\\w|\\d]+";
Pattern catalogSchemaTablePattern = Pattern.compile(catalogSchemaTable);
Matcher catalogSchemaTableMatcher =
catalogSchemaTablePattern.matcher(sql);
while (catalogSchemaTableMatcher.find()) {
String group = catalogSchemaTableMatcher.group();
int catalogIndex = group.indexOf('.');
System.out.println("before: " + group);
System.out.println("after: " + group.substring(catalogIndex + 1));
sql = sql.replace(group, group.substring(catalogIndex + 1));
}
return sql;
}
Please open an issue on JIRA, I will do my best to fix it.
Best wishes,
Xiaoxiang Yu
发件人: hosur narahari <[email protected]>
答复: "[email protected]" <[email protected]>
日期: 2018年9月24日 星期一 20:15
收件人: "[email protected]" <[email protected]>
主题: Re: select with catalog fails
actually