[ 
https://issues.apache.org/jira/browse/PIG-2866?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13432264#comment-13432264
 ] 

Bill Graham commented on PIG-2866:
----------------------------------

Here's a workaround for now. Instead of passing an {{InputStream}}, pass a file:

{noformat}
InputStream scriptInputStream = ...

File file = File.createTempFile("foo", "bar");
file.deleteOnExit();
OutputStream out = new FileOutputStream(file);

int read = 0;
byte[] bytes = new byte[1024];
while ((read = scriptInputStream.read(bytes)) != -1) {
   out.write(bytes, 0, read);
}

scriptInputStream.close();
out.flush();
out.close();

ScriptState.get().setFileName(file.getAbsolutePath()); <---- This is important
pigServer.registerScript(file.getAbsolutePath());
{noformat}


                
> PigServer fails with macros without a script file
> -------------------------------------------------
>
>                 Key: PIG-2866
>                 URL: https://issues.apache.org/jira/browse/PIG-2866
>             Project: Pig
>          Issue Type: Bug
>            Reporter: Bill Graham
>            Assignee: Bill Graham
>
> Making a call to {{PigServer.registerQuery}} with an {{InputStream}} will 
> fail if the script contains a macro. This is because 
> {{QueryParserDriver.makeMacroDef}} requires a filename. 
> {{QueryParserDriver.makeMacroDef}} should be changed to not assume that the 
> script input is from a file.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: 
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to