@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")); }
public static HiveWorkUnit tableCopyWorkUnit(HiveDataset dataset, StageableTableMetadata destinationTable, @Nullable String partitionName) { HiveWorkUnit workUnit = new HiveWorkUnit(dataset); workUnit.setProp(MATERIALIZER_MODE_KEY, MaterializerMode.TABLE_COPY.name()); workUnit.setProp(STAGEABLE_TABLE_METADATA_KEY, HiveSource.GENERICS_AWARE_GSON.toJson(destinationTable)); if (!Strings.isNullOrEmpty(partitionName)) { workUnit.setPartitionName(partitionName); } TaskUtils.setTaskFactoryClass(workUnit, HiveMaterializerTaskFactory.class); return workUnit; }
HiveMaterializer extends HiveTask { public static HiveWorkUnit tableCopyWorkUnit(HiveDataset dataset, StageableTableMetadata destinationTable, @Nullable String partitionName) { HiveWorkUnit workUnit = new HiveWorkUnit(dataset); workUnit.setProp(MATERIALIZER_MODE_KEY, MaterializerMode.TABLE_COPY.name()); workUnit.setProp(STAGEABLE_TABLE_METADATA_KEY, HiveSource.GENERICS_AWARE_GSON.toJson(destinationTable)); if (!Strings.isNullOrEmpty(partitionName)) { workUnit.setPartitionName(partitionName); } TaskUtils.setTaskFactoryClass(workUnit, HiveMaterializerTaskFactory.class); return workUnit; } }
HiveMaterializer extends HiveTask { public static HiveWorkUnit tableCopyWorkUnit(HiveDataset dataset, StageableTableMetadata destinationTable, @Nullable String partitionName) { HiveWorkUnit workUnit = new HiveWorkUnit(dataset); workUnit.setProp(MATERIALIZER_MODE_KEY, MaterializerMode.TABLE_COPY.name()); workUnit.setProp(STAGEABLE_TABLE_METADATA_KEY, HiveSource.GENERICS_AWARE_GSON.toJson(destinationTable)); if (!Strings.isNullOrEmpty(partitionName)) { workUnit.setPartitionName(partitionName); } TaskUtils.setTaskFactoryClass(workUnit, HiveMaterializerTaskFactory.class); return workUnit; } HiveMaterializer(TaskContext taskContext); }
HiveMaterializer extends HiveTask { public static HiveWorkUnit tableCopyWorkUnit(HiveDataset dataset, StageableTableMetadata destinationTable, @Nullable String partitionName) { HiveWorkUnit workUnit = new HiveWorkUnit(dataset); workUnit.setProp(MATERIALIZER_MODE_KEY, MaterializerMode.TABLE_COPY.name()); workUnit.setProp(STAGEABLE_TABLE_METADATA_KEY, HiveSource.GENERICS_AWARE_GSON.toJson(destinationTable)); if (!Strings.isNullOrEmpty(partitionName)) { workUnit.setPartitionName(partitionName); } TaskUtils.setTaskFactoryClass(workUnit, HiveMaterializerTaskFactory.class); return workUnit; } HiveMaterializer(TaskContext taskContext); static HiveWorkUnit tableCopyWorkUnit(HiveDataset dataset, StageableTableMetadata destinationTable,
      @Nullable String partitionName); static HiveWorkUnit viewMaterializationWorkUnit(HiveDataset dataset, HiveConverterUtils.StorageFormat storageFormat,
      StageableTableMetadata destinationTable, @Nullable String partitionName); static WorkUnit queryResultMaterializationWorkUnit(String query, HiveConverterUtils.StorageFormat storageFormat,
      StageableTableMetadata destinationTable); static StageableTableMetadata parseStageableTableMetadata(WorkUnit workUnit); @Override List<String> generateHiveQueries(); @Override QueryBasedHivePublishEntity generatePublishQueries(); }
HiveMaterializer extends HiveTask { public static HiveWorkUnit tableCopyWorkUnit(HiveDataset dataset, StageableTableMetadata destinationTable, @Nullable String partitionName) { HiveWorkUnit workUnit = new HiveWorkUnit(dataset); workUnit.setProp(MATERIALIZER_MODE_KEY, MaterializerMode.TABLE_COPY.name()); workUnit.setProp(STAGEABLE_TABLE_METADATA_KEY, HiveSource.GENERICS_AWARE_GSON.toJson(destinationTable)); if (!Strings.isNullOrEmpty(partitionName)) { workUnit.setPartitionName(partitionName); } TaskUtils.setTaskFactoryClass(workUnit, HiveMaterializerTaskFactory.class); return workUnit; } HiveMaterializer(TaskContext taskContext); static HiveWorkUnit tableCopyWorkUnit(HiveDataset dataset, StageableTableMetadata destinationTable,
      @Nullable String partitionName); static HiveWorkUnit viewMaterializationWorkUnit(HiveDataset dataset, HiveConverterUtils.StorageFormat storageFormat,
      StageableTableMetadata destinationTable, @Nullable String partitionName); static WorkUnit queryResultMaterializationWorkUnit(String query, HiveConverterUtils.StorageFormat storageFormat,
      StageableTableMetadata destinationTable); static StageableTableMetadata parseStageableTableMetadata(WorkUnit workUnit); @Override List<String> generateHiveQueries(); @Override QueryBasedHivePublishEntity generatePublishQueries();  }