Coding With Fun
Home Docker Django Node.js Articles Python pip guide FAQ Policy

Apache Pig string function


May 26, 2021 Apache Pig



There are the following String functions in Apache Pig.

S.N. Functions and descriptions
1 ENDSWITH(string, testAgainst)

Verify that a given string ends with a specific substring.

2 STARTSWITH(string, substring)

Accepts two string arguments and verifies that the first string starts with the second string.

3 SUBSTRING(string, startIndex, stopIndex)

Returns substrings from a given string.

4 EqualsIgnoreCase(string1, string2)

Compare two strings, ignoring case.

5 INDEXOF(string, ‘character’, startIndex)

Returns the first character that appears in the string, searching forward from the start index.

6 LAST_INDEX_OF(expression)

Returns the index of the last character that appears in the string, searching back from the start index.

7 LCFIRST(expression)

Converts the first character in the string to small case.

8 UCFIRST(expression)

Returns a string in which the first character is converted to capital.

9 UPPER(expression)

Returns a string converted to capital.

10 LOWER(expression)

Convert all characters in the string to small case.

11 REPLACE(string, ‘oldChar’, ‘newChar’);

Replace existing characters in the string with new characters.

12 STRSPLIT(string, regex, limit)

Split the string around a match for a given regular expression.

13 STRSPLITTOBAG(string, regex, limit)

Similar to the STRSPLIT() function, it splits the string by a given separator and returns the result to the package.

14 TRIM(expression)

Returns a copy of the string that deleted the front and rear spaces.

15 LTRIM(expression)

Returns a copy of the string that deleted the front-end space.

16 RTRIM(expression)

Returns a copy of the string for which the tail space was deleted.