You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by ga...@apache.org on 2013/01/23 20:13:21 UTC
svn commit: r1437635 - in /pig/trunk: CHANGES.txt
test/org/apache/pig/pigunit/pig/GruntParser.java
test/org/apache/pig/test/pigunit/pig/TestGruntParser.java
Author: gates
Date: Wed Jan 23 19:13:21 2013
New Revision: 1437635
URL: http://svn.apache.org/viewvc?rev=1437635&view=rev
Log:
PIG-3086 Allow A Prefix To Be Added To URIs In PigUnit Tests
Modified:
pig/trunk/CHANGES.txt
pig/trunk/test/org/apache/pig/pigunit/pig/GruntParser.java
pig/trunk/test/org/apache/pig/test/pigunit/pig/TestGruntParser.java
Modified: pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/pig/trunk/CHANGES.txt?rev=1437635&r1=1437634&r2=1437635&view=diff
==============================================================================
--- pig/trunk/CHANGES.txt (original)
+++ pig/trunk/CHANGES.txt Wed Jan 23 19:13:21 2013
@@ -24,6 +24,8 @@ INCOMPATIBLE CHANGES
IMPROVEMENTS
+PIG-3086: Allow A Prefix To Be Added To URIs In PigUnit Tests (nwhite via gates)
+
PIG-3091: Make schema, header and stats file configurable in JsonMetadata (pkommireddi via jcoveney)
PIG-3078: Make a UDF that, given a string, returns just the columns prefixed by that string (jcoveney)
Modified: pig/trunk/test/org/apache/pig/pigunit/pig/GruntParser.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/pigunit/pig/GruntParser.java?rev=1437635&r1=1437634&r2=1437635&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/pigunit/pig/GruntParser.java (original)
+++ pig/trunk/test/org/apache/pig/pigunit/pig/GruntParser.java Wed Jan 23 19:13:21 2013
@@ -69,6 +69,17 @@ public class GruntParser extends org.apa
* @return The same query, or a modified query, or blank.
*/
public String override(String query) {
+ // a path to be prepended to all the file names in the script
+ String fsRoot = System.getProperty("pigunit.filesystem.prefix");
+ if(fsRoot != null) {
+ query = Pattern.compile("(LOAD\\s+'(([^:/?#]+)://)?)", Pattern.CASE_INSENSITIVE).
+ matcher(query).
+ replaceFirst("$1" + fsRoot);
+ query = Pattern.compile("(STORE\\s+([^']+)\\s+INTO\\s+'(([^:/?#]+)://)?)", Pattern.CASE_INSENSITIVE).
+ matcher(query).
+ replaceFirst("$1" + fsRoot);
+ }
+
Map<String, String> metaData = new HashMap<String, String>();
for (Entry<String, String> alias : aliasOverride.entrySet()) {
Modified: pig/trunk/test/org/apache/pig/test/pigunit/pig/TestGruntParser.java
URL: http://svn.apache.org/viewvc/pig/trunk/test/org/apache/pig/test/pigunit/pig/TestGruntParser.java?rev=1437635&r1=1437634&r2=1437635&view=diff
==============================================================================
--- pig/trunk/test/org/apache/pig/test/pigunit/pig/TestGruntParser.java (original)
+++ pig/trunk/test/org/apache/pig/test/pigunit/pig/TestGruntParser.java Wed Jan 23 19:13:21 2013
@@ -69,4 +69,21 @@ public class TestGruntParser {
parser.override("STORE output INTO '/path'");
Assert.assertEquals("output", override.get("LAST_STORE_ALIAS"));
}
+
+ @Test
+ public void testChangeRootDirectory() throws Exception {
+ Assert.assertEquals(
+ "A = LOAD 'input.txt';",
+ parser.override("A = LOAD 'input.txt';"));
+
+ System.setProperty("pigunit.filesystem.prefix", "/tmp/pigunit/");
+ Assert.assertEquals(
+ "A = LOAD '/tmp/pigunit/input.txt';",
+ parser.override("A = LOAD 'input.txt';"));
+
+ System.clearProperty("pigunit.filesystem.prefix");
+ Assert.assertEquals(
+ "A = LOAD 'input.txt';",
+ parser.override("A = LOAD 'input.txt';"));
+ }
}