This topic provides the DDL syntax that is used to create a Phoenix5 result table, describes the parameters in the WITH clause, and provides sample code.

Notice Phoenix5 result tables support only the INSERT statement and do not support the UPDATE or DELETE statement.

What is Phoenix5?

The HBase SQL service is based on Phoenix 5.x and provides SQL support for HBase 2.x. You can use the Phoenix thin client to connect to ApsaraDB for HBase. The SQL service is integrated with Server Load Balancer (SLB). Round robin distribution is used to evenly distribute requests among query servers. The Phoenix thin client supports programming languages, such as Python and Go.

Prerequisites

The HBase SQL service is activated.

Limits

Only Flink that uses Ververica Runtime (VVR) 2.0.0 or later supports Phoenix5 connectors.

DDL syntax

create table phoenix5_sink (
  `STATE` varchar,
  CITY varchar,
  POPULATION BIGINT,
  PRIMARY KEY (`STATE`, CITY)
) WITH (
  'connector' = 'phoenix5',
  'serverUrl' = '<yourserverUrl>',
  'tableName' = '<yourTableName>',
  'batchsize' = '25'
);

Parameters in the WITH clause

Parameter Description Required Remarks
connector The type of the result table. Yes Default value: phoenix 5.
serverUrl The URL of the Phoenix5 query server.
  • If Phoenix5 is created in a cluster, the value of this parameter is the URL of SLB.
  • If Phoenix5 is created on a single server, the value of this parameter is the URL of the server.
Yes You must enable the HBase SQL service in an ApsaraDB for HBase instance.
tableName The name of the Phoenix5 table. Yes N/A.
batchSize The number of data records that are written at a time. No Default value: 20.

Sample code

The following sample code shows how to create a Phoenix5 result table in a Flink job.
CREATE TEMPORARY table datagen_source (
  `id` varchar,
  `name` varchar,
  `age` varchar,
  `birthday` varchar 
) WITH (
  'connector' = 'datagen'
);

CREATE TEMPORARY table phoenix5_sink (
  `id` varchar,
  `name` varchar,
  `age` varchar,
  `birthday` varchar,
  primary key (id)
) WITH (
  'connector' = 'phoenix5',
  'serverurl' = '<yourserverUrl>',
  'tablename' = '<yourTableName>',
  'batchsize' = '25'
);

INSERT INTO phoenix5_sink
  SELECT  `id` ,`name` , `age` ,`birthday` 
FROM datagen_source;