[
https://issues.apache.org/jira/browse/PIG-2729?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13417313#comment-13417313
]
Rohini Palaniswamy commented on PIG-2729:
-----------------------------------------
No worries. For future reference,
https://cwiki.apache.org/confluence/display/PIG/HowToContribute has all the
instructions. Its a really nice writeup and I had found it very helpful.
You are right with 1 and 2. It makes it same as the old logic. I was thinking
it would keep it simpler if instead of copying all the logic to getMacroFile
method, we could just change the name of
QueryParserUtil.getImportScriptAsReader to something like
getFileFromSearchImportPath and make it return a file instead of bufferedReader
and null instead of FileNotFoundException. That way the logic remains exactly
same and we don't have to worry about missing something.
{code}
QueryParserUtils.java
- static BufferedReader getImportScriptAsReader(String scriptPath)
- throws FileNotFoundException {
+
+ static File getFileFromSearchImportPath(String scriptPath) {
- return new BufferedReader(new FileReader(f));
+ return f;
- return new BufferedReader(new FileReader(f1));
+ return f1;
-
- throw new FileNotFoundException("Can't find the Specified file "
- + scriptPath);
+ return null;
QueryParserDriver.java getMacroFile():
File localFile = QueryParserUtils.getFileFromSearchImportPath(fname);
localFileRet = localFile == null
? FileLocalizer.fetchFile(pigContext.getProperties(), fname)
: new FetchFileRet(localFile.getCanonicalFile(), false);
{code}
And I checked. importTwoFilesTest still fails. I had to make mytest1.pig and
mytest2.pig to mytest4.pig and mytest5.pig to get it to pass. The cleaner thing
to do would be to clear the cache in QueryParserDriver before each test. But I
think this should be ok for now as the cache is private.
You can verify your patch by running
ant -Djavac.args="-Xlint -Xmaxwarns 1000" clean jar-withouthadoop test
-Dtestcase=TestMacroExpansion -logfile /tmp/log
> Macro expansion does not use pig.import.search.path - UnitTest borked
> ---------------------------------------------------------------------
>
> Key: PIG-2729
> URL: https://issues.apache.org/jira/browse/PIG-2729
> Project: Pig
> Issue Type: Bug
> Affects Versions: 0.9.2, 0.10.0
> Environment: pig-0.9.2 and pig-0.10.0, hadoop-0.20.2 from Clouderas
> distribution cdh3u3 on Kubuntu 12.04 64Bit.
> Reporter: Johannes Schwenk
> Fix For: 0.10.0
>
> Attachments: PIG-2729.patch, test-macros.tar.gz,
> use-search-path-for-imports.patch
>
>
> org.apache.pig.test.TestMacroExpansion, in function importUsingSearchPathTest
> the import statement is provided with the full path to /tmp/mytest2.pig so
> the pig.import.search.path is never used. I changed the import to
> import 'mytest2.pig';
> and ran the UnitTest again. This time the test failed as expected from my
> experience from earlier this day trying in vain to get pig eat my
> pig.import.search.path property! Other properties in the same custom
> properties file (provided via -propertyFile command line option) like
> udf.import.list get read without any problem.
--
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