private List<String> getIntermediateTables() { List<String> intermediateTables = Lists.newArrayList(); String[] tables = StringUtil.splitAndTrim(getParam("oldHiveTables"), ","); for (String t : tables) { intermediateTables.add(t); } return intermediateTables; }
private List<String> getExternalDataPaths() { String[] paths = StringUtil.splitAndTrim(getParam("externalDataPaths"), ","); List<String> result = Lists.newArrayList(); for (String s : paths) { result.add(s); } return result; }
@RequestMapping(value = "/{tables}/{project}", method = { RequestMethod.POST }, produces = { "application/json" }) @ResponseBody public Map<String, String[]> loadHiveTables(@PathVariable String tables, @PathVariable String project, @RequestBody HiveTableRequest request) throws IOException { String submitter = SecurityContextHolder.getContext().getAuthentication().getName(); Map<String, String[]> result = new HashMap<String, String[]>(); String[] tableNames = StringUtil.splitAndTrim(tables, ","); try { String[] loaded = tableService.loadHiveTablesToProject(tableNames, project); result.put("result.loaded", loaded); Set<String> allTables = new HashSet<String>(); for (String tableName : tableNames) { allTables.add(tableService.normalizeHiveTableName(tableName)); } for (String loadedTableName : loaded) { allTables.remove(loadedTableName); } String[] unloaded = new String[allTables.size()]; allTables.toArray(unloaded); result.put("result.unloaded", unloaded); if (request.isCalculate()) { tableService.calculateCardinalityIfNotPresent(loaded, submitter, project); } } catch (Throwable e) { logger.error("Failed to load Hive Table", e); throw new InternalErrorException(e.getLocalizedMessage()); } return result; }
StringBuilder fileList = new StringBuilder(); for (String fileName : StringUtil.splitAndTrim(kylinDependency, ",")) { Path p = new Path(fileName); if (p.isAbsolute() == false) {
@Test public void splitAndTrimTest() { String[] expected = new String[] { "foo", "bar" }; Assert.assertArrayEquals(expected, StringUtil.splitAndTrim(" foo... bar. ", ".")); }
@Test public void testMaterializeViewHql() { final int viewSize = 2; String[] mockedViewNames = { "mockedView1", "mockedView2" }; String[] mockedTalbeNames = { "`mockedTable1`", "`mockedTable2`" }; String mockedWorkingDir = "mockedWorkingDir"; StringBuilder hqls = new StringBuilder(); for (int i = 0; i < viewSize; i++) { String hql = HiveInputBase.materializeViewHql(mockedViewNames[i], mockedTalbeNames[i], mockedWorkingDir); hqls.append(hql); } for (String sub : StringUtil.splitAndTrim(hqls.toString(), "\n")) { Assert.assertTrue(sub.endsWith(";")); } Assert.assertEquals("DROP TABLE IF EXISTS `mockedView1`;\n" + "CREATE TABLE IF NOT EXISTS `mockedView1` LIKE `mockedTable1` LOCATION 'mockedWorkingDir/mockedView1';\n" + "ALTER TABLE `mockedView1` SET TBLPROPERTIES('auto.purge'='true');\n" + "INSERT OVERWRITE TABLE `mockedView1` SELECT * FROM `mockedTable1`;\n" + "DROP TABLE IF EXISTS `mockedView2`;\n" + "CREATE TABLE IF NOT EXISTS `mockedView2` LIKE `mockedTable2` LOCATION 'mockedWorkingDir/mockedView2';\n" + "ALTER TABLE `mockedView2` SET TBLPROPERTIES('auto.purge'='true');\n" + "INSERT OVERWRITE TABLE `mockedView2` SELECT * FROM `mockedTable2`;\n", hqls.toString()); }
private List<String> getIntermediateTables() { List<String> intermediateTables = Lists.newArrayList(); String[] tables = StringUtil.splitAndTrim(getParam("oldHiveTables"), ","); for (String t : tables) { intermediateTables.add(t); } return intermediateTables; }
private List<String> getExternalDataPaths() { String[] paths = StringUtil.splitAndTrim(getParam("externalDataPaths"), ","); List<String> result = Lists.newArrayList(); for (String s : paths) { result.add(s); } return result; }
StringBuilder fileList = new StringBuilder(); for (String fileName : StringUtil.splitAndTrim(kylinDependency, ",")) { Path p = new Path(fileName); if (p.isAbsolute() == false) {