pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From roh...@apache.org
Subject svn commit: r1746335 - in /pig/trunk/src/org/apache/pig: PigServer.java scripting/ScriptEngine.java
Date Tue, 31 May 2016 19:58:21 GMT
Author: rohini
Date: Tue May 31 19:58:21 2016
New Revision: 1746335

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

Modified:
    pig/trunk/src/org/apache/pig/PigServer.java
    pig/trunk/src/org/apache/pig/scripting/ScriptEngine.java

Modified: pig/trunk/src/org/apache/pig/PigServer.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/PigServer.java?rev=1746335&r1=1746334&r2=1746335&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/PigServer.java (original)
+++ pig/trunk/src/org/apache/pig/PigServer.java Tue May 31 19:58:21 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/trunk/src/org/apache/pig/scripting/ScriptEngine.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/scripting/ScriptEngine.java?rev=1746335&r1=1746334&r2=1746335&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/scripting/ScriptEngine.java (original)
+++ pig/trunk/src/org/apache/pig/scripting/ScriptEngine.java Tue May 31 19:58:21 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) {



Mime
View raw message