我有以下Pig Latin代码段(为了便于阅读,在多行格式化):
data = LOAD 'some_file'
as (bid:chararray,
pvs:long,
paid:long,
social:long,
search:long,
direct:long,
morning:long,
afternoon:long,
evening:long,
night:long,
platform:long);
user_dedication = FOREACH (GROUP data BY pvs)
GENERATE
(group==1L?'one offs':
(group<=10L:'between 1 and 10':
(group<=100L?'between 10 and 100':'more than 100'))) as bin,
COUNT(pvs) as bids;
导致以下错误:
2014-05-22 19:10:22,418 [main] ERROR org.apache.pig.tools.grunt.Grunt -
ERROR 1200: <line 3, column 70>
Syntax error, unexpected symbol at or near 'group'
我可以&#34;修复&#34;通过改写以上内容:
tmp1 = FOREACH (GROUP data BY pvs)
GENERATE
group as pvs,
(group==1L?'one offs':'else') as bin,
COUNT(bid_segments) as bids;
tmp2 = FOREACH tmp1 GENERATE
pvs, (bin=='else'?( pvs<=10L?'between 1 and 10':'else' ):bin) as bin, bids;
user_dedication = FOREACH tmp2 GENERATE
pvs, (bin=='else'?( pvs<=100L?'between 10 and 100':'more than 100' ):bin) as bin, bids;
对我来说这看起来像个直接的错误。为什么我不能编写嵌套的双条件语句?