Pig
  1. Pig
  2. PIG-2879

Pig current releases lack a UDF startsWith.This UDF tests if a given string starts with the specified prefix.

    Details

    • Type: New Feature New Feature
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 0.10.0
    • Fix Version/s: 0.11
    • Component/s: piggybank
    • Labels:
    • Release Note:
      Pig now includes a STARTSWITH built-in UDF that checks for presence of a given prefix in a chararray.

      Description

      Pig current releases lack a UDF startsWith.This UDF tests if a given string starts with the specified prefix.This UDF returns true if the character sequence represented by the string argument given as a prefix is a prefix of the character sequence represented by the given string; false otherwise.Also true will be returned if the given prefix is an empty string or is equal to the given String.

      1. PIG-2879-1.patch
        4 kB
        Eli Reisman
      2. PIG-2879-2.patch
        8 kB
        Eli Reisman
      3. PIG-2879-3.patch
        3 kB
        Eli Reisman
      4. PIG-2879-4.patch
        3 kB
        Eli Reisman

        Issue Links

          Activity

          Hide
          Eli Reisman added a comment -

          This is what I think is the STARTSWITH UDF and a related unit test. Hope this is in the right format, etc.?

          Show
          Eli Reisman added a comment - This is what I think is the STARTSWITH UDF and a related unit test. Hope this is in the right format, etc.?
          Hide
          Eli Reisman added a comment -

          First attempt at the patch.

          Show
          Eli Reisman added a comment - First attempt at the patch.
          Hide
          Eli Reisman added a comment -

          Moved test code into TestStringUDFs and added Schema mapping for string datatypes to STARTSWITH UDF.

          Thanks for the great hackday!

          Show
          Eli Reisman added a comment - Moved test code into TestStringUDFs and added Schema mapping for string datatypes to STARTSWITH UDF. Thanks for the great hackday!
          Hide
          Eli Reisman added a comment -

          My IDE was messing with existing whitespace, reposting patch...sorry!

          Show
          Eli Reisman added a comment - My IDE was messing with existing whitespace, reposting patch...sorry!
          Hide
          Gianmarco De Francisci Morales added a comment -

          Hi Eli, thanks for the patch.

          A few comments.
          To properly handle the exception you should use warn.

              warn("Error message " + e.getMessage(), PigWarning.UDF_WARNING_1);
          

          You should also override outputSchema.

              @Override
              public Schema outputSchema(Schema input) {
                  return new Schema(new Schema.FieldSchema(null, DataType.BOOLEAN));
              }
          

          You should check for null also "argument" and "testAgaints".

          All the rest looks good.
          I will commit once these issues have been addressed.

          Show
          Gianmarco De Francisci Morales added a comment - Hi Eli, thanks for the patch. A few comments. To properly handle the exception you should use warn. warn( "Error message " + e.getMessage(), PigWarning.UDF_WARNING_1); You should also override outputSchema. @Override public Schema outputSchema(Schema input) { return new Schema( new Schema.FieldSchema( null , DataType.BOOLEAN)); } You should check for null also "argument" and "testAgaints". All the rest looks good. I will commit once these issues have been addressed.
          Hide
          Eli Reisman added a comment -

          Is this on the right track? Thanks again

          Show
          Eli Reisman added a comment - Is this on the right track? Thanks again
          Hide
          Gianmarco De Francisci Morales added a comment -

          +1
          Committed to trunk.
          Thanks Eli!

          Show
          Gianmarco De Francisci Morales added a comment - +1 Committed to trunk. Thanks Eli!
          Hide
          Anuroopa George added a comment -

          Thanks Eli

          Show
          Anuroopa George added a comment - Thanks Eli
          Hide
          Eli Reisman added a comment -

          thanks again!

          Show
          Eli Reisman added a comment - thanks again!

            People

            • Assignee:
              Eli Reisman
              Reporter:
              Anuroopa George
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development