- Apache Pig 教程
- Apache Pig - 首頁
- Apache Pig 簡介
- Apache Pig - 概述
- Apache Pig - 架構
- Apache Pig 環境
- Apache Pig - 安裝
- Apache Pig - 執行
- Apache Pig - Grunt Shell
- Pig Latin
- Pig Latin - 基礎
- 載入與儲存運算子
- Apache Pig - 讀取資料
- Apache Pig - 儲存資料
- 診斷運算子
- Apache Pig - 診斷運算子
- Apache Pig - Describe 運算子
- Apache Pig - Explain 運算子
- Apache Pig - Illustrate 運算子
- Pig Latin 內建函式
- Apache Pig - 評估函式
- 載入與儲存函式
- Apache Pig - Bag 和 Tuple 函式
- Apache Pig - 字串函式
- Apache Pig - 日期時間函式
- Apache Pig - 數學函式
- Apache Pig 有用資源
- Apache Pig - 快速指南
- Apache Pig - 有用資源
- Apache Pig - 討論
Apache Pig - LOWER() 函式
此函式用於將字串中的所有字元轉換為小寫。
語法
以下是LOWER()函式的語法。
grunt> LOWER(expression)
示例
假設在HDFS目錄/pig_data/中有一個名為emp.txt的檔案,如下所示。此檔案包含員工詳細資訊,例如id、姓名、年齡和城市。
emp.txt
001,Robin,22,newyork 002,BOB,23,Kolkata 003,Maya,23,Tokyo 004,Sara,25,London 005,David,23,Bhuwaneshwar 006,Maggy,22,Chennai 007,Robert,22,newyork 008,Syam,23,Kolkata 009,Mary,25,Tokyo 010,Saran,25,London 011,Stacy,25,Bhuwaneshwar 012,Kelly,22,Chennai
並且,我們已使用名為emp_data的關係將此檔案載入到Pig中,如下所示。
grunt> emp_data = LOAD 'hdfs://:9000/pig_data/emp.txt' USING PigStorage(',')
as (id:int, name:chararray, age:int, city:chararray);
以下是LOWER()函式的示例。在此示例中,我們將所有員工的姓名轉換為小寫。
grunt> lower_data = FOREACH emp_data GENERATE (id,name), LOWER(name);
上述語句將所有員工的姓名轉換為小寫並返回結果。
語句的結果將儲存在名為lower_data的關係中。使用 Dump 運算子驗證關係lower_data的內容。
grunt> Dump lower_data; ((1,Robin),robin) ((2,BOB),bob) ((3,Maya),maya) ((4,Sara),sara) ((5,David),david) ((6,Maggy),maggy) ((7,Robert),robert) ((8,Syam),syam) ((9,Mary),mary) ((10,Saran),saran) ((11,Stacy),stacy) ((12,Kelly),kelly)
apache_pig_string_functions.htm
廣告