Search in sources :

Example 11 with LoadFileDesc

use of org.apache.hadoop.hive.ql.plan.LoadFileDesc in project hive by apache.

the class TestGenMapRedUtilsCreateConditionalTask method testMergePathValidMoveWorkReturnsNewMoveWork.

@Test
public void testMergePathValidMoveWorkReturnsNewMoveWork() {
    final Path condInputPath = new Path("s3a://bucket/scratch/-ext-10000");
    final Path condOutputPath = new Path("s3a://bucket/scratch/-ext-10002");
    final Path targetMoveWorkPath = new Path("s3a://bucket/scratch/-ext-10003");
    final MoveWork mockWork = mock(MoveWork.class);
    final LineageState lineageState = new LineageState();
    MoveWork newWork;
    // test using loadFileWork
    when(mockWork.getLoadFileWork()).thenReturn(new LoadFileDesc(condOutputPath, targetMoveWorkPath, false, "", "", false));
    newWork = GenMapRedUtils.mergeMovePaths(condInputPath, mockWork, lineageState);
    assertNotNull(newWork);
    assertNotEquals(newWork, mockWork);
    assertEquals(condInputPath, newWork.getLoadFileWork().getSourcePath());
    assertEquals(targetMoveWorkPath, newWork.getLoadFileWork().getTargetDir());
    // test using loadTableWork
    TableDesc tableDesc = new TableDesc();
    reset(mockWork);
    when(mockWork.getLoadTableWork()).thenReturn(new LoadTableDesc(condOutputPath, tableDesc, null));
    newWork = GenMapRedUtils.mergeMovePaths(condInputPath, mockWork, lineageState);
    assertNotNull(newWork);
    assertNotEquals(newWork, mockWork);
    assertEquals(condInputPath, newWork.getLoadTableWork().getSourcePath());
    assertTrue(newWork.getLoadTableWork().getTable().equals(tableDesc));
}
Also used : Path(org.apache.hadoop.fs.Path) MoveWork(org.apache.hadoop.hive.ql.plan.MoveWork) LoadTableDesc(org.apache.hadoop.hive.ql.plan.LoadTableDesc) LoadFileDesc(org.apache.hadoop.hive.ql.plan.LoadFileDesc) LineageState(org.apache.hadoop.hive.ql.session.LineageState) TableDesc(org.apache.hadoop.hive.ql.plan.TableDesc) LoadTableDesc(org.apache.hadoop.hive.ql.plan.LoadTableDesc) Test(org.junit.Test)

Example 12 with LoadFileDesc

use of org.apache.hadoop.hive.ql.plan.LoadFileDesc in project hive by apache.

the class TestGenMapRedUtilsCreateConditionalTask method createMoveTask.

private Task<MoveWork> createMoveTask(Path source, Path destination) {
    Task<MoveWork> moveTask = mock(MoveTask.class);
    MoveWork moveWork = new MoveWork();
    moveWork.setLoadFileWork(new LoadFileDesc(source, destination, true, null, null, false));
    when(moveTask.getWork()).thenReturn(moveWork);
    return moveTask;
}
Also used : MoveWork(org.apache.hadoop.hive.ql.plan.MoveWork) LoadFileDesc(org.apache.hadoop.hive.ql.plan.LoadFileDesc)

Aggregations

LoadFileDesc (org.apache.hadoop.hive.ql.plan.LoadFileDesc)12 LoadTableDesc (org.apache.hadoop.hive.ql.plan.LoadTableDesc)10 MoveWork (org.apache.hadoop.hive.ql.plan.MoveWork)9 Path (org.apache.hadoop.fs.Path)6 TableDesc (org.apache.hadoop.hive.ql.plan.TableDesc)5 DynamicPartitionCtx (org.apache.hadoop.hive.ql.plan.DynamicPartitionCtx)4 Serializable (java.io.Serializable)3 ArrayList (java.util.ArrayList)3 ColumnInfo (org.apache.hadoop.hive.ql.exec.ColumnInfo)3 RowSchema (org.apache.hadoop.hive.ql.exec.RowSchema)3 TableScanOperator (org.apache.hadoop.hive.ql.exec.TableScanOperator)3 HiveException (org.apache.hadoop.hive.ql.metadata.HiveException)3 FileSinkDesc (org.apache.hadoop.hive.ql.plan.FileSinkDesc)3 VisibleForTesting (com.google.common.annotations.VisibleForTesting)2 IOException (java.io.IOException)2 FieldSchema (org.apache.hadoop.hive.metastore.api.FieldSchema)2 MetaException (org.apache.hadoop.hive.metastore.api.MetaException)2 ConditionalTask (org.apache.hadoop.hive.ql.exec.ConditionalTask)2 FileSinkOperator (org.apache.hadoop.hive.ql.exec.FileSinkOperator)2 MaterializedViewDesc (org.apache.hadoop.hive.ql.exec.MaterializedViewDesc)2