@Test public void testDiscoverTablespaceFromSelect() { String defaultTableSpace = TableSpace.DEFAULT; String theTableSpace = "myts"; assertEquals(defaultTableSpace, QueryUtils.discoverTablespace(defaultTableSpace, "select * from test")); assertEquals(defaultTableSpace, QueryUtils.discoverTablespace(defaultTableSpace, "")); assertEquals(theTableSpace, QueryUtils.discoverTablespace(defaultTableSpace, "select a from myts.test")); assertEquals(theTableSpace, QueryUtils.discoverTablespace(defaultTableSpace, "select a.b from myts.test")); assertEquals(theTableSpace, QueryUtils.discoverTablespace(defaultTableSpace, "select a.b from myts.test where foo='bar'")); assertEquals(theTableSpace, QueryUtils.discoverTablespace(defaultTableSpace, "select * from myts.test")); assertEquals(theTableSpace, QueryUtils.discoverTablespace(defaultTableSpace, "SELECT COUNT(M.id) FROM myts.a M WHERE 1=1 AND (M.id IN (SELECT H.id FROM myts.b AS H WHERE H.FIELD_NAME='From' AND H.FIELD_VALUE LIKE 'aaa'))")); }
public static String discoverTablespace(String defaultTableSpace, String query) { if (query == null) { return defaultTableSpace; } final Matcher matcher = TABLE_SPACE_NAME_PATTERN.matcher(query); if (matcher.find()) { final String tableSpace = matcher.group("tablespace"); if (tableSpace != null) { return tableSpace.substring(0, tableSpace.length() - 1); } } return defaultTableSpace; }
QueryUtils { public static String discoverTablespace(String defaultTableSpace, String query) { if (query == null) { return defaultTableSpace; } final Matcher matcher = TABLE_SPACE_NAME_PATTERN.matcher(query); if (matcher.find()) { final String tableSpace = matcher.group("tablespace"); if (tableSpace != null) { return tableSpace.substring(0, tableSpace.length() - 1); } } return defaultTableSpace; } }
QueryUtils { public static String discoverTablespace(String defaultTableSpace, String query) { if (query == null) { return defaultTableSpace; } final Matcher matcher = TABLE_SPACE_NAME_PATTERN.matcher(query); if (matcher.find()) { final String tableSpace = matcher.group("tablespace"); if (tableSpace != null) { return tableSpace.substring(0, tableSpace.length() - 1); } } return defaultTableSpace; }  }
QueryUtils { public static String discoverTablespace(String defaultTableSpace, String query) { if (query == null) { return defaultTableSpace; } final Matcher matcher = TABLE_SPACE_NAME_PATTERN.matcher(query); if (matcher.find()) { final String tableSpace = matcher.group("tablespace"); if (tableSpace != null) { return tableSpace.substring(0, tableSpace.length() - 1); } } return defaultTableSpace; }  static String discoverTablespace(String defaultTableSpace, String query); }
QueryUtils { public static String discoverTablespace(String defaultTableSpace, String query) { if (query == null) { return defaultTableSpace; } final Matcher matcher = TABLE_SPACE_NAME_PATTERN.matcher(query); if (matcher.find()) { final String tableSpace = matcher.group("tablespace"); if (tableSpace != null) { return tableSpace.substring(0, tableSpace.length() - 1); } } return defaultTableSpace; }  static String discoverTablespace(String defaultTableSpace, String query);  }