You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by ro...@apache.org on 2016/05/31 19:58:48 UTC

svn commit: r1746336 - in /pig/branches/branch-0.16/src/org/apache/pig: PigServer.java scripting/ScriptEngine.java

Author: rohini
Date: Tue May 31 19:58:48 2016
New Revision: 1746336

URL: http://svn.apache.org/viewvc?rev=1746336&view=rev
Log:
Fix tests for PIG-4908

Modified:
    pig/branches/branch-0.16/src/org/apache/pig/PigServer.java
    pig/branches/branch-0.16/src/org/apache/pig/scripting/ScriptEngine.java

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=1746336&r1=1746335&r2=1746336&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 Tue May 31 19:58:48 2016
@@ -24,9 +24,7 @@ import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintStream;
-import java.io.PrintWriter;
 import java.io.StringReader;
-import java.io.StringWriter;
 import java.lang.reflect.Constructor;
 import java.lang.reflect.Method;
 import java.net.URL;
@@ -267,7 +265,7 @@ public class PigServer {
                 log.warn("ATS is disabled since"
                         + " yarn.timeline-service.enabled set to false");
             }
-            
+
         }
 
         // set hdfs caller context
@@ -678,7 +676,7 @@ public class PigServer {
         String nameInJar = filePath;
         // Use the relative path in the jar, if the path specified is relative
         if (!ret.didFetch) {
-            if (!new File(path).isAbsolute()) {
+            if (!new File(path).isAbsolute() && path.indexOf("." + File.separator) == -1) {
                 // 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;

Modified: pig/branches/branch-0.16/src/org/apache/pig/scripting/ScriptEngine.java
URL: http://svn.apache.org/viewvc/pig/branches/branch-0.16/src/org/apache/pig/scripting/ScriptEngine.java?rev=1746336&r1=1746335&r2=1746336&view=diff
==============================================================================
--- pig/branches/branch-0.16/src/org/apache/pig/scripting/ScriptEngine.java (original)
+++ pig/branches/branch-0.16/src/org/apache/pig/scripting/ScriptEngine.java Tue May 31 19:58:48 2016
@@ -38,6 +38,7 @@ import java.util.regex.Pattern;
 import org.apache.hadoop.util.Shell;
 import org.apache.pig.backend.executionengine.ExecException;
 import org.apache.pig.impl.PigContext;
+import org.apache.pig.impl.util.UDFContext;
 import org.apache.pig.tools.pigstats.PigStats;
 
 /**
@@ -127,7 +128,9 @@ public abstract class ScriptEngine {
     //protected static InputStream getScriptAsStream(String scriptPath) {
         InputStream is = null;
         File file = new File(scriptPath);
-        if (file.exists()) {
+        // In the frontend give preference to the local file.
+        // In the backend, try the jar first
+        if (UDFContext.getUDFContext().isFrontend() && file.exists()) {
             try {
                 is = new FileInputStream(file);
             } catch (FileNotFoundException e) {
@@ -156,7 +159,14 @@ public abstract class ScriptEngine {
                 }
             }
         }
-        
+        if (is == null && file.exists()) {
+            try {
+                is = new FileInputStream(file);
+            } catch (FileNotFoundException e) {
+                throw new IllegalStateException("could not find existing file "+scriptPath, e);
+            }
+        }
+
         // TODO: discuss if we want to add logic here to load a script from HDFS
 
         if (is == null) {