Pig教程

Pig ROUND

Apache Pig ROUND 函数

Apache Pig ROUND 函数用于将提供的值向上舍入为整数。如果返回类型是浮点数,则该值四舍五入为整数。但是,如果返回类型为 double,则该值会四舍五入为 long。

语法

ROUND(expression)

ROUND 函数示例

在这个示例中,我们返回给定表达式的向上取整值。

执行步骤ROUND 函数

在本地计算机中创建一个文本文件并插入值。
$ nano mathround.txt
Apache Pig ROUND Function 检查插入到文本文件中的值。
$ cat mathround.txt
Apache Pig ROUND Function 上传特定目录下 HDFS 上的文本文件。
$ hdfs dfs-put mathround.txt /pigexample
开启猪 MapReduce 运行模式。
$ pig
加载包含数据的文件。
grunt> A = LOAD '/pigexample/mathround.txt' AS (a1:float) ;
现在,执行并验证数据。
grunt> DUMP A;
Apache Pig ROUND Function 让我们返回向上取整的值。
grunt> Result = FOREACH A GENERATE ROUND(a1);
grunt> DUMP Result;
Apache Pig ROUND Function
在这里,我们得到了想要的输出。
昵称: 邮箱:
Copyright © 2022 立地货 All Rights Reserved.
备案号:京ICP备14037608号-4