Greenplum external table single column of data

Had to work with some data that was one column of data in a fixed width format. Solution was to create an external table that was one column then use substr function to pull out the data.

External table:

CREATE EXTERNAL TABLE trmtmp_ext_table (
    col1 text
)
LOCATION (
        'gpfdist://host-1:port/path/trmtmp.out',
        'gpfdist://host-2:port/path/trmtmp.out',
        'gpfdist://host-3:port/path/trmtmp.out'
)
FORMAT 'text'
LOG ERRORS INTO trmtmp_err_ext_table SEGMENT REJECT LIMIT 5 ROWS;

View of the external table:

DROP VIEW trmtmp_view_ext_tbl;
CREATE VIEW trmtmp_view_ext_tbl AS (
SELECT
    substr(col1,1,2) AS col1,
    substr(col1,3,5) AS col2
FROM  
    trmtmp_ext_table
);

Extrapolate from there.

Comments

Popular posts from this blog

Database, schema, and table sizes in Greenplum

Greenplum update with multiple tables

Show running queries on Postgresql/Greenplum