Java Code Examples for org.apache.pig.impl.logicalLayer.FrontendException#getMessage()
The following examples show how to use
org.apache.pig.impl.logicalLayer.FrontendException#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: QueryParserDriver.java From spork with Apache License 2.0 | 6 votes |
private boolean expandImport(Tree ast) throws ParserException { List<CommonTree> nodes = new ArrayList<CommonTree>(); traverseImport(ast, nodes); if (nodes.isEmpty()) return false; // Validate if imports are enabled/disabled final BlackAndWhitelistFilter filter = new BlackAndWhitelistFilter( this.pigContext); try { filter.validate(PigCommandFilter.Command.IMPORT); } catch (FrontendException e) { throw new ParserException(e.getMessage()); } for (CommonTree t : nodes) { macroImport(t); } return true; }
Example 2
Source File: TestErrorHandling.java From spork with Apache License 2.0 | 6 votes |
@Test // PIG-1956, 1957 public void tesNegative9() throws IOException { pig.registerQuery("a = load 'temp' as (a0:int, a1:int);\n"); pig.registerQuery("b = group a by a0;\n"); try { pig.registerQuery("c = foreach b { " + " c1 = foreach a { " + " c11 = filter a by a1 > 0; " + " generate c11; " + " } " + " generate c1; " + " }\n"); } catch (FrontendException ex) { String msg = ex.getMessage(); Assert.assertTrue( msg.contains( "line 5, column 32" ) ); Assert.assertTrue( msg.contains( "mismatched input '{' expecting GENERATE")); return; } Assert.fail( "Testcase should fail" ); }
Example 3
Source File: TestErrorHandling.java From spork with Apache License 2.0 | 6 votes |
@Test // PIG-1921 public void tesNegative13() throws IOException { String query = "A = load 'x' as (u:int, v);\n" + "B = load 'y';\n" + "C = join A by u, B by w;"; try { pig.registerQuery( query ); } catch(FrontendException ex) { String msg = ex.getMessage(); System.out.println( msg ); Assert.assertTrue( !msg.contains( "null") ); Assert.assertTrue( msg.contains( "Projected field [w] does not exist.") ); return; } Assert.fail( "Testcase should fail" ); }
Example 4
Source File: TestDataBagAccess.java From spork with Apache License 2.0 | 6 votes |
@Test public void testBagConstantAccessFailure() throws IOException, ExecException { File input = Util.createInputFile("tmp", "", new String[] {"sampledata\tnot_used"}); boolean exceptionOccured = false; pigServer.setValidateEachStatement(true); try { pigServer.registerQuery("a = load '" + Util.generateURI(input.toString(), pigServer.getPigContext()) + "';"); pigServer.registerQuery("b = foreach a generate {(16, 4.0e-2, 'hello')} as mybag:{t:(i: int, d: double, c: chararray)};"); pigServer.registerQuery("c = foreach b generate mybag.t;"); pigServer.explain("c", System.out); } catch(FrontendException e) { exceptionOccured = true; String msg = e.getMessage(); Util.checkStrContainsSubStr(msg, "Cannot find field t in i:int,d:double,c:chararray"); } assertTrue(exceptionOccured); }
Example 5
Source File: LogicalPlanBuilder.java From spork with Apache License 2.0 | 5 votes |
void defineCommand(String alias, StreamingCommand command) { try { filter.validate(PigCommandFilter.Command.DEFINE); } catch (FrontendException e) { throw new RuntimeException(e.getMessage()); } pigContext.registerStreamCmd( alias, command ); }
Example 6
Source File: TestErrorHandling.java From spork with Apache License 2.0 | 5 votes |
@Test // PIG-1961 public void tesNegative11() throws IOException { String query = "A = load ^ 'x' as (name, age, gpa);\n"; try { pig.registerQuery( query ); } catch(FrontendException ex) { String msg = ex.getMessage(); System.out.println( msg ); Assert.assertFalse( msg.contains( "file null" ) ); Assert.assertTrue( msg.contains( "Unexpected character" ) ); return; } Assert.fail( "Testcase should fail" ); }
Example 7
Source File: TestErrorHandling.java From spork with Apache License 2.0 | 5 votes |
@Test // PIG-1961 public void tesNegative12() throws IOException { String query = "A = loadd 'x' as (name, age, gpa);\n"; try { pig.registerQuery( query ); } catch(FrontendException ex) { String msg = ex.getMessage(); System.out.println( msg ); Assert.assertFalse( msg.contains( "file null" ) ); Assert.assertTrue( msg.contains( "Syntax error, unexpected symbol at or near 'A'" ) ); return; } Assert.fail( "Testcase should fail" ); }
Example 8
Source File: TestErrorHandling.java From spork with Apache License 2.0 | 5 votes |
@Test //pig-2606 public void testNegative14() throws IOException { String query = "A = load 'x'; \n" + "B = union A, A;"; try { pig.registerQuery( query ); } catch(FrontendException ex) { String msg = ex.getMessage(); System.out.println( msg ); Assert.assertTrue( msg.contains( "Pig does not accept same alias as input for") ); Assert.assertTrue( msg.contains( "UNION") ); return; } Assert.fail( "Testcase should fail" ); }
Example 9
Source File: TestErrorHandling.java From spork with Apache License 2.0 | 5 votes |
@Test //pig-2606 public void testNegative15() throws IOException { String query = "A = load 'x' as (a0, a1); \n" + "B = join A by a0, A by a1;"; try { pig.registerQuery( query ); } catch(FrontendException ex) { String msg = ex.getMessage(); System.out.println( msg ); Assert.assertTrue( msg.contains( "Pig does not accept same alias as input for") ); Assert.assertTrue( msg.contains( "JOIN") ); return; } Assert.fail( "Testcase should fail" ); }