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
What's the Same?
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:
- Greenplum 7 fully supports the external table SQL command syntax of Greenplum 6.
- Greenplum 7 fully supports external table access to remote data sources via all existing protocols (
file
,gpdist
,pxf
, ands3
). - You must create separate tables to read from (
CREATE EXTERNAL TABLE
) and write to (CREATE WRITABLE EXTERNAL TABLE
) the same external data location. - The pg_exttable system catalog (now a view) provides the same information.
What Has Changed?
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 nowf
(was previouslyr
).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 theCREATE [WRITABLE] EXTERNAL TABLE
command:Because an external table is internally represented as a foreign table:
- Every external table is associated with the
gp_exttable_fdw
foreign-data wrapper. - Every external table is associated with the
gp_exttable_server
foreign server. - Certain command output and error, detail, and notice messages about external tables refer to the table as a foreign table.
- External tables are included in the foreign table catalogs, for example pg_foreign_table.
- External tables are included when you list or examine foreign tables (for example, the
\det
psql
meta-command).
- Every external table is associated with the
External table-specific information displayed in
psql
\dE+
output has changed; the relationType
of an external table is nowforeign table
. Example:External table-specific information displayed in
psql
\d+ <external_table_name>
output has changed; it now displays in foreign table format. For this exampleCREATE EXTERNAL TABLE
call:The example
\d+
output follows:The
EXPLAIN
output for a query including an external table previously returned the textExternal Scan
.EXPLAIN
now returnsForeign Scan
in this scenario.
Additional Considerations
Additional factors to consider:
- Even though an external table is internally represented as a foreign table, you cannot both read from and write to the same external table.
- You must change any scripts that you wrote that depend on external table DDL or
psql
\dE
or\d+
output. - Greenplum 7 dumps and restores the DDL of external tables using foreign table syntax.
Content feedback and comments