Question

How do I store my pig output into greenplum database? I had tried

STORE relation INTO 'table' USING org.apache.pig.piggybank.storage.DBStorage('DriverName', 'jdbc:postgresql://host/db', 'id', 'password', 'INSERT INTO table (cust_id,name,age,gender,city,nationality)');

he job fails in this. Is there any other way?

Was it helpful?

Solution

To expand the answer a bit:

REGISTER postgresql-9.2-1002.jdbc4.jar;
REGISTER piggybank.jar;
STORE relation INTO 'my_table' USING org.apache.pig.piggybank.storage.DBStorage( 
    'org.postgresql.Driver', 'jdbc:postgresql://host:port/db', 'user', 'password',
    'INSERT INTO my_table VALUES (?,?,?,?,?,?)');

Please note that the SQL table should exist prior to the load. This was verified to work with PostgreSQL 9.3

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top