This is a way to replace a pig query by another query.
For example, if we have this map of overrides: Map<alias,query>
It might be possible to do the same thing in a less hacky way. e.g. pig.registerQuery replace the query of a certain alias...
399400401402403404405406407408409410411412
registerQuery(query, 1); } public void registerScript(String fileName) throws IOException { try { GruntParser grunt = new GruntParser(new FileReader(new File(fileName))); grunt.setInteractive(false); grunt.setParams(this); grunt.parseStopOnError(true); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); throw new IOException(e.getCause()); } catch (org.apache.pig.tools.pigscript.parser.ParseException e) {
349350351352353354355356357358359360361362
+ "using PigStorage(':') as (uname:chararray, passwd:chararray, uid:int,gid:int);" + "b = filter a by uid > 5;" + "explain b;" + "store b into '/tmp/output1';\n"; GruntParser parser = new GruntParser(new StringReader(script)); parser.setInteractive(false); parser.setParams(myPig); parser.parseStopOnError(); } catch (Exception e) { e.printStackTrace(); Assert.fail(); } finally {
374375376377378379380381382383384385386387
+ "using PigStorage(':') as (uname:chararray, passwd:chararray, uid:int,gid:int);" + "b = filter a by uid > 5;" + "dump b;" + "store b into '/tmp/output1';\n"; GruntParser parser = new GruntParser(new StringReader(script)); parser.setInteractive(false); parser.setParams(myPig); parser.parseStopOnError(); } catch (Exception e) { e.printStackTrace(); Assert.fail(); } finally {
+ "using PigStorage(':') as (uname:chararray, passwd:chararray, uid:int,gid:int);" + "b = filter a by uid > 5;" + "describe b;" + "store b into '/tmp/output1';\n"; GruntParser parser = new GruntParser(new StringReader(script)); parser.setInteractive(false); parser.setParams(myPig); parser.parseStopOnError(); } catch (Exception e) { e.printStackTrace(); Assert.fail(); } finally {
424425426427428429430431432433434435436437
+ "using PigStorage(':') as (uname:chararray, passwd:chararray, uid:int,gid:int);" + "b = filter a by uid > 5;" + "illustrate b;" + "store b into '/tmp/output1';\n"; GruntParser parser = new GruntParser(new StringReader(script)); parser.setInteractive(false); parser.setParams(myPig); parser.parseStopOnError(); } catch (Exception e) { e.printStackTrace(); Assert.fail(); } finally {
13621363136413651366136713681369137013711372137313741375
+ "using PigStorage(':') as (uname:chararray, passwd:chararray, uid:int,gid:int);" + "b = filter a by uid > 5;" + "explain b;" + "store b into '/tmp/output1';\n"; GruntParser parser = new GruntParser(new StringReader(script)); parser.setInteractive(false); parser.setParams(myPig); parser.parseStopOnError(); } catch (Exception e) { e.printStackTrace(); Assert.fail(); }
13851386138713881389139013911392139313941395139613971398
+ "using PigStorage(':') as (uname:chararray, passwd:chararray, uid:int,gid:int);" + "b = filter a by uid > 5;" + "dump b;" + "store b into '/tmp/output1';\n"; GruntParser parser = new GruntParser(new StringReader(script)); parser.setInteractive(false); parser.setParams(myPig); parser.parseStopOnError(); } catch (Exception e) { e.printStackTrace(); Assert.fail(); }
14081409141014111412141314141415141614171418141914201421
+ "using PigStorage(':') as (uname:chararray, passwd:chararray, uid:int,gid:int);" + "b = filter a by uid > 5;" + "describe b;" + "store b into '/tmp/output1';\n"; GruntParser parser = new GruntParser(new StringReader(script)); parser.setInteractive(false); parser.setParams(myPig); parser.parseStopOnError(); } catch (Exception e) { e.printStackTrace(); Assert.fail(); }
14311432143314341435143614371438143914401441144214431444
+ "using PigStorage(':') as (uname:chararray, passwd:chararray, uid:int,gid:int);" + "b = filter a by uid > 5;" + "illustrate b;" + "store b into '/tmp/output1';\n"; GruntParser parser = new GruntParser(new StringReader(script)); parser.setInteractive(false); parser.setParams(myPig); parser.parseStopOnError(); } catch (Exception e) { e.printStackTrace(); Assert.fail(); }
21172118211921202121212221232124212521262127212821292130