if (useHsqldbTestServer()) { this.getTestServer().dropExistingSchema(); } catch (SQLException sqlE) { fail(sqlE.toString()); this.createTableWithColTypes(types, vals); this.tableNames.add(this.getTableName()); this.removeTableDir(); incrementTableNum();
@After public void tearDown() { try { for (String table : tableNames) { dropTableIfExists(table); } } catch(SQLException e) { LOG.error("Can't clean up the database:", e); } super.tearDown(); }
/** * Create the argv to pass to Sqoop. * @return the argv as an array of strings. */ private String [] getArgv(String[] extraArgs, String[] excludeTables) { ArrayList<String> args = new ArrayList<String>(); CommonArgs.addHadoopFlags(args); args.add("--warehouse-dir"); args.add(getWarehouseDir()); args.add("--connect"); args.add(getConnectString()); args.add("--num-mappers"); args.add("1"); args.add("--escaped-by"); args.add("\\"); if (excludeTables != null) { args.add("--exclude-tables"); args.add(StringUtils.join(excludeTables, ",")); } if (extraArgs != null) { for (String arg : extraArgs) { args.add(arg); } } return args.toArray(new String[0]); }
@Test public void testMultiTableImport() throws IOException { String [] argv = getArgv(null, null); runImport(new ImportAllTablesTool(), argv); Path warehousePath = new Path(this.getWarehouseDir()); int i = 0; for (String tableName : this.tableNames) { if (!isOnPhysicalCluster()) { reader = new BufferedReader( new InputStreamReader(new FileInputStream( new File(filePath.toString())))); } else { FileSystem dfs = FileSystem.get(getConf()); FSDataInputStream dis = dfs.open(filePath); reader = new BufferedReader(new InputStreamReader(dis));
@Test public void testMultiTableImportAsParquetFormat() throws IOException { String [] argv = getArgv(new String[]{"--as-parquetfile"}, null); runImport(new ImportAllTablesTool(), argv); Path warehousePath = new Path(this.getWarehouseDir()); int i = 0; for (String tableName : this.tableNames) { Path tablePath = new Path(warehousePath, tableName); // dequeue the expected value for this table. This // list has the same order as the tableNames list. String expectedVal = Integer.toString(i++) + "," + this.expectedStrings.get(0); this.expectedStrings.remove(0); List<String> result = new ParquetReader(tablePath).readAllInCsv(); assertEquals("Table " + tableName + " expected a different string", singletonList(expectedVal), result); } }
@Test public void testMultiTableImportWithExclude() throws IOException { String exclude = this.tableNames.get(0); String [] argv = getArgv(null, new String[]{ exclude }); runImport(new ImportAllTablesTool(), argv); Path warehousePath = new Path(this.getWarehouseDir()); int i = 0; for (String tableName : this.tableNames) { if (!isOnPhysicalCluster()) { reader = new BufferedReader( new InputStreamReader(new FileInputStream( } else { FSDataInputStream dis; FileSystem dfs = FileSystem.get(getConf()); if (tableName.equals(exclude)) { try {