Return-Path: X-Original-To: apmail-pig-dev-archive@www.apache.org Delivered-To: apmail-pig-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 49F92D6F7 for ; Mon, 1 Oct 2012 17:19:10 +0000 (UTC) Received: (qmail 27884 invoked by uid 500); 1 Oct 2012 17:19:09 -0000 Delivered-To: apmail-pig-dev-archive@pig.apache.org Received: (qmail 27846 invoked by uid 500); 1 Oct 2012 17:19:09 -0000 Mailing-List: contact dev-help@pig.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@pig.apache.org Delivered-To: mailing list dev@pig.apache.org Received: (qmail 27837 invoked by uid 500); 1 Oct 2012 17:19:09 -0000 Delivered-To: apmail-hadoop-pig-dev@hadoop.apache.org Received: (qmail 27833 invoked by uid 99); 1 Oct 2012 17:19:09 -0000 Received: from arcas.apache.org (HELO arcas.apache.org) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 01 Oct 2012 17:19:09 +0000 Date: Tue, 2 Oct 2012 04:19:09 +1100 (NCT) From: "Dmitriy V. Ryaboy (JIRA)" To: pig-dev@hadoop.apache.org Message-ID: <1287672735.148690.1349111949865.JavaMail.jiratomcat@arcas> In-Reply-To: <1467696811.120593.1348551669073.JavaMail.jiratomcat@arcas> Subject: [jira] [Commented] (PIG-2931) $ signs in the replacement string make parameter substitution fail MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/PIG-2931?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13466961#comment-13466961 ] Dmitriy V. Ryaboy commented on PIG-2931: ---------------------------------------- The patch looks correct, but I can't help but wonder if anyone might be (ab)using the current behavior.. second opinion? > $ 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 > > Attachments: PIG-2931.patch > > > To reproduce the issue, use the following pig script: > {code:title=test.pig} > a = load 'data'; > b = filter by $FILTER; > {code} > and run the following command: > {code} > pig -x local -dryrun -f test.pig -p FILTER="(\$0 == 'a')" > {code} > This generates the following script: > {code:title=test.pig.substituted} > a = load 'data'; > b = filter by ($FILTER == 'a'); > {code} > However this should be: > {code} > a = load 'data'; > b = filter by ($0 == 'a'); > {code} > This is because Pig calls replaceFirst() with a replacement string that include a $ sign as follows: > {code} > "$FILTER".replaceFirst("\\$FILTER", "($0 == 'a')")); > {code} > 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: > {quote} > 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. > {quote} -- 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