use of org.apache.gobblin.data.management.conversion.hive.entities.TableLikeStageableTableMetadata in project incubator-gobblin by apache.
the class HiveMaterializerTest method testMaterializeTablePartition.
@Test
public void testMaterializeTablePartition() throws Exception {
String destinationTable = "materializeTablePartition";
File tmpDir = Files.createTempDir();
tmpDir.deleteOnExit();
WorkUnit workUnit = HiveMaterializer.viewMaterializationWorkUnit(this.dataset, HiveConverterUtils.StorageFormat.AVRO, new TableLikeStageableTableMetadata(this.dataset.getTable(), this.dbName, destinationTable, tmpDir.getAbsolutePath()), String.format("%s=part1", this.partitionColumn));
HiveMaterializer hiveMaterializer = new HiveMaterializer(getTaskContextForRun(workUnit));
hiveMaterializer.run();
Assert.assertEquals(hiveMaterializer.getWorkingState(), WorkUnitState.WorkingState.SUCCESSFUL);
hiveMaterializer.commit();
Assert.assertEquals(hiveMaterializer.getWorkingState(), WorkUnitState.WorkingState.SUCCESSFUL);
List<List<String>> allTable = executeStatementAndGetResults(this.jdbcConnector, String.format("SELECT * FROM %s.%s", this.dbName, destinationTable), 3);
Assert.assertEquals(allTable.size(), 4);
Assert.assertEquals(allTable.stream().map(l -> l.get(0)).collect(Collectors.toList()), Lists.newArrayList("101", "102", "103", "104"));
}
use of org.apache.gobblin.data.management.conversion.hive.entities.TableLikeStageableTableMetadata in project incubator-gobblin by apache.
the class HiveMaterializerTest method testMaterializeTable.
@Test
public void testMaterializeTable() throws Exception {
String destinationTable = "materializeTable";
File tmpDir = Files.createTempDir();
tmpDir.deleteOnExit();
WorkUnit workUnit = HiveMaterializer.viewMaterializationWorkUnit(this.dataset, HiveConverterUtils.StorageFormat.AVRO, new TableLikeStageableTableMetadata(this.dataset.getTable(), this.dbName, destinationTable, tmpDir.getAbsolutePath()), null);
HiveMaterializer hiveMaterializer = new HiveMaterializer(getTaskContextForRun(workUnit));
hiveMaterializer.run();
Assert.assertEquals(hiveMaterializer.getWorkingState(), WorkUnitState.WorkingState.SUCCESSFUL);
hiveMaterializer.commit();
Assert.assertEquals(hiveMaterializer.getWorkingState(), WorkUnitState.WorkingState.SUCCESSFUL);
List<List<String>> allTable = executeStatementAndGetResults(this.jdbcConnector, String.format("SELECT * FROM %s.%s", this.dbName, destinationTable), 3);
Assert.assertEquals(allTable.size(), 8);
Assert.assertEquals(allTable.stream().map(l -> l.get(0)).collect(Collectors.toList()), Lists.newArrayList("101", "102", "103", "104", "201", "202", "203", "204"));
}
use of org.apache.gobblin.data.management.conversion.hive.entities.TableLikeStageableTableMetadata in project incubator-gobblin by apache.
the class HiveMaterializerTest method testCopyTable.
@Test
public void testCopyTable() throws Exception {
String destinationTable = "copyTable";
File tmpDir = Files.createTempDir();
tmpDir.deleteOnExit();
WorkUnit workUnit = HiveMaterializer.tableCopyWorkUnit(this.dataset, new TableLikeStageableTableMetadata(this.dataset.getTable(), this.dbName, destinationTable, tmpDir.getAbsolutePath()), String.format("%s=part1", this.partitionColumn));
HiveMaterializer hiveMaterializer = new HiveMaterializer(getTaskContextForRun(workUnit));
hiveMaterializer.run();
Assert.assertEquals(hiveMaterializer.getWorkingState(), WorkUnitState.WorkingState.SUCCESSFUL);
hiveMaterializer.commit();
Assert.assertEquals(hiveMaterializer.getWorkingState(), WorkUnitState.WorkingState.SUCCESSFUL);
List<List<String>> allTable = executeStatementAndGetResults(this.jdbcConnector, String.format("SELECT * FROM %s.%s", this.dbName, destinationTable), 3);
Assert.assertEquals(allTable.size(), 4);
Assert.assertEquals(allTable.stream().map(l -> l.get(0)).collect(Collectors.toList()), Lists.newArrayList("101", "102", "103", "104"));
}
use of org.apache.gobblin.data.management.conversion.hive.entities.TableLikeStageableTableMetadata in project incubator-gobblin by apache.
the class HiveMaterializerTest method testMaterializeView.
@Test
public void testMaterializeView() throws Exception {
String destinationTable = "materializeView";
File tmpDir = Files.createTempDir();
tmpDir.deleteOnExit();
String viewName = "myView";
this.jdbcConnector.executeStatements(String.format("CREATE VIEW %s.%s AS SELECT * FROM %s.%s WHERE name = 'foo'", this.dbName, viewName, this.dbName, this.sourceTableName));
Table view;
try (AutoReturnableObject<IMetaStoreClient> client = pool.getClient()) {
view = new Table(client.get().getTable(this.dbName, viewName));
}
HiveDataset viewDataset = new HiveDataset(FileSystem.getLocal(new Configuration()), pool, view, new Properties());
WorkUnit workUnit = HiveMaterializer.viewMaterializationWorkUnit(viewDataset, HiveConverterUtils.StorageFormat.AVRO, new TableLikeStageableTableMetadata(viewDataset.getTable(), this.dbName, destinationTable, tmpDir.getAbsolutePath()), null);
HiveMaterializer hiveMaterializer = new HiveMaterializer(getTaskContextForRun(workUnit));
hiveMaterializer.run();
Assert.assertEquals(hiveMaterializer.getWorkingState(), WorkUnitState.WorkingState.SUCCESSFUL);
hiveMaterializer.commit();
Assert.assertEquals(hiveMaterializer.getWorkingState(), WorkUnitState.WorkingState.SUCCESSFUL);
List<List<String>> allTable = executeStatementAndGetResults(this.jdbcConnector, String.format("SELECT * FROM %s.%s", this.dbName, destinationTable), 3);
Assert.assertEquals(allTable.size(), 4);
Assert.assertEquals(allTable.stream().map(l -> l.get(0)).collect(Collectors.toList()), Lists.newArrayList("101", "103", "201", "203"));
}
use of org.apache.gobblin.data.management.conversion.hive.entities.TableLikeStageableTableMetadata in project incubator-gobblin by apache.
the class HiveMaterializerTest method testMaterializeQuery.
@Test
public void testMaterializeQuery() throws Exception {
String destinationTable = "materializeQuery";
File tmpDir = Files.createTempDir();
tmpDir.deleteOnExit();
WorkUnit workUnit = HiveMaterializer.queryResultMaterializationWorkUnit(String.format("SELECT * FROM %s.%s WHERE name = 'foo'", this.dbName, this.sourceTableName), HiveConverterUtils.StorageFormat.AVRO, new TableLikeStageableTableMetadata(this.dataset.getTable(), this.dbName, destinationTable, tmpDir.getAbsolutePath()));
HiveMaterializer hiveMaterializer = new HiveMaterializer(getTaskContextForRun(workUnit));
hiveMaterializer.run();
Assert.assertEquals(hiveMaterializer.getWorkingState(), WorkUnitState.WorkingState.SUCCESSFUL);
hiveMaterializer.commit();
Assert.assertEquals(hiveMaterializer.getWorkingState(), WorkUnitState.WorkingState.SUCCESSFUL);
List<List<String>> allTable = executeStatementAndGetResults(this.jdbcConnector, String.format("SELECT * FROM %s.%s", this.dbName, destinationTable), 3);
Assert.assertEquals(allTable.size(), 4);
Assert.assertEquals(allTable.stream().map(l -> l.get(0)).collect(Collectors.toList()), Lists.newArrayList("101", "103", "201", "203"));
}
Aggregations