Registers a pig scripts with its variables substituted. @throws IOException If a temp file containing the pig script could not be created. @throws ParseException The pig script could not have all its variables substituted.
()
| 180 | * @throws ParseException The pig script could not have all its variables substituted. |
| 181 | */ |
| 182 | protected void registerScript() throws IOException, ParseException { |
| 183 | getCluster(); |
| 184 | |
| 185 | BufferedReader reader = new BufferedReader(new StringReader(this.originalTextPigScript)); |
| 186 | PigContext context = getPigServer().getPigContext(); |
| 187 | |
| 188 | String substitutedPig = context.doParamSubstitution(reader, |
| 189 | args == null ? null : Arrays.asList(args), |
| 190 | argFiles == null ? null : Arrays.asList(argFiles)); |
| 191 | LOG.info(substitutedPig); |
| 192 | |
| 193 | File f = File.createTempFile("tmp", "pigunit"); |
| 194 | PrintWriter pw = new PrintWriter(f); |
| 195 | pw.println(substitutedPig); |
| 196 | pw.close(); |
| 197 | |
| 198 | String pigSubstitutedFile = f.getCanonicalPath(); |
| 199 | getPigServer().registerScript(pigSubstitutedFile, aliasOverrides); |
| 200 | } |
| 201 | |
| 202 | /** |
| 203 | * Executes the Pig script with its current overrides. |
no test coverage detected