You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pig.apache.org by ha...@apache.org on 2010/02/04 03:36:57 UTC
svn commit: r906326 - in /hadoop/pig/trunk: CHANGES.txt
src/org/apache/pig/tools/grunt/GruntParser.java
src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj
test/org/apache/pig/test/TestGrunt.java
Author: hashutosh
Date: Thu Feb 4 02:36:57 2010
New Revision: 906326
URL: http://svn.apache.org/viewvc?rev=906326&view=rev
Log:
PIG-1190: Handling of quoted strings in pig-latin/grunt commands
Modified:
hadoop/pig/trunk/CHANGES.txt
hadoop/pig/trunk/src/org/apache/pig/tools/grunt/GruntParser.java
hadoop/pig/trunk/src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj
hadoop/pig/trunk/test/org/apache/pig/test/TestGrunt.java
Modified: hadoop/pig/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/CHANGES.txt?rev=906326&r1=906325&r2=906326&view=diff
==============================================================================
--- hadoop/pig/trunk/CHANGES.txt (original)
+++ hadoop/pig/trunk/CHANGES.txt Thu Feb 4 02:36:57 2010
@@ -24,6 +24,8 @@
IMPROVEMENTS
+PIG-1190: Handling of quoted strings in pig-latin/grunt commands (ashutoshc)
+
PIG-1214: Pig 0.6 Docs fixes (chandec via olgan)
PIG-977: exit status does not account for JOB_STATUS.TERMINATED (ashutoshc)
Modified: hadoop/pig/trunk/src/org/apache/pig/tools/grunt/GruntParser.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/tools/grunt/GruntParser.java?rev=906326&r1=906325&r2=906326&view=diff
==============================================================================
--- hadoop/pig/trunk/src/org/apache/pig/tools/grunt/GruntParser.java (original)
+++ hadoop/pig/trunk/src/org/apache/pig/tools/grunt/GruntParser.java Thu Feb 4 02:36:57 2010
@@ -419,9 +419,9 @@
protected void processSet(String key, String value) throws IOException, ParseException {
if (key.equals("debug"))
{
- if (value.equals("on") || value.equals("'on'"))
+ if (value.equals("on"))
mPigServer.debugOn();
- else if (value.equals("off") || value.equals("'off'"))
+ else if (value.equals("off"))
mPigServer.debugOff();
else
throw new ParseException("Invalid value " + value + " provided for " + key);
Modified: hadoop/pig/trunk/src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj?rev=906326&r1=906325&r2=906326&view=diff
==============================================================================
--- hadoop/pig/trunk/src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj (original)
+++ hadoop/pig/trunk/src/org/apache/pig/tools/pigscript/parser/PigScriptParser.jj Thu Feb 4 02:36:57 2010
@@ -473,7 +473,7 @@
|
<REGISTER>
t1 = GetPath()
- {processRegister(t1.image);}
+ {processRegister(unquote(t1.image));}
|
Script()
|
@@ -496,7 +496,7 @@
(
t1 = GetKey()
t2 = GetValue()
- {processSet(t1.image, t2.image);}
+ {processSet(t1.image, unquote(t2.image));}
)
|
<EOF>
Modified: hadoop/pig/trunk/test/org/apache/pig/test/TestGrunt.java
URL: http://svn.apache.org/viewvc/hadoop/pig/trunk/test/org/apache/pig/test/TestGrunt.java?rev=906326&r1=906325&r2=906326&view=diff
==============================================================================
--- hadoop/pig/trunk/test/org/apache/pig/test/TestGrunt.java (original)
+++ hadoop/pig/trunk/test/org/apache/pig/test/TestGrunt.java Thu Feb 4 02:36:57 2010
@@ -758,5 +758,51 @@
Grunt grunt = new Grunt(new BufferedReader(reader), context);
grunt.exec();
+ assertEquals("high", context.getProperties().getProperty(PigContext.JOB_PRIORITY));
+ }
+
+ public void testSetWithQuotes() throws Throwable {
+ PigServer server = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
+ PigContext context = server.getPigContext();
+
+ String strCmd = "set job.priority 'high'\n";
+
+ ByteArrayInputStream cmd = new ByteArrayInputStream(strCmd.getBytes());
+ InputStreamReader reader = new InputStreamReader(cmd);
+
+ Grunt grunt = new Grunt(new BufferedReader(reader), context);
+
+ grunt.exec();
+ assertEquals("high", context.getProperties().getProperty(PigContext.JOB_PRIORITY));
+ }
+
+ public void testRegisterWithQuotes() throws Throwable {
+ PigServer server = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
+ PigContext context = server.getPigContext();
+
+ String strCmd = "register 'pig.jar'\n";
+
+ ByteArrayInputStream cmd = new ByteArrayInputStream(strCmd.getBytes());
+ InputStreamReader reader = new InputStreamReader(cmd);
+
+ Grunt grunt = new Grunt(new BufferedReader(reader), context);
+
+ grunt.exec();
+ assertTrue(context.extraJars.contains(ClassLoader.getSystemResource("pig.jar")));
+ }
+
+ public void testRegisterWithoutQuotes() throws Throwable {
+ PigServer server = new PigServer(ExecType.MAPREDUCE, cluster.getProperties());
+ PigContext context = server.getPigContext();
+
+ String strCmd = "register pig.jar\n";
+
+ ByteArrayInputStream cmd = new ByteArrayInputStream(strCmd.getBytes());
+ InputStreamReader reader = new InputStreamReader(cmd);
+
+ Grunt grunt = new Grunt(new BufferedReader(reader), context);
+
+ grunt.exec();
+ assertTrue(context.extraJars.contains(ClassLoader.getSystemResource("pig.jar")));
}
}