0
votes

I am trying to execute the following command in pig

7369,SMITH,CLERK,800.00,null,20
7499,ALLEN,SALESMAN,1600.00,300.00,30

Script

emp_bag = LOAD '/home/training/dvs/emp.csv' using PigStorage(',') AS (eno:int, ename:chararray, job:chararray, sal:int, comm:int, deptno:int);

And getting the below error

bash: syntax error near unexpected token `('

Please help to resolve this.

2
Post sample data from emp.csv.The syntax looks correctVK_217
Here is sample data- 7369,SMITH,CLERK,800.00,null,20Priyanka
I don't see any issue with the sample snippet shared.Murali Rao

2 Answers

1
votes

Are you running your pig command on bash ?

If yes, please start the pig console first and then run it.

Just type pig and enter.

0
votes

Most likely the issue is the data of type float.You need to change the datatype for 4th and 5th field to float from int. Also if null is a string then you will have to handle it using chararray field and replace 'null' with ''.

emp_bag = LOAD '/home/training/dvs/emp.csv' using PigStorage(',') AS (eno:int, ename:chararray, job:chararray, sal:float, comm:float, deptno:int);

Alternatively,you can check whether the issue is with the datatype by not specifying the schema in which case the default datatype will be bytearray.

emp_bag = LOAD '/home/training/dvs/emp.csv' using PigStorage(',')