@Test public void testRemoveCatalog() { String[] beforeRemoveSql = new String[] { "select name, count(*) as cnt from schema1.user where bb.dd >2 group by name", "select name, count(*) as cnt from .default2.user where dd >2 group by name", "select name, count(*) as cnt from %s.default2.user where dd >2 group by name", "select name, count(*) as cnt from %s.user.a.cu where dd >2 group by name", "select name, count(*) as cnt from %s.default2.user where dd >2 group by name", "select name, count() as cnt from %s.test.kylin_sales inner join " + "%s.test.kylin_account " + "ON kylin_sales.BUYER_ID=kylin_account.ACCOUNT_ID group by name", "select schema1.table1.col1 from %s.schema1.table1" }; String[] afterRemoveSql = new String[] { "select name, count(*) as cnt from schema1.user where bb.dd >2 group by name", "select name, count(*) as cnt from .default2.user where dd >2 group by name", "select name, count(*) as cnt from default2.user where dd >2 group by name", "select name, count(*) as cnt from user.a.cu where dd >2 group by name", "select name, count(*) as cnt from default2.user where dd >2 group by name", "select name, count() as cnt from test.kylin_sales inner join " + "test.kylin_account " + "ON kylin_sales.BUYER_ID=kylin_account.ACCOUNT_ID group by name", "select schema1.table1.col1 from schema1.table1" }; Assert.assertEquals(afterRemoveSql.length, beforeRemoveSql.length); for (int i = 0; i < beforeRemoveSql.length; i++) { String before = beforeRemoveSql[i]; before = before.replace("%s", catalog); String after = afterRemoveSql[i]; Assert.assertEquals(after, QueryUtil.removeCatalog(before, catalog)); } }
static String removeCatalog(String sql, String catalog) { if (catalog == null) return sql; else return sql.replace(catalog + ".", ""); }
QueryUtil { static String removeCatalog(String sql, String catalog) { if (catalog == null) return sql; else return sql.replace(catalog + ".", ""); } }
QueryUtil { static String removeCatalog(String sql, String catalog) { if (catalog == null) return sql; else return sql.replace(catalog + ".", ""); } private  QueryUtil(); }
QueryUtil { static String removeCatalog(String sql, String catalog) { if (catalog == null) return sql; else return sql.replace(catalog + ".", ""); } private  QueryUtil(); static String appendLimitOffsetToSql(String sql, int limit, int offset); @Deprecated static String massageSql(String sql, String project, int limit, int offset, String defaultSchema); static String massageSql(String sql, String project, int limit, int offset, String defaultSchema,
            String catalog); static String makeErrorMsgUserFriendly(Throwable e); static String makeErrorMsgUserFriendly(String errorMsg); static boolean isSelectStatement(String sql); static String removeCommentInSql(String sql1); }
QueryUtil { static String removeCatalog(String sql, String catalog) { if (catalog == null) return sql; else return sql.replace(catalog + ".", ""); } private  QueryUtil(); static String appendLimitOffsetToSql(String sql, int limit, int offset); @Deprecated static String massageSql(String sql, String project, int limit, int offset, String defaultSchema); static String massageSql(String sql, String project, int limit, int offset, String defaultSchema,
            String catalog); static String makeErrorMsgUserFriendly(Throwable e); static String makeErrorMsgUserFriendly(String errorMsg); static boolean isSelectStatement(String sql); static String removeCommentInSql(String sql1);  }