GreenPlum creates external representations

Source: Internet
Author: User
Tags table definition
Example1-SingleGreenplumfileserver (gpfdist) tables (|) asthecolumndelimiter. CREATEE

Example 1-Single Greenplum file server (gpfdist) instance on multiple NIC machine Creates a readable external table named ext_expenses using the gpfdist protocol. the files are formatted with a pipe (|) as the column delimiter. CREATE E

Example 1-Single Greenplum file server (gpfdist) instance on multiple NIC machineCreates a readable external table named ext_expenses using the gpfdist protocol. The files are formatted with a pipe (|) as the column delimiter.
Create external table ext_expenses (name text, date, amount float4, category text, desc1 text) LOCATION ('gpfdist: // etlhost-1: 8081/* ', 'gpfdist: // etlhost-2: 8081/* ') FORMAT 'text' (DELIMITER' | ');

Example 2-Multiple Greenplum file server (gpfdist) instancesCreates a readable external table named ext_expenses using the gpfdist protocol from all files with the txt extension. The files are formatted with a pipe (|) as the column delimiter and an empty space as null.
Create external table ext_expenses (name text, date, amount float4, category text, desc1 text) LOCATION ('gpfdist: // etlhost-1: 8081 /*. txt ', 'gpfdist: // etlhost-2: 8082 /*. txt ') FORMAT 'text' (DELIMITER' | 'null '');

Example 3-Multiple secure Greenplum file server (gpfdists) instancesCreates a readable external table named ext_expenses using the gpfdists protocol from all files with the txt extension. The files are formatted with a pipe (|) as the column delimiter and an empty space as null.
First, run gpfdist with the -- ssl option. Then, execute the following command.
Create external table ext_expenses (name text, date, amount float4, category text, desc1 text) LOCATION ('gpfdists: // etlhost-1: 8081 /*. txt ', 'gpfdists: // etlhost-2: 8082 /*. txt ') FORMAT 'text' (DELIMITER' | 'null '');

Example 4-Single Greenplum file server (gpfdist) instance with error loggingCreates a readable external table named ext_expenses using the gpfdist protocol from all files with the txt extension. The files are formatted with a pipe (|) as the column delimiter and an empty space as null.
The external table is accessed in single row error isolation mode. an error table (err_customer) is specified. any data formatting errors that are found in the input data will be discarded to err_customer, along with a description of the error. err_customer can later be queried in order to see the nature of errors and reload the rejected data after fixing the issues. if the count of badly formatted data rows on any specific segment is greater than five (specified as the segment reject limit value ), the entire external table operation will be aborted and no rows will be processed.
Create external table ext_expenses (name text, date, amount float4, category text, desc1 text) LOCATION ('gpfdist: // etlhost-1: 8081 /*. txt ', 'gpfdist: // etlhost-2: 8082 /*. txt ') FORMAT 'text' (DELIMITER' | 'null' ') log errors into err_customer segment reject limit 5;
Create the same readable external table definition as abve, but with CSV formatted files:
Create external table ext_expenses (name text, date, amount float4, category text, desc1 text) LOCATION ('gpfdist: // etlhost-1: 8081 /*. txt ', 'gpfdist: // etlhost-2: 8082 /*. txt ') FORMAT 'csv' (DELIMITER', ') log errors into err_customer segment reject limit 5;

Example 5-TEXT Format on a Hadoop Distributed File Server (HDFS)Creates a readable external table named ext_expenses using the gphdfs protocol. The files are formatted with a pipe (|) as the column delimiter.
Create external table ext_expenses (name text, date, amount float4, category text, desc1 text) LOCATION ('gphdfs: // hdfshost-1: 8081/data/filename.txt ') FORMAT 'text' (DELIMITER '| ');
Note: Only one data path is permitted with gphdfs. For examples of reading and writing custom formatted data on a Hadoop Distributed File System.

Example 6-Multiple file protocols in CSV format with header rowsCreates a readable external table named ext_expenses using the file protocol. The wildcard specifications are not the same for all the files. The files are formatted in CSV format and have a header row.
Create external table ext_expenses (name text, date, amount float4, category text, desc1 text) LOCATION ('file: // filehost: 5432/data/international /*', 'File: // filehost: 5432/data/regional/* 'file: // filehost: 5432/data/supplement /*. csv ') FORMAT 'csv' (HEADER );

Example 7-Readable Web External Table with ScriptCreate a readable web external table that executes a script once per segment host:
Create external web table log_output (linenum int, message text) EXECUTE '/var/load_scripts/get_log_data.sh' on hostformat 'text' (DELIMITER '| ');

Example 8-Writable External Table that Writes to a FileCreate a writable external table named sales_out that uses gpfdist to write output data to a file named sales. out. the files are formatted with a pipe (|) as the column delimiter and an empty space as null.
Create writable external table sales_out (LIKE sales) LOCATION ('gpfdist: // etl1: 8081/sales. out ') FORMAT 'text' (DELIMITER' | 'null' ') distributed by (txn_id );

Example 9-Writable External Web Table with ScriptCreate a writable external web table that pipes output data stored ed by the segments to an executable script named to_adreport_etl.sh:
Create writable external web table campaign_out (LIKE campaign) EXECUTE '/var/unload_scripts/to_adreport_etl.sh 'format 'text' (DELIMITER' | ');
Use the writable external table defined above to unload selected data:
Insert into campaign_out SELECT * FROM campaign WHERE customer_id = 123;

Example 10-Readable and Writable External Tables with XML TransformationsGreenplum Database now can read and write XML data to and from external tables with gpfdist. for information on setting up an XML transform, see "Transforming XML Data" on page 178. the following code reads XML data into a table.
Create readable external table prices_readable (LIKE prices) LOCATION ('gpfdist: // 127.0.0.1: 8080/data/prices. xml # transform = prices_input ') FORMAT 'text' (delimiter' | ') log errors into prices_errortable segment reject limit 10;
The following code creates a writable external table that transforms the data in the Greenplum Database to XML.
Create writable external table prices_readable (LIKE prices) LOCATION ('gpfdist: // 127.0.0.1: 8080/data/prices. xml # transform = prices_input ') FORMAT 'text' (delimiter' | ');

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.