pig-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@apache.org
Subject svn commit: r1796119 - in /pig/trunk: CHANGES.txt src/org/apache/pig/scripting/BoundScript.java test/org/apache/pig/test/TestScriptLanguage.java
Date Thu, 25 May 2017 00:16:43 GMT
Author: daijy
Date: Thu May 25 00:16:43 2017
New Revision: 1796119

URL: http://svn.apache.org/viewvc?rev=1796119&view=rev
Log:
PIG-5185: Job name show "DefaultJobName" when running a Python script

Modified:
    pig/trunk/CHANGES.txt
    pig/trunk/src/org/apache/pig/scripting/BoundScript.java
    pig/trunk/test/org/apache/pig/test/TestScriptLanguage.java

Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1796119&r1=1796118&r2=1796119&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Thu May 25 00:16:43 2017
@@ -97,6 +97,8 @@ OPTIMIZATIONS
  
 BUG FIXES
 
+PIG-5185: Job name show "DefaultJobName" when running a Python script (daijy)
+
 PIG-4748: DateTimeWritable forgets Chronology (szita)
 
 PIG-5229: TestPigTest.testSpecificOrderOutput and testSpecificOrderOutputForAlias failing
(knoguchi)

Modified: pig/trunk/src/org/apache/pig/scripting/BoundScript.java
URL: http://svn.apache.org/viewvc/pig/trunk/src/org/apache/pig/scripting/BoundScript.java?rev=1796119&r1=1796118&r2=1796119&view=diff
==============================================================================
--- pig/trunk/src/org/apache/pig/scripting/BoundScript.java (original)
+++ pig/trunk/src/org/apache/pig/scripting/BoundScript.java Thu May 25 00:16:43 2017
@@ -17,6 +17,7 @@
  */
 package org.apache.pig.scripting;
 
+import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.StringReader;
@@ -264,13 +265,18 @@ public class BoundScript {
         LOG.info("Query to run:\n" + query);
         List<PigProgressNotificationListener> listeners = ScriptState.get().getAllListeners();
         PigContext pc = scriptContext.getPigContext();
+        String scriptName = new File(ScriptState.get().getFileName()).getName();
         ScriptState scriptState = pc.getExecutionEngine().instantiateScriptState();
+        scriptState.setFileName(scriptName);
         ScriptState.start(scriptState);
         ScriptState.get().setScript(query);
         for (PigProgressNotificationListener listener : listeners) {
             ScriptState.get().registerListener(listener);
         }
         PigServer pigServer = new PigServer(scriptContext.getPigContext(), false);
+        if (!pigServer.getPigContext().getProperties().containsKey("jobName")) {
+            pigServer.setJobName(scriptName);
+        }
         GruntParser grunt = new GruntParser(new StringReader(query), pigServer);
         grunt.setInteractive(false);
         try {

Modified: pig/trunk/test/org/apache/pig/test/TestScriptLanguage.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/TestScriptLanguage.java?rev=1796119&r1=1796118&r2=1796119&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/TestScriptLanguage.java (original)
+++ pig/trunk/test/org/apache/pig/test/TestScriptLanguage.java Thu May 25 00:16:43 2017
@@ -31,6 +31,7 @@ import org.apache.hadoop.fs.Path;
 import org.apache.pig.PigRunner;
 import org.apache.pig.PigServer;
 import org.apache.pig.data.Tuple;
+import org.apache.pig.impl.PigContext;
 import org.apache.pig.scripting.ScriptEngine;
 import org.apache.pig.tools.pigstats.OutputStats;
 import org.apache.pig.tools.pigstats.PigStats;
@@ -248,6 +249,8 @@ public class TestScriptLanguage {
         assertEquals("simple_out", name);
         assertEquals(12, stats.getBytesWritten());
         assertEquals(3, stats.getRecordWritten());
+        String jobName = stats.getPigProperties().getProperty(PigContext.JOB_NAME);
+        assertTrue(jobName.contains("pigRunnerTest"));
     }
 
     @Test
@@ -260,6 +263,7 @@ public class TestScriptLanguage {
                 "Pig.fs(\"rmr simple_out2\")",
                 "output1 = 'simple_out'",
                 "output2 = 'simple_out2'",
+                "P.set(\"jobName\", \"myjob\")",
                 "P = Pig.compile(\"mypipeline\", \"\"\"a = load '$input';store a into '$output';\"\"\")",
                 "Q = P.bind([{'input':input, 'output':output1}, {'input':input, 'output':output2}])",
                 "stats = Q.run()"
@@ -284,6 +288,8 @@ public class TestScriptLanguage {
             assertEquals(1, stats.getNumberJobs());
             assertEquals(12, stats.getBytesWritten());
             assertEquals(3, stats.getRecordWritten());
+            String jobName = stats.getPigProperties().getProperty(PigContext.JOB_NAME);
+            assertTrue(jobName.contains("myjob"));
         }
     }
 



Mime
View raw message