×

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 诊断运算符

Apache Pig Diagnostic运算符Apache Pig Describe运算符Apache Pig Explain运算符Apache Pig illustrate运算符

Apache Pig 分组和连接

Apache Pig Group运算符Apache Pig Cogroup运算符Apache Pig Join运算符Apache Pig Cross运算符

Apache Pig 合并和拆分

Apache Pig Union运算符Apache Pig Split运算符

Apache Pig 过滤

Apache Pig Filter运算符Apache Pig Distinct运算符Apache Pig Foreach运算符

Apache Pig 排序

Apache Pig Order By运算符Apache Pig Limit运算符

Pig Latin 内置函数

Apache Pig Eval函数Apache Pig 加载和存储函数Apache Pig 包和元组函数Apache Pig 字符串函数Apache Pig 日期时间函数Apache Pig 数学函数

Apache Pig 其他执行模式

Apache Pig 用户定义函数Apache Pig 运行脚本

Apache Pig 有用的资源

Apache Pig 有用资源Apache Pig 讨论

Apache Pig UCFIRST()函数


Apache Pig 字符串函数Apache Pig 字符串函数


此函数接受一个字符串,将其第一个字母转换为大写,并返回结果。

函数

这是函数 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://localhost: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 字符串函数Apache Pig 字符串函数


分类导航

关注微信下载离线手册

bootwiki移动版 bootwiki
(群号:472910771)