Пример #1
0
 @Test
 // See PIG-730
 public void testMergeSchemaWithTwoLevelAccess3() throws Exception {
   // Generate two schemas
   LogicalSchema ls1 = Utils.parseSchema("a:{t:(a0:int, a1:int)}");
   LogicalSchema ls2 = Utils.parseSchema("b:{t:(b0:int, b1:int)}");
   LogicalSchema ls3 = LogicalSchema.merge(ls1, ls2, MergeMode.LoadForEach);
   Assert.assertTrue(
       org.apache.pig.newplan.logical.Util.translateSchema(ls3)
           .toString()
           .equals("{a: {(a0: int,a1: int)}}"));
 }
Пример #2
0
  @Test
  public void testNewMergeDifferentSize1() throws Throwable {
    LogicalSchema a = Utils.parseSchema("a1:bytearray, b1:long, c1:long");
    LogicalSchema b = Utils.parseSchema("a2:bytearray, b2:long");

    LogicalSchema mergedSchema = LogicalSchema.merge(a, b, LogicalSchema.MergeMode.Union);
    Assert.assertTrue(mergedSchema == null);

    try {
      LogicalSchema.merge(a, b, LogicalSchema.MergeMode.LoadForEach);
      Assert.fail();
    } catch (FrontendException e) {
      Assert.assertTrue(e.getErrorCode() == 1031);
    }
  }
Пример #3
0
  @Test
  public void testNewMergeNullSchemas() throws Throwable {
    LogicalSchema a = Utils.parseSchema("a1:bytearray, b1:(b11:int, b12:float), c1:long");
    LogicalSchema b = Utils.parseSchema("a2:bytearray, b2:(), c2:int");

    LogicalSchema mergedSchema = LogicalSchema.merge(a, b, LogicalSchema.MergeMode.Union);
    LogicalSchema expected = Utils.parseSchema("a1:bytearray, b1:(), c1:long");
    Assert.assertTrue(LogicalSchema.equals(mergedSchema, expected, false, false));

    mergedSchema = LogicalSchema.merge(a, b, LogicalSchema.MergeMode.LoadForEach);
    expected = Utils.parseSchema("a1:bytearray, b1:(b11:int, b12:float), c1:long");
    Assert.assertTrue(LogicalSchema.equals(mergedSchema, expected, false, false));

    mergedSchema = LogicalSchema.merge(b, a, LogicalSchema.MergeMode.LoadForEach);
    expected = Utils.parseSchema("a2:bytearray, b2:(b11:int,b12:float), c2:int");
    Assert.assertTrue(LogicalSchema.equals(mergedSchema, expected, false, false));
  }