Java Code Examples for org.apache.pig.newplan.logical.relational.LogicalSchema#merge()
The following examples show how to use
org.apache.pig.newplan.logical.relational.LogicalSchema#merge() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestSchema.java From spork with Apache License 2.0 | 6 votes |
@Test public void testNewNormalNestedMerge1() throws Exception { LogicalSchema a = org.apache.pig.newplan.logical.Util.translateSchema(Utils.getSchemaFromString( "a1:bytearray, b1:(b11:int, b12:float), c1:long")); LogicalSchema b = org.apache.pig.newplan.logical.Util.translateSchema(Utils.getSchemaFromString( "a2:bytearray, b2:(b21:double, b22:long), c2:int")); LogicalSchema mergedSchema = LogicalSchema.merge(a, b, LogicalSchema.MergeMode.Union); LogicalSchema expected = org.apache.pig.newplan.logical.Util.translateSchema(Utils.getSchemaFromString( "a1:bytearray, b1:(), c1:long")); expected.getField(1).schema = new LogicalSchema(); assertTrue(LogicalSchema.equals(mergedSchema, expected, false, false)); mergedSchema = LogicalSchema.merge(a, b, LogicalSchema.MergeMode.LoadForEach); expected = org.apache.pig.newplan.logical.Util.translateSchema(Utils.getSchemaFromString( "a1:bytearray, b1:(b11:int, b12:float), c1:long")); assertTrue(LogicalSchema.equals(mergedSchema, expected, false, false)); mergedSchema = LogicalSchema.merge(b, a, LogicalSchema.MergeMode.LoadForEach); expected = org.apache.pig.newplan.logical.Util.translateSchema(Utils.getSchemaFromString( "a2:bytearray, b2:(b21:double, b22:long), c2:int")); assertTrue(LogicalSchema.equals(mergedSchema, expected, false, false)); }
Example 2
Source File: TestSchema.java From spork with Apache License 2.0 | 6 votes |
@Test public void testNewNormalNestedMerge2() throws Exception { LogicalSchema a = org.apache.pig.newplan.logical.Util.translateSchema(Utils.getSchemaFromString( "a1:(a11:chararray, a12:float), b1:(b11:chararray, b12:float), c1:long")); LogicalSchema b = org.apache.pig.newplan.logical.Util.translateSchema(Utils.getSchemaFromString( "a2:bytearray, b2:(b21:double, b22:long), c2:chararray")); LogicalSchema mergedSchema = LogicalSchema.merge(a, b, LogicalSchema.MergeMode.Union); LogicalSchema expected = org.apache.pig.newplan.logical.Util.translateSchema(Utils.getSchemaFromString( "a1:(a11:chararray, a12:float), b1:(), c1:bytearray")); expected.getField(1).schema = new LogicalSchema(); assertTrue(LogicalSchema.equals(mergedSchema, expected, false, false)); mergedSchema = LogicalSchema.merge(a, b, LogicalSchema.MergeMode.LoadForEach); expected = org.apache.pig.newplan.logical.Util.translateSchema(Utils.getSchemaFromString( "a1:(a11:chararray, a12:float), b1:(b11:chararray, b12:float), c1:long")); assertTrue(LogicalSchema.equals(mergedSchema, expected, false, false)); mergedSchema = LogicalSchema.merge(b, a, LogicalSchema.MergeMode.LoadForEach); expected = org.apache.pig.newplan.logical.Util.translateSchema(Utils.getSchemaFromString( "a2:(a11:chararray, a12:float), b2:(b21:double, b22:long), c2:chararray")); assertTrue(LogicalSchema.equals(mergedSchema, expected, false, false)); }
Example 3
Source File: TestSchema.java From spork with Apache License 2.0 | 6 votes |
@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" ); 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" ); 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" ); assertTrue(LogicalSchema.equals(mergedSchema, expected, false, false)); }
Example 4
Source File: TestSchema.java From spork with Apache License 2.0 | 5 votes |
@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); assertEquals("{a: {t: (a0: int,a1: int)}}", org.apache.pig.newplan.logical.Util.translateSchema(ls3).toString()); }
Example 5
Source File: TestSchema.java From spork with Apache License 2.0 | 5 votes |
@Test(expected = FrontendException.class) 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); assertNull(mergedSchema); try { LogicalSchema.merge(a, b, LogicalSchema.MergeMode.LoadForEach); } catch (FrontendException e) { assertEquals(1031, e.getErrorCode()); throw e; } }