Apache Pig - String Functions


Advertisements

We have the following String functions in Apache Pig.

S.N. Functions & Description
1 ENDSWITH(string, testAgainst)

To verify whether a given string ends with a particular substring.

2 STARTSWITH(string, substring)

Accepts two string parameters and verifies whether the first string starts with the second.

3 SUBSTRING(string, startIndex, stopIndex)

Returns a substring from a given string.

4 EqualsIgnoreCase(string1, string2)

To compare two stings ignoring the case.

5 INDEXOF(string, ‘character’, startIndex)

Returns the first occurrence of a character in a string, searching forward from a start index.

6 LAST_INDEX_OF(expression)

Returns the index of the last occurrence of a character in a string, searching backward from a start index.

7 LCFIRST(expression)

Converts the first character in a string to lower case.

8 UCFIRST(expression)

Returns a string with the first character converted to upper case.

9 UPPER(expression)

UPPER(expression) Returns a string converted to upper case.

10 LOWER(expression)

Converts all characters in a string to lower case.

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

To replace existing characters in a string with new characters.

12 STRSPLIT(string, regex, limit)

To split a string around matches of a given regular expression.

13 STRSPLITTOBAG(string, regex, limit)

Similar to the STRSPLIT() function, it splits the string by given delimiter and returns the result in a bag.

14 TRIM(expression)

Returns a copy of a string with leading and trailing whitespaces removed.

15 LTRIM(expression)

Returns a copy of a string with leading whitespaces removed.

16 RTRIM(expression)

Returns a copy of a string with trailing whitespaces removed.

Useful Video Courses


Video

Apache Spark Online Training

46 Lectures 3.5 hours

Arnab Chakraborty

Video

Apache Spark with Scala - Hands On with Big Data

23 Lectures 1.5 hours

Mukund Kumar Mishra

Video

Learn Apache Cordova using Visual Studio 2015 & Command line

16 Lectures 1 hours

Nilay Mehta

Video

Delta Lake with Apache Spark using Scala

52 Lectures 1.5 hours

Bigdata Engineer

Video

Apache Zeppelin - Big Data Visualization Tool

14 Lectures 1 hours

Bigdata Engineer

Video

Olympic Games Analytics Project in Apache Spark for Beginner

23 Lectures 1 hours

Bigdata Engineer

Advertisements