Java Code Examples for org.apache.pig.PigException#getMessage()
The following examples show how to use
org.apache.pig.PigException#getMessage() .
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: TestUnionOnSchema.java From spork with Apache License 2.0 | 6 votes |
private void checkSchemaEx(String query, String expectedErr) throws IOException { PigServer pig = new PigServer(ExecType.LOCAL); boolean foundEx = false; try{ Util.registerMultiLineQuery(pig, query); pig.dumpSchema("u"); }catch(FrontendException e){ PigException pigEx = LogUtils.getPigException(e); foundEx = true; if(!pigEx.getMessage().contains(expectedErr)){ String msg = "Expected exception message matching '" + expectedErr + "' but got '" + pigEx.getMessage() + "'" ; fail(msg); } } if(!foundEx) fail("No exception thrown. Exception is expected."); }
Example 2
Source File: TestBestFitCast.java From spork with Apache License 2.0 | 6 votes |
@Test public void testByteArrayCast1() throws IOException { // Passing (float, bytearray) // Ambiguous matches: (float, long) , (float, double) boolean exceptionCaused = false; try { pigServer.registerQuery("A = LOAD '" + inputFile + "' as (x:float, y);"); pigServer.registerQuery("B = FOREACH A generate x, " + UDF3.class.getName() + "(x,y);"); pigServer.openIterator("B"); } catch (Exception e) { exceptionCaused = true; PigException pe = LogUtils.getPigException(e); String msg = (pe == null ? e.getMessage() : pe.getMessage()); assertTrue(msg.contains("Multiple matching functions")); assertTrue(msg.contains("{float,double}, {float,long}")); } assertTrue(exceptionCaused); }
Example 3
Source File: TestBestFitCast.java From spork with Apache License 2.0 | 6 votes |
@Test public void testByteArrayCast5() throws IOException, ExecException { // Passing (bytearray, int, int ) // Ambiguous matches: (float, long, double) , (float, double, long) // bytearray can be casted to float but the two ints cannot be unambiguously // casted boolean exceptionCaused = false; try { pigServer.registerQuery("A = LOAD '" + inputFile + "' as (x, y:int);"); pigServer.registerQuery("B = FOREACH A generate x, " + UDF3.class.getName() + "(x,y, y);"); pigServer.openIterator("B"); } catch (Exception e) { exceptionCaused = true; PigException pe = LogUtils.getPigException(e); String msg = (pe == null ? e.getMessage() : pe.getMessage()); assertTrue(msg.contains("Multiple matching functions")); assertTrue(msg.contains("({float,double,long}, {float,long,double})")); } assertTrue(exceptionCaused); }
Example 4
Source File: TestBestFitCast.java From spork with Apache License 2.0 | 6 votes |
@Test public void testByteArrayCast6() throws IOException, ExecException { // Passing (bytearray, long, long ) // Ambiguous matches: (float, long, double) , (float, double, long) // bytearray can be casted to float but the two longs cannot be // unambiguously casted boolean exceptionCaused = false; try { pigServer.registerQuery("A = LOAD '" + inputFile + "' as (x, y:long);"); pigServer.registerQuery("B = FOREACH A generate x, " + UDF3.class.getName() + "(x,y, y);"); pigServer.openIterator("B"); } catch (Exception e) { exceptionCaused = true; PigException pe = LogUtils.getPigException(e); String msg = (pe == null ? e.getMessage() : pe.getMessage()); assertTrue(msg.contains("Multiple matching functions")); assertTrue(msg.contains("({float,double,long}, {float,long,double})")); } assertTrue(exceptionCaused); }
Example 5
Source File: TestBestFitCast.java From spork with Apache License 2.0 | 6 votes |
@Test public void testByteArrayCast7() throws IOException, ExecException { // Passing (bytearray, double, double ) // Ambiguous matches: (float, long, double) , (float, double, long) // bytearray can be casted to float but the two doubles cannot be // casted with a permissible cast boolean exceptionCaused = false; try { pigServer.registerQuery("A = LOAD '" + inputFile + "' as (x, y:double);"); pigServer.registerQuery("B = FOREACH A generate x, " + UDF3.class.getName() + "(x,y, y);"); pigServer.openIterator("B"); } catch (Exception e) { exceptionCaused = true; PigException pe = LogUtils.getPigException(e); String msg = (pe == null ? e.getMessage() : pe.getMessage()); assertTrue(msg.contains("Could not infer the matching function")); } assertTrue(exceptionCaused); }
Example 6
Source File: TestBestFitCast.java From spork with Apache License 2.0 | 6 votes |
@Test public void testByteArrayCast12() throws IOException, ExecException { // Passing (float, bytearray, int ) // Ambiguous matches: (float, long, double) , (float, double, long) // will cause conflict since we could cast int to // long or double and bytearray to long or double. boolean exceptionCaused = false; try { pigServer.registerQuery("A = LOAD '" + inputFile2 + "' as (x:float, y, z:int);"); pigServer.registerQuery("B = FOREACH A generate x, " + UDF3.class.getName() + "(x,y, y);"); pigServer.openIterator("B"); } catch (Exception e) { exceptionCaused = true; PigException pe = LogUtils.getPigException(e); String msg = (pe == null ? e.getMessage() : pe.getMessage()); assertTrue(msg.contains("Multiple matching functions")); assertTrue(msg.contains("({float,double,long}, {float,long,double}")); } assertTrue(exceptionCaused); }
Example 7
Source File: TestBestFitCast.java From spork with Apache License 2.0 | 6 votes |
@Test public void test2() throws Exception { // Passing (int, int) // Possible matches: (float, float) , (long, double) // Throws Exception as ambiguous definitions found try { pigServer.registerQuery("A = LOAD '" + inputFile + "' as (x:long, y:int);"); pigServer.registerQuery("B = FOREACH A generate x, " + UDF1.class.getName() + "(y,y);"); pigServer.openIterator("B"); } catch (Exception e) { PigException pe = LogUtils.getPigException(e); String msg = (pe == null ? e.getMessage() : pe.getMessage()); assertEquals(true, msg.contains("as multiple or none of them fit")); } }
Example 8
Source File: TestBestFitCast.java From spork with Apache License 2.0 | 6 votes |
@Test public void test5() throws Exception { // Passing bytearrays // Possible matches: (float, float) , (long, double) // Throws exception since more than one funcSpec and inp is bytearray try { pigServer.registerQuery("A = LOAD '" + inputFile + "';"); pigServer.registerQuery("B = FOREACH A generate $0, " + UDF1.class.getName() + "($1,$1);"); pigServer.openIterator("B"); } catch (Exception e) { PigException pe = LogUtils.getPigException(e); String msg = (pe == null ? e.getMessage() : pe.getMessage()); assertEquals(true, msg.contains("Multiple matching functions")); } }
Example 9
Source File: Util.java From spork with Apache License 2.0 | 5 votes |
public static void checkMessageInException(FrontendException e, String expectedErr) { PigException pigEx = LogUtils.getPigException(e); String message = pigEx.getMessage(); checkErrorMessageContainsExpected(message, expectedErr); }