Apache pig ElephantBird UDF:ORDER BY在json字段上生成语法错误

Apache pig ElephantBird UDF:ORDER BY在json字段上生成语法错误,apache-pig,elephantbird,Apache Pig,Elephantbird,我正在Hadoop 1.2.1上使用Pig 0.13.0。为了处理JSON文件,我还使用了4.5版的ElephantBird UDF。到目前为止,我对UDF没有太大的问题,但当我尝试按json字段排序别名时,pig编译器不太满意,我得到了以下错误: Failed to parse: <file find.pig, line 13, column 35> Syntax error, unexpected symbol at or near 'long' 我尝试删除(long),但没

我正在Hadoop 1.2.1上使用Pig 0.13.0。为了处理JSON文件,我还使用了4.5版的ElephantBird UDF。到目前为止,我对UDF没有太大的问题,但当我尝试按json字段排序别名时,pig编译器不太满意,我得到了以下错误:

Failed to parse: <file find.pig, line 13, column 35>  Syntax error, unexpected symbol at or near 'long'

我尝试删除(long),但没有效果。

您不能根据
JsonLoader
返回的映射中的值对记录进行排序,也不能按
排序方式进行类型转换。您可以做的是将
json#“imp”
的值投影到记录中的一个字段,然后按以下顺序排序:

records = FOREACH records GENERATE json, (long)json#'imp' AS imp:long;
sortedrecords = ORDER records BY imp desc;
records = FOREACH records GENERATE json, (long)json#'imp' AS imp:long;
sortedrecords = ORDER records BY imp desc;