ADB to ADB Connector configuration
To send data from the local (source) ADB cluster to the remote (target) ADB cluster via ADB to ADB Connector, you should first create the following objects on the local cluster side:
-
Server — encapsulates connection information that a foreign data wrapper uses to access an external data source.
-
User mapping — provides authentication to an external data source by mapping users.
-
Foreign table — a table in ADB that defines the remote data structure. A foreign table has no storage in ADB, but can be used in queries just like a normal table.
To see how to use the listed objects to send data, refer to ADB to ADB Connector usage examples.
IMPORTANT
|
Server
To create a server, use the CREATE SERVER
command. The basic command syntax is listed below:
CREATE SERVER <server_name> [ TYPE '<server_type>' ] [ VERSION '<server_version>' ]
FOREIGN DATA WRAPPER <fdw_name>
[ OPTIONS ( [ <option> '<value>' [, ... ]] ) ]
where:
-
<server_name>
— a server name in ADB. Should be unique within the current ADB database. -
<server_type>
— an optional server type. -
<server_version>
— an optional server version. -
<fdw_name>
— a foreign data wrapper name. You should use theadb_fdw
foreign data wrapper, which is automatically created after the connector installation (see step 4 in ADB to ADB Connector installation). -
<option>
— server options that define the connection details. The options that are available for ADB to ADB Connector are listed in the Server options table. Note that these options (excepthost
,port
,num_segments
) can be defined both at the server level and at the foreign table level. Options marked as required should be specified at least in one definition (server or table). Table-level options take precedence. -
<value>
— option values.
NOTE
|
Name | Type | Description | Default | Required |
---|---|---|---|---|
host |
TEXT |
An IP address or name of the remote ADB master host. Validation rules for the |
— |
Yes |
port |
TEXT |
A port number that is used to connect to the remote ADB master host. Validation rules for the |
— |
Yes |
dbname |
TEXT |
A name of the target database on the remote ADB cluster side |
— |
Yes |
mpp_execute |
TEXT |
The distribution strategy for query execution. The only possible value is The |
master |
No |
use_remote_estimate |
BOOL |
Indicates whether to use an external cluster for planning a query. Based on the flag, query costs are estimated and the number of executors on segments is calculated. If Possible values: |
false |
No |
num_segments |
INT |
The number of executors on segments that are used to process data received from the parallel cursor endpoints. If the number of local cluster segments is smaller than the number of endpoints, some local cluster executors will get more endpoints (which will cause processing skew). Positive integers >= |
— |
No |
fdw_startup_cost |
DOUBLE |
The cost estimate for obtaining the first tuple from the data source. Positive double values are allowed |
100.0 |
No |
fdw_tuple_cost |
DOUBLE |
The cost estimate for obtaining one tuple from the data source. Positive double values are allowed |
0.01 |
No |
fetch_size |
INT |
The number of rows in the data batch read by the connector. Positive integers >= |
100 |
No |
updatable |
BOOL |
Indicates the ability to change tables on the remote ADB cluster side via the Possible values: |
true |
No |
User mapping
To create a user mapping, use the CREATE USER MAPPING
command. The basic command syntax is listed below:
CREATE USER MAPPING FOR { <username> | USER | CURRENT_USER | PUBLIC }
SERVER <server_name>
[ OPTIONS ( <option> '<value>' [, ... ] ) ]
where:
-
<username>
— a user name in ADB. The following constants are allowed:-
USER
orCURRENT_USER
— the current user who established the ADB connection. -
PUBLIC
— all present and future ADB users.
-
-
<server_name>
— a server name. -
<option>
— user mapping options, which typically include a user name and a password to connect to an external data source. The options that are available for ADB to ADB Connector are listed in the User mapping options table. -
<value>
— option values.
NOTE
|
Name | Type | Description | Default | Required |
---|---|---|---|---|
user |
TEXT |
A user name in the remote ADB database |
— |
Yes |
password |
TEXT |
A user password in the remote ADB database |
— |
Yes |
Foreign table
To create a foreign table, use the CREATE FOREIGN TABLE
command. The basic command syntax is listed below:
CREATE FOREIGN TABLE [ IF NOT EXISTS ] <table_name> ( [
<column_name> <data_type> [ COLLATE <collation> ] [ <column_constraint> [ ... ] ]
[, ... ]
] )
SERVER <server_name>
[ OPTIONS ( <option> '<value>' [, ... ] ) ]
where:
-
<table_name>
— a foreign table name in ADB. -
<column_name>
— a column name. -
<data_type>
— a column data type. -
<collation>
— a column collation. -
<column_constraint>
— a constraint defined at the column level. The name<constraint_name>
is given optionally. The syntax:[ CONSTRAINT <constraint_name> ] { NOT NULL | NULL | DEFAULT <default_expr> }
Possible constraints:
-
NOT NULL
— specifies that the column is not allowed to contain null values. -
NULL
— specifies that the column is allowed to contain null values. It is the default behavior (unlessNOT NULL
is specified). -
DEFAULT
— sets the default column value equal to<default_expr>
.
-
-
<server_name>
— a server name. -
<option>
— foreign table options. For ADB to ADB Connector, all options defined at the server level (excepthost
,port
,num_segments
) can be overwritten at the foreign table level (partially or fully). When you specify an option for a server and a foreign table at the same time, the table level takes precedence. Additionally, at the foreign table level, three more options are available (see Foreign table options below). -
<value>
— option values.
NOTE
|
Name | Type | Description | Default | Required |
---|---|---|---|---|
schema_name |
TEXT |
A schema name that is used to access a table on the remote ADB cluster side. If the parameter is undefined, a schema of the |
— |
No |
table_name |
TEXT |
A target table name on the remote ADB cluster side |
— |
Yes |
column_name |
TEXT |
A column name of the target table |
— |
No |