pig-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Cheolsoo Park (JIRA)" <j...@apache.org>
Subject [jira] [Created] (PIG-2931) $ signs in the replacement string make parameter substitution fail
Date Tue, 25 Sep 2012 05:41:09 GMT
Cheolsoo Park created PIG-2931:

             Summary: $ signs in the replacement string make parameter substitution fail
                 Key: PIG-2931
                 URL: https://issues.apache.org/jira/browse/PIG-2931
             Project: Pig
          Issue Type: Bug
    Affects Versions: 0.10.0
            Reporter: Cheolsoo Park
            Assignee: Cheolsoo Park
             Fix For: 0.11

To reproduce the issue, use the following pig script:
a = load 'data';
b = filter by $FILTER;

and run the following command:
pig -x local -dryrun -f test.pig -p FILTER="(\$0 == 'a')"

This generates the following script:
a = load 'data';
b = filter by ($FILTER == 'a');

However this should be:
a = load 'data';
b = filter by ($0 == 'a');

This is because Pig calls replaceFirst() with a replacement string that include a $ sign as
"$FILTER".replaceFirst("\\$FILTER", "($0 == 'a')"));

To treat $ signs as literals in the replacement string, we must escape them. Please see the
[Java doc|http://docs.oracle.com/javase/6/docs/api/java/util/regex/Matcher.html#replaceFirst(java.lang.String)]
for Matcher class for explanation:
Note that backslashes (\) and dollar signs ($) in the replacement string may cause the results
to be different than if it were being treated as a literal replacement string. Dollar signs
may be treated as references to captured subsequences as described above, and backslashes
are used to escape literal characters in the replacement string.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

View raw message