pig-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Prashant Kommireddi (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (PIG-3182) Pig currently lacks function to trim the whitespace only on the left hand side
Date Thu, 14 Feb 2013 09:26:12 GMT

    [ https://issues.apache.org/jira/browse/PIG-3182?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13578256#comment-13578256
] 

Prashant Kommireddi commented on PIG-3182:
------------------------------------------

Thanks a lot for the patch Padma. A few comments:

1. Can you please name the UDF LTRIM? All caps will keep it in-sync with the builtin UDF TRIM.
2. Package name should be "org.apache.pig.piggybank.evaluation.string"
3. Pig uses space and not tabs for indentation. Could you please correct the same?
4. You could implement outputSchema(Schema) to specify what the expected output type of the
UDF is, in this case a chararray.
{code}
    @Override
    public Schema outputSchema(Schema input) {
        return new Schema(new Schema.FieldSchema(null, DataType.CHARARRAY));
    }
{code}
5. UDF does not have a description for the class. You could probably move exec(Tuple) method's
description to be the Class/UDF description. 
6. Do you think the function "Lefttrim(String col)" could be made private? Also, you could
avoid the code in there with a simpler regex may be?
7. You might just want to warn and return null in case of an ExecException. Throwing an IOException
would cause the script to fail on a few bad records. Here is an example from the UDF TRIM().
{code}
catch (ExecException e) {
            warn("Error reading input: " + e.getMessage(), PigWarning.UDF_WARNING_1);
            return null;
        }
{code}

Thanks again for working on this.
                
> Pig currently lacks function to trim the whitespace only on the left hand side
> ------------------------------------------------------------------------------
>
>                 Key: PIG-3182
>                 URL: https://issues.apache.org/jira/browse/PIG-3182
>             Project: Pig
>          Issue Type: New Feature
>    Affects Versions: 0.1.0
>            Reporter: Padma Ravindran
>            Priority: Minor
>              Labels: patch
>         Attachments: LTrim.java.patch
>
>
> Pig currently lacks function to trim the whitespace only on the left hand side of a given
word
> ltrim(' lorem ') = 'lorem '

--
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

Mime
View raw message