This topic describes the external table implementation and changes in Greenplum 7, and is geared towards existing users of Greenplum 6. Greenplum 7 converts an external table that you define with the CREATE EXTERNAL TABLE command into a foreign table, and internally operates on and represents the table using the foreign table data structures and catalog.
(See also Understanding the External Table to Foreign Table Mapping for detailed information about the external table to foreign table conversion, and its runtime implications.)
Parent topic: Accessing External Data with External Tables
If you used external tables in Greenplum 6, the underlying functionality has not changed in Greenplum 7. The following external table features and behaviors remain the same in VMware Greenplum 7:
file
, gpdist
, pxf
, and s3
).CREATE EXTERNAL TABLE
) and write to (CREATE WRITABLE EXTERNAL TABLE
) the same external data location.Note the following differences in the Greenplum 7 external table implementation compared to Greenplum 6:
Greenplum 7 uses foreign table data structures and catalogs to internally represent external tables. Use the pg_foreign_table system catalog table and the ftoptions
column to view the table definition.
A pg_tables
query no longer returns external tables in the query results.
The pg_class.relkind
of an external table is now f
(was previously r
).
The pg_exttable system catalog is now a view.
In addition to pg_exttable
, you can use the following query to list all of the foreign tables that were created using the CREATE [WRITABLE] EXTERNAL TABLE
command:
SELECT * FROM pg_foreign_table ft
JOIN pg_foreign_server fs ON ft.ftserver = fs.oid
WHERE srvname = 'gp_exttable_server';
Because an external table is internally represented as a foreign table:
gp_exttable_fdw
foreign-data wrapper.gp_exttable_server
foreign server.\det
psql
meta-command).External table-specific information displayed in psql
\dE+
output has changed; the relation Type
of an external table is now foreign table
. Example:
\dE
List of relations
Schema | Name | Type | Owner
--------+--------------+---------------+---------
public | ext_expenses | foreign table | gpadmin
External table-specific information displayed in psql
\d+ <external_table_name>
output has changed; it now displays in foreign table format. For this example CREATE EXTERNAL TABLE
call:
CREATE EXTERNAL TABLE ext_expenses ( name text, date date, amount float4, category text, desc1 varchar )
LOCATION ('gpfdist://etlhost-1:8081/*.txt', 'gpfdist://etlhost-2:8082/*.txt')
FORMAT 'TEXT' ( DELIMITER '|' NULL ' ' )
LOG ERRORS SEGMENT REJECT LIMIT 5;
The example \d+
output follows:
\d+ ext_expenses
Foreign table "public.ext_expenses"
Column | Type | Collation | Nullable | Default | FDW options | Storage | Stats target | Description
----------+-------------------+-----------+----------+---------+-------------+----------+--------------+-------------
name | text | | | | | extended | |
date | date | | | | | plain | |
amount | real | | | | | plain | |
category | text | | | | | extended | |
desc1 | character varying | | | | | extended | |
FDW options: (format 'text', delimiter '|', "null" ' ', escape E'\\', location_uris 'gpfdist://etlhost-1:8081/\*.txt|'gpfdist://etlhost-2:8082/\*.txt', execute_on 'ALL_SEGMENTS', reject_limit '5', reject_limit_type 'rows', log_errors 'enable', encoding 'UTF8', is_writable 'false')
The EXPLAIN
output for a query including an external table previously returned the text External Scan
. EXPLAIN
now returns Foreign Scan
in this scenario.
Additional factors to consider:
psql
\dE
or \d+
output.