This topic describes how to create a Phoenix5 result table in Realtime Compute for Apache Flink.
Notice
- This topic applies only to Realtime Compute for Apahce Flink in exclusive node.
- This topic applies only to Blink 3.4.0 and later.
- Only Phoenix 5.X is supported.
- Phoenix is an HBase SQL service deployed on an ApsaraDB for HBase instance. You can use Phoenix only after you activate this service in ApsaraDB for HBase instances.
DDL syntax
In Realtime Compute for Apache Flink, you can use Phoenix5 to store output data. The
following code shows an example:
create table US_POPULATION_SINK (
`STATE` varchar,
CITY varchar,
POPULATION BIGINT,
PRIMARY KEY (`STATE`, CITY)--- The primary key. This field is required.
) WITH (
type = 'PHOENIX5',
serverUrl = '<yourserverUrl>',
tableName = '<yourTableName>'
);
Parameters in the WITH clause
Parameter | Description | Required | Remarks |
---|---|---|---|
type | The type of the result table. | Yes | Set the value to PHOENIX5 .
|
serverUrl | The URL of the Phoenix5 query server.
|
Yes | You must enable the HBase SQL service in an ApsaraDB for HBase instance.
The value of the serverUrl parameter is in the http://host:port format. In the format:
|
tableName | The name of the Phoenix5 table. | Yes | The name of the Phoenix5 table is in the SchemaName.TableName format. In the format:
|
Sample code
The following sample code shows how to create a Phoenix5 result table in a Realtime
Compute for Apache Flink job.
create table `source` (
`id` varchar,
`name` varchar,
`age` varchar,
`birthday` varchar
) WITH (
type = 'random'
);
create table sink (
`id` varchar,
`name` varchar,
`age` varchar,
`birthday` varchar,
primary key (id)
) WITH (
type = 'PHOENIX5',
serverUrl = '<yourserverUrl>',
tableName = '<yourTableName>'
);
INSERT INTO sink
SELECT `id` ,`name` , `age` ,`birthday`
FROM `source`;