Example 2 - Write Custom-Formatted Data from Greenplum Database to HDFS

Example 2 - Write Custom-Formatted Data from Greenplum Database to HDFS

The sample code makes the following assumptions.

  • The data in Greenplum Database format is located on the Hadoop Distributed File System on /demo/data/writeFromGPDB_42 on port 8081.
  • This code writes the data to /demo/data/MRTest2 on port 8081.
  1. Run a SQL command to create the writable table.
    =# CREATE WRITABLE EXTERNAL TABLE demodata 
       LOCATION ('gphdfs://hdfshost-1:8081/demo/data/MRTest2') 
       FORMAT 'custom' (formatter='gphdfs_export');
    
  2. Author and run code for a MapReduce job. Use the same import statements shown in Example 1 - Read Custom-Formatted Data from HDFS.
Note: Omit the port number when using the gpmr-1.0-gnet-1.0.0.1 connector.