pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From roh...@apache.org
Subject svn commit: r1745287 - in /pig/branches/branch-0.16: CHANGES.txt src/org/apache/pig/PigServer.java
Date Mon, 23 May 2016 22:37:59 GMT
Author: rohini
Date: Mon May 23 22:37:59 2016
New Revision: 1745287

URL: http://svn.apache.org/viewvc?rev=1745287&view=rev
Log:
PIG-4908: JythonFunction refers to Oozie launcher script absolute path (rohini)

Modified:
    pig/branches/branch-0.16/CHANGES.txt
    pig/branches/branch-0.16/src/org/apache/pig/PigServer.java

Modified: pig/branches/branch-0.16/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.16/CHANGES.txt?rev=1745287&r1=1745286&r2=1745287&view=diff
==============================================================================
--- pig/branches/branch-0.16/CHANGES.txt (original)
+++ pig/branches/branch-0.16/CHANGES.txt Mon May 23 22:37:59 2016
@@ -129,6 +129,8 @@ PIG-4639: Add better parser for Apache H
 
 BUG FIXES
 
+PIG-4908: JythonFunction refers to Oozie launcher script absolute path (rohini)
+
 PIG-4905: Input of empty dir does not produce empty output file in Tez (rohini)
 
 PIG-4576: Nightly test HCat_DDL_2 fails with TDE ON (nmaheshwari via daijy)

Modified: pig/branches/branch-0.16/src/org/apache/pig/PigServer.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.16/src/org/apache/pig/PigServer.java?rev=1745287&r1=1745286&r2=1745287&view=diff
==============================================================================
--- pig/branches/branch-0.16/src/org/apache/pig/PigServer.java (original)
+++ pig/branches/branch-0.16/src/org/apache/pig/PigServer.java Mon May 23 22:37:59 2016
@@ -612,7 +612,8 @@ public class PigServer {
             pigContext.scriptingUDFs.put(path, namespace);
         }
 
-        File f = FileLocalizer.fetchFile(pigContext.getProperties(), path).file;
+        FetchFileRet ret = FileLocalizer.fetchFile(pigContext.getProperties(), path);
+        File f = ret.file;
         if (!f.canRead()) {
             int errCode = 4002;
             String msg = "Can't read file: " + path;
@@ -621,9 +622,19 @@ public class PigServer {
         }
         String cwd = new File(".").getCanonicalPath();
         String filePath = f.getCanonicalPath();
-        //Use the relative path in the jar, if the path specified is relative
-        String nameInJar = filePath.equals(cwd + File.separator + path) ?
-                filePath.substring(cwd.length() + 1) : filePath;
+        String nameInJar = filePath;
+        // Use the relative path in the jar, if the path specified is relative
+        if (!ret.didFetch) {
+            if (!new File(path).isAbsolute()) {
+                // In case of Oozie, the localized files are in a different
+                // directory symlinked to the current directory. Canonical path will not
point to cwd.
+                nameInJar = path;
+            } else if (filePath.equals(cwd + File.separator + path)) {
+                // If user specified absolute path and it refers to cwd
+                nameInJar = filePath.substring(cwd.length() + 1);
+            }
+        }
+
         pigContext.addScriptFile(nameInJar, filePath);
         if(scriptingLang != null) {
             ScriptEngine se = ScriptEngine.getInstance(scriptingLang);



Mime
View raw message