我正在通过 Alan Gates编写 Programming Pig,但在介绍宏功能的脚本中出现错误:http: //ofps.oreilly.com/titles/9781449302641/advanced_pig_latin.html#macros
--macro.pig
-- Given daily input and a particular year, analyze how
-- stock prices changed on days dividends were paid out.
define dividend_analysis (daily, year, daily_symbol, daily_open, daily_close)
returns analyzed {
divs = load 'NYSE_dividends' as (exchange:chararray,
symbol:chararray, date:chararray, dividends:float);
divsthisyear = filter divs by date matches '$year-.*';
dailythisyear = filter $daily by date matches '$year-.*';
jnd = join divsthisyear by symbol, dailythisyear by $daily_symbol;
$analyzed = foreach jnd generate dailythisyear::$daily_symbol,
$daily_close - $daily_open;
};
daily = load 'NYSE_daily' as (exchange:chararray, symbol:chararray,
date:chararray, open:float, high:float, low:float, close:float,
volume:int, adj_close:float);
results = dividend_analysis(daily, '2009', 'symbol', 'open', 'close');
$
错误是 .中的双冒号后出现的意外符号dailythisyear::$daily_symbol
。
如果不替换该行,您将如何解决此问题:
$analyzed = foreach jnd generate divsthisyear::symbol, $daily_close - $daily_open;