PageRenderTime 47ms CodeModel.GetById 11ms RepoModel.GetById 0ms app.codeStats 1ms

/test/e2e/pig/tests/macro.conf

https://github.com/ftian/pig
Unknown | 598 lines | 544 code | 54 blank | 0 comment | 0 complexity | 4f765ccd14a0e6803b4e1bd7e141465c MD5 | raw file
Possible License(s): Apache-2.0
  1. ###############################################################################
  2. # Nightly tests for pig.
  3. #
  4. # Author: Alan F. Gates (gates@)
  5. # $Header:$
  6. #
  7. #use Yahoo::Miners::Test::PigSetup;
  8. #PigSetup::setup();
  9. #my $me = `whoami`;
  10. #chomp $me;
  11. $cfg = {
  12. 'driver' => 'Pig',
  13. 'groups' => [
  14. {
  15. 'name' => 'Macro_DefinitionAndInline',
  16. 'tests' => [
  17. {
  18. # simple macro, no args
  19. 'num' => 1,
  20. 'pig' => q#define simple_macro() returns void {
  21. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  22. b = foreach a generate age, name;
  23. store b into ':OUTPATH:';
  24. }
  25. simple_macro();#,
  26. 'verify_pig_script' => q#a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  27. b = foreach a generate age, name;
  28. store b into ':OUTPATH:';#,
  29. },{
  30. # input args, no return
  31. 'num' => 2,
  32. 'pig' => q#define simple_macro(loadfile) returns void {
  33. a = load '$loadfile' as (name, age, gpa);
  34. b = foreach a generate age, name;
  35. store b into ':OUTPATH:';
  36. }
  37. simple_macro(':INPATH:/singlefile/studenttab10k');#,
  38. 'verify_pig_script' => q#a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  39. b = foreach a generate age, name;
  40. store b into ':OUTPATH:';#,
  41. },{
  42. # input args, return value
  43. 'num' => 3,
  44. 'pig' => q#define simple_macro(loadfile) returns b {
  45. a = load '$loadfile' as (name, age, gpa);
  46. $b = foreach a generate age, name;
  47. }
  48. x = simple_macro(':INPATH:/singlefile/studenttab10k');
  49. store x into ':OUTPATH:';#,
  50. 'verify_pig_script' => q#a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  51. b = foreach a generate age, name;
  52. store b into ':OUTPATH:';#,
  53. },
  54. {
  55. # input args, filter on double and int, return value
  56. 'num' => 4,
  57. 'pig' => q#define simple_macro(in_relation, min_gpa, max_age) returns c {
  58. b = filter $in_relation by gpa >= $min_gpa and age <= $max_age;
  59. $c = foreach b generate age, name;
  60. }
  61. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  62. x = simple_macro(a, '3.0', '40');
  63. store x into ':OUTPATH:';#,
  64. 'verify_pig_script' => q#a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  65. b = filter a by gpa >= 3.0 and age <= 40;
  66. c = foreach b generate age, name;
  67. store c into ':OUTPATH:';#,
  68. },
  69. {
  70. #Definition multiple input, no output, multiple returns value
  71. #x = with multiple input, no output, multiple returns value
  72. #Query based on FilterEq from nightly.conf
  73. 'num' => 5,
  74. 'pig' => q\define test (in1, in2) returns r1, r2 {
  75. a = load '$in1' using PigStorage() as (name, age, gpa);
  76. $r1 = filter a by (age >= 50 or name > 'fred') and (gpa <= 3.0 or name >= 'bob');
  77. b = load '$in2' using PigStorage() as (name:chararray, age:int, registration, contributions:double);
  78. $r2 = filter b by name matches 'f.ed' and (chararray)registration matches 'd.m';
  79. }
  80. x1, x2 = test(':INPATH:/singlefile/studenttab10k', ':INPATH:/singlefile/votertab10k');
  81. store x1 into ':OUTPATH:.1' using PigStorage;
  82. store x2 into ':OUTPATH:.2' using PigStorage;\,
  83. 'verify_pig_script' => q\a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  84. a1 = filter a by (age >= 50 or name > 'fred') and (gpa <= 3.0 or name >= 'bob');
  85. store a1 into ':OUTPATH:.1' using PigStorage;
  86. b = load ':INPATH:/singlefile/votertab10k' using PigStorage() as (name:chararray, age:int, registration, contributions:double);
  87. b2 = filter b by name matches 'f.ed' and (chararray)registration matches 'd.m';
  88. store b2 into ':OUTPATH:.2' using PigStorage;\,
  89. 'floatpostprocess' => 1,
  90. 'delimiter' => ' ',
  91. },
  92. {
  93. # use positional parameters inside macro
  94. 'num' => 6,
  95. 'pig' => q#define simple_macro(in_relation, min_gpa, max_age) returns c {
  96. b = filter $in_relation by $2 >= $min_gpa and $1 <= $max_age;
  97. $c = foreach b generate age, name;
  98. }
  99. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  100. x = simple_macro(a, '3.0', '40');
  101. store x into ':OUTPATH:';#,
  102. 'verify_pig_script' => q#a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  103. b = filter a by gpa >= 3.0 and age <= 40;
  104. c = foreach b generate age, name;
  105. store c into ':OUTPATH:';#,
  106. },
  107. {
  108. # Test nested macros
  109. 'num' => 7,
  110. 'pig' => q\define sum_it(in, relation, scol) returns d {
  111. $d = foreach $in generate group, SUM($relation.$scol);
  112. }
  113. define group_it(in_relation, group_key, sum_col) returns c {
  114. b = group $in_relation by $group_key ;
  115. $c = sum_it(b, $in_relation, $sum_col);
  116. }
  117. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  118. x = group_it(a, 'name', 'age');
  119. store x into ':OUTPATH:';\,
  120. 'verify_pig_script' => q#a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  121. b = group a by name;
  122. c = foreach b generate group, SUM(a.age);
  123. store c into ':OUTPATH:';#,
  124. },
  125. {
  126. # single macro definition invoked multiple times
  127. 'num' => 8,
  128. 'pig' => q#define simple_macro(in_relation, min_gpa, max_age) returns c {
  129. b = filter $in_relation by gpa >= $min_gpa and age <= $max_age;
  130. $c = foreach b generate age, name;
  131. }
  132. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  133. x = simple_macro(a, '3.0', '40');
  134. store x into ':OUTPATH:.1';
  135. z = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  136. y = simple_macro(a, '2.0', '50');
  137. store y into ':OUTPATH:.2';#,
  138. 'verify_pig_script' => q#a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  139. b = filter a by gpa >= 3.0 and age <= 40;
  140. c = foreach b generate age, name;
  141. store c into ':OUTPATH:.1';
  142. d = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  143. e = filter d by gpa >= 2.0 and age <= 50;
  144. f = foreach e generate age, name;
  145. store f into ':OUTPATH:.2';#,
  146. },
  147. {
  148. # macro arg used as function arg
  149. 'num' => 9,
  150. 'pig' => q#define simple_macro(loadfile, sep) returns b {
  151. a = load '$loadfile' using PigStorage('$sep') as (name, age, gpa);
  152. $b = foreach a generate age, name;
  153. }
  154. x = simple_macro(':INPATH:/singlefile/studentcolon10k', ':');
  155. store x into ':OUTPATH:';#,
  156. 'verify_pig_script' => q#a = load ':INPATH:/singlefile/studentcolon10k' using PigStorage(':') as (name, age, gpa);
  157. b = foreach a generate age, name;
  158. store b into ':OUTPATH:';#,
  159. },
  160. {
  161. # Multiple returns via split in the data flow
  162. 'num' => 10,
  163. 'pig' => q\define test (in1) returns r1, r2 {
  164. a = load '$in1' using PigStorage() as (name, age, gpa);
  165. $r1 = filter a by (age >= 50 or name > 'fred') and (gpa <= 3.0 or name >= 'bob');
  166. $r2 = filter a by name > 'fred';
  167. }
  168. x1, x2 = test(':INPATH:/singlefile/studenttab10k');
  169. store x1 into ':OUTPATH:.1' using PigStorage;
  170. store x2 into ':OUTPATH:.2' using PigStorage;\,
  171. 'verify_pig_script' => q\a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  172. a1 = filter a by (age >= 50 or name > 'fred') and (gpa <= 3.0 or name >= 'bob');
  173. store a1 into ':OUTPATH:.1' using PigStorage;
  174. a2 = filter a by name > 'fred';
  175. store a2 into ':OUTPATH:.2' using PigStorage;\,
  176. 'floatpostprocess' => 1,
  177. 'delimiter' => ' ',
  178. },
  179. {
  180. # parameter substitution at the top level
  181. 'num' => 11,
  182. 'pig_params' => ['-p', qq(loadfile='singlefile/studenttab10k')],
  183. 'pig' => q#define simple_macro(in_relation, min_gpa, max_age) returns c {
  184. b = filter $in_relation by gpa >= $min_gpa and age <= $max_age;
  185. $c = foreach b generate age, name;
  186. }
  187. a = load ':INPATH:/$loadfile' as (name, age, gpa);
  188. x = simple_macro(a, '3.0', '40');
  189. store x into ':OUTPATH:';#,
  190. 'verify_pig_script' => q#a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  191. b = filter a by gpa >= 3.0 and age <= 40;
  192. c = foreach b generate age, name;
  193. store c into ':OUTPATH:';#,
  194. }
  195. ]
  196. },
  197. {
  198. 'name' => 'Macro_Scope',
  199. 'tests' => [
  200. {
  201. # re-use of variable in macro and global scope
  202. 'num' => 1,
  203. 'pig' => q#define simple_macro(in_relation, min_gpa, max_age) returns b {
  204. $b = filter $in_relation by $2 >= $min_gpa and $1 <= $max_age;
  205. }
  206. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  207. x = simple_macro(a, '3.0', '40');
  208. b = foreach x generate age, name;
  209. store b into ':OUTPATH:';#,
  210. 'verify_pig_script' => q#a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  211. b = filter a by gpa >= 3.0 and age <= 40;
  212. c = foreach b generate age, name;
  213. store c into ':OUTPATH:';#,
  214. },
  215. {
  216. #Definition where there is a name collision between parameters in parent/child macro
  217. 'num' => 2,
  218. 'pig' => q\define sum_it(in_relation, relation, sum_col) returns c {
  219. b = foreach $in_relation generate group, SUM($relation.$sum_col);
  220. $c = order b by $1;
  221. }
  222. define group_it(in_relation, group_key, sum_col) returns c {
  223. b = group $in_relation by $group_key ;
  224. $c = sum_it(b, $in_relation, $sum_col);
  225. }
  226. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  227. x = group_it(a, name, age);
  228. store x into ':OUTPATH:';\,
  229. 'verify_pig_script' => q#a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  230. b = group a by name;
  231. c = foreach b generate group, SUM(a.age);
  232. store c into ':OUTPATH:';#,
  233. },
  234. {
  235. #Definition where there is a name collision between macro and returns value in main pig script
  236. 'num' => 3,
  237. 'pig' => q#define simple_macro(in_relation, min_gpa, max_age) returns c {
  238. b = filter $in_relation by gpa >= $min_gpa and age <= $max_age;
  239. $c = foreach b generate age, name;
  240. }
  241. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  242. c = simple_macro(a, '3.0', '40');
  243. store c into ':OUTPATH:';#,
  244. 'verify_pig_script' => q#a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  245. b = filter a by gpa >= 3.0 and age <= 40;
  246. c = foreach b generate age, name;
  247. store c into ':OUTPATH:';#,
  248. }
  249. ]
  250. },
  251. {
  252. 'name' => 'Macro_Schema',
  253. 'tests' => [
  254. {
  255. # macro that does not change the schema
  256. 'num' => 1,
  257. 'pig' => q\define test(in) returns a {
  258. $a = filter $in by age > 30;
  259. }
  260. a = load ':INPATH:/singlefile/studenttab10k' as (name:chararray, age:int, gpa:double);
  261. b = test(a);
  262. describe b;\,
  263. 'rc' => 0,
  264. 'expected_out_regex'=> "b: {name: chararray,age: int,gpa: double}"
  265. },
  266. {
  267. # macro that does change the schema
  268. 'num' => 2,
  269. 'pig' => q\define test(in) returns a {
  270. $a = foreach $in generate name;
  271. }
  272. a = load ':INPATH:/singlefile/studenttab10k' as (name:chararray, age:int, gpa:double);
  273. b = test(a);
  274. describe b;\,
  275. 'rc' => 0,
  276. 'expected_out_regex'=> "b: {name: chararray}"
  277. }
  278. ]
  279. },
  280. {
  281. 'name' => 'Macro_Misc',
  282. 'tests' => [
  283. {
  284. #Comments in macro
  285. 'num' => 1,
  286. 'pig' => q#define simple_macro(in_relation, min_gpa, max_age) returns c {
  287. b = filter $in_relation by gpa >= $min_gpa and age <= $max_age;
  288. $c = foreach b generate age, name;
  289. -- add a comment
  290. }
  291. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  292. x = simple_macro(a, '3.0', '40');
  293. store x into ':OUTPATH:';#,
  294. 'verify_pig_script' => q#a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  295. b = filter a by gpa >= 3.0 and age <= 40;
  296. c = foreach b generate age, name;
  297. store c into ':OUTPATH:';#,
  298. },
  299. {
  300. #register
  301. 'num' => 2,
  302. 'pig' => q\define test (in) returns b {
  303. $b = foreach $in generate name, org.apache.pig.test.udf.evalfunc.Fred() as fred;
  304. }
  305. register :FUNCPATH:/testudf.jar;
  306. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  307. x = test(a);
  308. store x into ':OUTPATH:';\,
  309. 'verify_pig_script' => q#a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  310. register :FUNCPATH:/testudf.jar;
  311. b = foreach a generate name, org.apache.pig.test.udf.evalfunc.Fred() as fred;
  312. store b into ':OUTPATH:';#,
  313. },
  314. {
  315. #define for streaming combines with define for macros
  316. 'num' => 3,
  317. ,'pig' => q#define CMD `perl -ne 'print $_;'`;
  318. define test(in) returns B {
  319. $B = stream $in through CMD as (name, age, gpa);
  320. }
  321. A = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  322. x = test(A);
  323. store x into ':OUTPATH:';#,
  324. 'verify_pig_script' => q#A = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  325. define CMD `perl -ne 'print $_;'`;
  326. B = stream A through CMD as (name, age, gpa);
  327. store B into ':OUTPATH:';#,
  328. 'floatpostprocess' => 1,
  329. 'delimiter' => ' '
  330. },
  331. {
  332. #JIRA: PIG-2681
  333. 'num' => 4,
  334. ,'pig' => q\
  335. define test (in,out) returns b {
  336. a = load '$in' as (name, age, gpa);
  337. $b = foreach a generate name, org.apache.pig.test.udf.evalfunc.Fred() as fred;
  338. store $b into '$out';
  339. }
  340. register :FUNCPATH:/testudf.jar;
  341. x = test(':INPATH:/singlefile/studenttab10k',':OUTPATH:');
  342. \,
  343. }
  344. ]
  345. },
  346. {
  347. 'name' => 'Macro_Import',
  348. 'tests' => [
  349. {
  350. 'num' => 1,
  351. 'pig' => q#import ':SCRIPTHOMEPATH:/macro1.pig';
  352. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  353. x = simple_macro(a, '3.0', '40');
  354. store x into ':OUTPATH:';#,
  355. 'verify_pig_script' => q#a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  356. b = filter a by gpa >= 3.0 and age <= 40;
  357. c = foreach b generate age, name;
  358. store c into ':OUTPATH:';#,
  359. }
  360. ]
  361. },
  362. {
  363. 'name' => 'Macro_Error',
  364. 'tests' => [
  365. {
  366. # parameter names repeated
  367. 'num' => 1,
  368. 'ignore' => 'https://issues.apache.org/jira/browse/PIG-2247',
  369. 'pig' => q#define simple_macro(in_relation, min_gpa, min_gpa) returns c {
  370. b = filter $in_relation by gpa >= $min_gpa;
  371. $c = foreach b generate age, name;
  372. }
  373. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  374. x = simple_macro(a, '3.0', '40');
  375. store x into ':OUTPATH:';#,
  376. 'expected_err_regex' => "Multiple arguments min_gpa found"
  377. },
  378. {
  379. # undefined parameter in macro
  380. 'num' => 2,
  381. 'pig' => q#define simple_macro(in_relation, min_gpa) returns c {
  382. b = filter $in_relation by gpa >= $min_gpa and age <= $max_age;
  383. $c = foreach b generate age, name;
  384. }
  385. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  386. x = simple_macro(a, '3.0');
  387. store x into ':OUTPATH:';#,
  388. 'expected_err_regex' => "Macro inline failed for macro 'simple_macro'. Reason: Undefined parameter : max_age"
  389. },
  390. {
  391. # name collision between arg and return value
  392. 'num' => 3,
  393. 'pig' => q#define simple_macro(in_relation, min_gpa, c) returns c {
  394. b = filter $in_relation by gpa >= $min_gpa and age <= $c;
  395. $c = foreach b generate age, name;
  396. }
  397. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  398. x = simple_macro(a, '3.0', '40');
  399. store x into ':OUTPATH:';#,
  400. 'expected_err_regex' => "Multiple values found for c"
  401. },
  402. {
  403. # keyword as macro name
  404. 'num' => 4,
  405. 'pig' => q#define foreach(in_relation, min_gpa) returns c {
  406. b = filter $in_relation by gpa >= $min_gpa;
  407. $c = foreach b generate age, name;
  408. }
  409. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  410. x = simple_macro(a, '3.0', '40');
  411. store x into ':OUTPATH:';#,
  412. 'expected_err_regex' => "mismatched input 'foreach' expecting IDENTIFIER_L"
  413. },
  414. {
  415. # UDF as macro name
  416. 'num' => 5,
  417. 'ignore' => 'https://issues.apache.org/jira/browse/PIG-2248',
  418. 'pig' => q#define COUNT(in_relation, min_gpa) returns c {
  419. b = filter $in_relation by gpa >= $min_gpa;
  420. $c = foreach b generate age, name;
  421. }
  422. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  423. x = COUNT(a, '3.0');
  424. store x into ':OUTPATH:';#,
  425. 'expected_err_regex' => "macro name hides UDF COUNT"
  426. },
  427. {
  428. # redefine a macro
  429. 'num' => 6,
  430. 'pig' => q#define simple_macro(in_relation, min_gpa) returns c {
  431. b = filter $in_relation by gpa >= $min_gpa;
  432. $c = foreach b generate age, name;
  433. }
  434. define simple_macro(in, min_age) returns d {
  435. b = filter $in by age >= $min_age;
  436. $d = foreach b generate age, name;
  437. }
  438. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  439. x = simple_macro(a, '3.0', '40');
  440. store x into ':OUTPATH:';#,
  441. 'expected_err_regex' => "Duplicated macro name 'simple_macro'"
  442. },
  443. {
  444. # invoke non-existent macro
  445. 'num' => 7,
  446. 'pig' => q#
  447. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  448. x = nosuch_macro('a', '3.0', '40');
  449. store x into ':OUTPATH:';#,
  450. 'expected_err_regex' => "Cannot expand macro 'nosuch_macro'. Reason: Macro must be defined before expansion."
  451. },
  452. {
  453. # Specifies two returns, but only actually returns one
  454. 'num' => 8,
  455. 'pig' => q#define simple(in_relation, min_gpa) returns c,d {
  456. b = filter $in_relation by gpa >= $min_gpa;
  457. $c = foreach b generate age, name;
  458. }
  459. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  460. x, y = simple(a, '3.0');
  461. store x into ':OUTPATH:.1';
  462. store y into ':OUTPATH:.2';#,
  463. 'expected_err_regex' => "Invalid macro definition: . Reason: Macro 'simple' missing return alias: d"
  464. },
  465. {
  466. # syntax error in a macro, check for correct line number
  467. 'num' => 9,
  468. 'pig' => q#define simple(in_relation, min_gpa) returns c {
  469. b = fiter $in_relation by gpa >= $min_gpa;
  470. $c = foreach b generate age, name;
  471. }
  472. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  473. x = simple(a, '3.0');
  474. store x into ':OUTPATH:';#,
  475. 'expected_err_regex' => "line 2"
  476. },
  477. {
  478. # too many args passed to macro
  479. 'num' => 10,
  480. 'pig' => q#define simple_macro(in_relation, min_gpa) returns c {
  481. b = filter $in_relation by gpa >= $min_gpa;
  482. $c = foreach b generate age, name;
  483. }
  484. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  485. x = simple_macro(a, '3.0', '40');
  486. store x into ':OUTPATH:';#,
  487. 'expected_err_regex' => "Failed to expand macro 'simple_macro'. Reason: Expected number of parameters: 2 actual number of inputs: 3"
  488. },
  489. {
  490. # return two values, but script only accepts 1
  491. 'num' => 11,
  492. 'pig' => q#define simple(in_relation, min_gpa) returns c,d {
  493. b = filter $in_relation by gpa >= $min_gpa;
  494. $c = foreach b generate age, name;
  495. $d = foreach b generate name, age;
  496. }
  497. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  498. x = simple(a, '3.0');
  499. store x into ':OUTPATH:';#,
  500. 'expected_err_regex' => "Failed to expand macro 'simple'. Reason: Expected number of return aliases: 2 actual number of return values: 1"
  501. },
  502. {
  503. # return 1 value, but script expects 2
  504. 'num' => 12,
  505. 'pig' => q#define simple(in_relation, min_gpa) returns c {
  506. b = filter $in_relation by gpa >= $min_gpa;
  507. $c = foreach b generate age, name;
  508. }
  509. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  510. x, y = simple(a, '3.0');
  511. store x into ':OUTPATH:.1';
  512. store y into ':OUTPATH:.2';#,
  513. 'expected_err_regex' => "Failed to expand macro 'simple'. Reason: Expected number of return aliases: 1 actual number of return values: 2"
  514. }
  515. ]
  516. },
  517. {
  518. 'name' => 'Macro_Import_Error',
  519. 'tests' => [
  520. {
  521. # import non-existent file
  522. 'num' => 1,
  523. 'ignore' => 1, # different error message for different version of hadoop
  524. 'pig' => q#import 'nosuchfile';
  525. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  526. x = simple_macro('a', '3.0', '40');
  527. store x into ':OUTPATH:';#,
  528. 'expected_err_regex' => "Failed to import file 'nosuchfile'. Reason: Can't find the Specified file nosuchfile"
  529. },
  530. {
  531. # import a macro with a syntax error
  532. 'num' => 2,
  533. 'pig' => q#import ':SCRIPTHOMEPATH:/macro_bad1.pig';
  534. a = load ':INPATH:/singlefile/studenttab10k' as (name, age, gpa);
  535. x = simple_macro(a, '3.0', '40');
  536. store x into ':OUTPATH:';#,
  537. 'expected_err_regex' => "Invalid macro definition"
  538. }
  539. ]
  540. }
  541. ],
  542. },
  543. ;
  544. # import non-existent file, import script with error