- 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 - UCFIRST()
此函式接受一個字串,將其首字母轉換為大寫,並返回結果。
語法
以下是函式UCFIRST()的語法。
grunt> UCFIRST(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);
以下是UCFIRST()函式的示例。在此示例中,我們嘗試將員工所屬城市的名稱的首字母轉換為大寫。
grunt> ucfirst_data = FOREACH emp_data GENERATE (id,city), UCFIRST(city);
語句的結果將儲存在名為ucfirst_data的關係中。使用 Dump 運算子驗證關係ucfirst_data的內容,如下所示。
在我們的示例中,“newyork”城市名稱的首字母是小寫。應用 UCFIRST() 函式後,它變為“NEWYORK”。
grunt>Dump ucfirst_data; ((1,newyork),Newyork) ((2,Kolkata),Kolkata) ((3,Tokyo),Tokyo) ((4,London),London) ((5,Bhuwaneshwar),Bhuwaneshwar) ((6,Chennai),Chennai) ((7,newyork),Newyork) ((8,Kolkata),Kolkata) ((9,Tokyo),Tokyo) ((10,London),London) ((11,Bhuwaneshwar),Bhuwaneshwar) ((12,Chennai),Chennai)
apache_pig_string_functions.htm
廣告