doc-exports/docs/dli/sqlreference/dli_08_0384.html
Su, Xiaomeng 76a5b1ee83 dli_sqlreference_20240227
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com>
Co-authored-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
Co-committed-by: Su, Xiaomeng <suxiaomeng1@huawei.com>
2024-03-27 22:02:33 +00:00

268 lines
30 KiB
HTML

<a name="dli_08_0384"></a><a name="dli_08_0384"></a>
<h1 class="topictitle1">HBase Source Table</h1>
<div id="body8662426"><div class="section" id="dli_08_0384__en-us_topic_0000001309855869_section670892955410"><h4 class="sectiontitle">Function</h4><p id="dli_08_0384__en-us_topic_0000001309855869_p835216342549">Create a source stream to obtain data from HBase as input for jobs. HBase is a column-oriented distributed cloud storage system that features enhanced reliability, excellent performance, and elastic scalability. It applies to the storage of massive amounts of data and distributed computing. You can use HBase to build a storage system capable of storing TB- or even PB-level data. With HBase, you can filter and analyze data with ease and get responses in milliseconds, rapidly mining data value. DLI can read data from HBase for filtering, analysis, and data dumping.</p>
</div>
<div class="section" id="dli_08_0384__en-us_topic_0000001309855869_section11337165518558"><h4 class="sectiontitle">Prerequisites</h4><ul id="dli_08_0384__en-us_topic_0000001309855869_ul13179123403513"><li id="dli_08_0384__en-us_topic_0000001309855869_li1817918345355">An enhanced datasource connection has been created for DLI to connect to HBase, so that jobs can run on the dedicated queue of DLI and you can set the security group rules as required.
</li><li id="dli_08_0384__en-us_topic_0000001309855869_li1396003318327">If MRS HBase is used, IP addresses of all hosts in the MRS cluster have been added to host information of the enhanced datasource connection.<p id="dli_08_0384__en-us_topic_0000001309855869_p320475513329"><a name="dli_08_0384__en-us_topic_0000001309855869_li1396003318327"></a><a name="en-us_topic_0000001309855869_li1396003318327"></a>.</p>
<p id="dli_08_0384__en-us_topic_0000001309855869_p1290940152113">For details, see section "Modifying the Host Information" in the <em id="dli_08_0384__en-us_topic_0000001309855869_i127901043142014">Data Lake Insight User Guide</em>.</p>
</li></ul>
</div>
<div class="section" id="dli_08_0384__en-us_topic_0000001309855869_section16453173518321"><h4 class="sectiontitle">Precautions</h4><ul id="dli_08_0384__en-us_topic_0000001309855869_ul1529319563109"><li id="dli_08_0384__en-us_topic_0000001309855869_li58061142227">When creating a Flink OpenSource SQL job, you need to set <strong id="dli_08_0384__en-us_topic_0000001309855869_b11602135102011">Flink Version</strong> to <strong id="dli_08_0384__en-us_topic_0000001309855869_b13603851182011">1.12</strong> on the <strong id="dli_08_0384__en-us_topic_0000001309855869_b206031851142014">Running Parameters</strong> tab of the job editing page, select <strong id="dli_08_0384__en-us_topic_0000001309855869_b460355114209">Save Job Log</strong>, and set the OBS bucket for saving job logs.</li><li id="dli_08_0384__en-us_topic_0000001309855869_li719716113525">The column families in created HBase source table must be declared as the ROW type, the field names map the column family names, and the nested field names map the column qualifier names.<p id="dli_08_0384__en-us_topic_0000001309855869_p186789115529"><a name="dli_08_0384__en-us_topic_0000001309855869_li719716113525"></a><a name="en-us_topic_0000001309855869_li719716113525"></a>There is no need to declare all the families and qualifiers in the schema. Users can declare what is used in the query. Except the ROW type fields, the single atomic type field (for example, STRING or BIGINT) will be recognized as the HBase rowkey. The rowkey field can be an arbitrary name, but should be quoted using backticks if it is a reserved keyword.</p>
</li></ul>
</div>
<div class="section" id="dli_08_0384__en-us_topic_0000001309855869_section1198425395616"><h4 class="sectiontitle">Syntax</h4><pre class="screen" id="dli_08_0384__en-us_topic_0000001309855869_screen344510125715">create table hbaseSource (
attr_name attr_type
(',' attr_name attr_type)*
(',' watermark for rowtime_column_name as watermark-strategy_expression)
','PRIMARY KEY (attr_name, ...) NOT ENFORCED)
)
with (
'connector' = 'hbase-2.2',
'table-name' = '',
'zookeeper.quorum' = ''
);</pre>
</div>
<div class="section" id="dli_08_0384__en-us_topic_0000001309855869_section11860133905818"><h4 class="sectiontitle">Parameters</h4>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_08_0384__en-us_topic_0000001309855869_table1792955835818" frame="border" border="1" rules="all"><caption><b>Table 1 </b>Parameter description</caption><thead align="left"><tr id="dli_08_0384__en-us_topic_0000001309855869_row39301258105810"><th align="left" class="cellrowborder" valign="top" width="19.509999999999998%" id="mcps1.3.5.2.2.6.1.1"><p id="dli_08_0384__en-us_topic_0000001309855869_p693025820588">Parameter</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="8.37%" id="mcps1.3.5.2.2.6.1.2"><p id="dli_08_0384__en-us_topic_0000001309855869_p16930958155814">Mandatory</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="10.35%" id="mcps1.3.5.2.2.6.1.3"><p id="dli_08_0384__en-us_topic_0000001309855869_p18115113719717">Default Value</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="8.870000000000001%" id="mcps1.3.5.2.2.6.1.4"><p id="dli_08_0384__en-us_topic_0000001309855869_p15948144216715">Data Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="52.900000000000006%" id="mcps1.3.5.2.2.6.1.5"><p id="dli_08_0384__en-us_topic_0000001309855869_p493035816580">Description</p>
</th>
</tr>
</thead>
<tbody><tr id="dli_08_0384__en-us_topic_0000001309855869_row129308583583"><td class="cellrowborder" valign="top" width="19.509999999999998%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_0384__en-us_topic_0000001309855869_p393065810586">connector</p>
</td>
<td class="cellrowborder" valign="top" width="8.37%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_0384__en-us_topic_0000001309855869_p12930175813580">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="10.35%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_0384__en-us_topic_0000001309855869_p1511511373714">None</p>
</td>
<td class="cellrowborder" valign="top" width="8.870000000000001%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_0384__en-us_topic_0000001309855869_p129491421378">String</p>
</td>
<td class="cellrowborder" valign="top" width="52.900000000000006%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_0384__en-us_topic_0000001309855869_p181621120191118">Connector to be used. Set this parameter to <strong id="dli_08_0384__en-us_topic_0000001309855869_b650510156322">hbase-2.2</strong>.</p>
</td>
</tr>
<tr id="dli_08_0384__en-us_topic_0000001309855869_row0930115825816"><td class="cellrowborder" valign="top" width="19.509999999999998%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_0384__en-us_topic_0000001309855869_p199301358135815">table-name</p>
</td>
<td class="cellrowborder" valign="top" width="8.37%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_0384__en-us_topic_0000001309855869_p193085835811">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="10.35%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_0384__en-us_topic_0000001309855869_p101151637974">None</p>
</td>
<td class="cellrowborder" valign="top" width="8.870000000000001%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_0384__en-us_topic_0000001309855869_p79495424713">String</p>
</td>
<td class="cellrowborder" valign="top" width="52.900000000000006%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_0384__en-us_topic_0000001309855869_p119302058165815">Name of the HBase table to connect.</p>
</td>
</tr>
<tr id="dli_08_0384__en-us_topic_0000001309855869_row109301158135816"><td class="cellrowborder" valign="top" width="19.509999999999998%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_0384__en-us_topic_0000001309855869_p093015817586">zookeeper.quorum</p>
</td>
<td class="cellrowborder" valign="top" width="8.37%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_0384__en-us_topic_0000001309855869_p89301358155814">Yes</p>
</td>
<td class="cellrowborder" valign="top" width="10.35%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_0384__en-us_topic_0000001309855869_p101157370719">None</p>
</td>
<td class="cellrowborder" valign="top" width="8.870000000000001%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_0384__en-us_topic_0000001309855869_p17949742671">String</p>
</td>
<td class="cellrowborder" valign="top" width="52.900000000000006%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_0384__en-us_topic_0000001309855869_p636743484420">HBase ZooKeeper quorum, in the format of "ZookeeperAddress:ZookeeperPort".</p>
<p id="dli_08_0384__en-us_topic_0000001309855869_p9871653181210">The following uses an MRS HBase cluster as an example to describe how to obtain the IP address and port number of ZooKeeper used by this parameter:</p>
<ul id="dli_08_0384__en-us_topic_0000001309855869_ul571954114435"><li id="dli_08_0384__en-us_topic_0000001309855869_li177201341154318">On MRS Manager, choose <strong id="dli_08_0384__en-us_topic_0000001309855869_b135534139349">Cluster</strong> and click the name of the desired cluster. Choose <strong id="dli_08_0384__en-us_topic_0000001309855869_b177935993413">Services</strong> &gt; <strong id="dli_08_0384__en-us_topic_0000001309855869_b7133155123517">ZooKeeper</strong> &gt; <strong id="dli_08_0384__en-us_topic_0000001309855869_b86881567358">Instance</strong>, and obtain the IP address of the ZooKeeper instance.</li><li id="dli_08_0384__en-us_topic_0000001309855869_li1433443194310">On MRS Manager, choose <strong id="dli_08_0384__en-us_topic_0000001309855869_b156594913613">Cluster</strong> and click the name of the desired cluster. Choose <strong id="dli_08_0384__en-us_topic_0000001309855869_b86544983616">Services</strong> &gt; <strong id="dli_08_0384__en-us_topic_0000001309855869_b16651649133612">ZooKeeper</strong> &gt; <strong id="dli_08_0384__en-us_topic_0000001309855869_b26554913367">Configurations</strong> &gt; <strong id="dli_08_0384__en-us_topic_0000001309855869_b127826546376">All Configurations</strong>, search for the <strong id="dli_08_0384__en-us_topic_0000001309855869_b72028152380">clientPort</strong> parameter, and obtain its value, that is, the ZooKeeper port number.</li></ul>
</td>
</tr>
<tr id="dli_08_0384__en-us_topic_0000001309855869_row2930165875815"><td class="cellrowborder" valign="top" width="19.509999999999998%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_0384__en-us_topic_0000001309855869_p1193025875815">zookeeper.znode.parent</p>
</td>
<td class="cellrowborder" valign="top" width="8.37%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_0384__en-us_topic_0000001309855869_p3930205865811">No</p>
</td>
<td class="cellrowborder" valign="top" width="10.35%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_0384__en-us_topic_0000001309855869_p1911618371278">/hbase</p>
</td>
<td class="cellrowborder" valign="top" width="8.870000000000001%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_0384__en-us_topic_0000001309855869_p1694912422710">String</p>
</td>
<td class="cellrowborder" valign="top" width="52.900000000000006%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_0384__en-us_topic_0000001309855869_p17930195815586">Root directory in ZooKeeper. The default value is <strong id="dli_08_0384__en-us_topic_0000001309855869_b3316426045153">/hbase</strong>.</p>
</td>
</tr>
<tr id="dli_08_0384__en-us_topic_0000001309855869_row74325584913"><td class="cellrowborder" valign="top" width="19.509999999999998%" headers="mcps1.3.5.2.2.6.1.1 "><p id="dli_08_0384__en-us_topic_0000001309855869_p898164614212">null-string-literal</p>
</td>
<td class="cellrowborder" valign="top" width="8.37%" headers="mcps1.3.5.2.2.6.1.2 "><p id="dli_08_0384__en-us_topic_0000001309855869_p39874618217">No</p>
</td>
<td class="cellrowborder" valign="top" width="10.35%" headers="mcps1.3.5.2.2.6.1.3 "><p id="dli_08_0384__en-us_topic_0000001309855869_p298174618218">None</p>
</td>
<td class="cellrowborder" valign="top" width="8.870000000000001%" headers="mcps1.3.5.2.2.6.1.4 "><p id="dli_08_0384__en-us_topic_0000001309855869_p998646182118">String</p>
</td>
<td class="cellrowborder" valign="top" width="52.900000000000006%" headers="mcps1.3.5.2.2.6.1.5 "><p id="dli_08_0384__en-us_topic_0000001309855869_p18525963217">Representation for null values for string fields.</p>
<p id="dli_08_0384__en-us_topic_0000001309855869_p1981246142115">HBase source encodes/decodes empty bytes as null values for all types except the string type.</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="dli_08_0384__en-us_topic_0000001309855869_section11151124192013"><h4 class="sectiontitle">Data Type Mapping</h4><p id="dli_08_0384__en-us_topic_0000001309855869_p169933132115">HBase stores all data as byte arrays. The data needs to be serialized and deserialized during read and write operations.</p>
<p id="dli_08_0384__en-us_topic_0000001309855869_p66992342118">When serializing and de-serializing, Flink HBase connector uses utility class <strong id="dli_08_0384__en-us_topic_0000001309855869_b3537742114310">org.apache.hadoop.hbase.util.Bytes</strong> provided by HBase (Hadoop) to convert Flink data types to and from byte arrays.</p>
<p id="dli_08_0384__en-us_topic_0000001309855869_p269919319215">Flink HBase connector encodes null values to empty bytes, and decode empty bytes to null values for all data types except the string type. For the string type, the null literal is determined by the <strong id="dli_08_0384__en-us_topic_0000001309855869_b547935316447">null-string-literal</strong> option.</p>
<div class="tablenoborder"><table cellpadding="4" cellspacing="0" summary="" id="dli_08_0384__en-us_topic_0000001309855869_table17452636132111" frame="border" border="1" rules="all"><caption><b>Table 2 </b>Data type mapping</caption><thead align="left"><tr id="dli_08_0384__en-us_topic_0000001309855869_row1345263617217"><th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.6.5.2.3.1.1"><p id="dli_08_0384__en-us_topic_0000001309855869_p16452436132117">Flink SQL Type</p>
</th>
<th align="left" class="cellrowborder" valign="top" width="50%" id="mcps1.3.6.5.2.3.1.2"><p id="dli_08_0384__en-us_topic_0000001309855869_p12452123662114">HBase Conversion</p>
</th>
</tr>
</thead>
<tbody><tr id="dli_08_0384__en-us_topic_0000001309855869_row14452636132115"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.1 "><p id="dli_08_0384__en-us_topic_0000001309855869_p2045273672116">CHAR/VARCHAR/STRING</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.2 "><p id="dli_08_0384__en-us_topic_0000001309855869_p427912322519">byte[] toBytes(String s)</p>
<p id="dli_08_0384__en-us_topic_0000001309855869_p12279192302515">String toString(byte[] b)</p>
</td>
</tr>
<tr id="dli_08_0384__en-us_topic_0000001309855869_row1145216365211"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.1 "><p id="dli_08_0384__en-us_topic_0000001309855869_p19452143632119">BOOLEAN</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.2 "><p id="dli_08_0384__en-us_topic_0000001309855869_p759018125250">byte[] toBytes(boolean b)</p>
<p id="dli_08_0384__en-us_topic_0000001309855869_p4590212192515">boolean toBoolean(byte[] b)</p>
</td>
</tr>
<tr id="dli_08_0384__en-us_topic_0000001309855869_row17452153612211"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.1 "><p id="dli_08_0384__en-us_topic_0000001309855869_p18452103611212">BINARY/VARBINARY</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.2 "><p id="dli_08_0384__en-us_topic_0000001309855869_p14452736182115">Returns byte[] as is.</p>
</td>
</tr>
<tr id="dli_08_0384__en-us_topic_0000001309855869_row34521365219"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.1 "><p id="dli_08_0384__en-us_topic_0000001309855869_p13452173612116">DECIMAL</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.2 "><p id="dli_08_0384__en-us_topic_0000001309855869_p1214719587243">byte[] toBytes(BigDecimal v)</p>
<p id="dli_08_0384__en-us_topic_0000001309855869_p614745818244">BigDecimal toBigDecimal(byte[] b)</p>
</td>
</tr>
<tr id="dli_08_0384__en-us_topic_0000001309855869_row194521636162114"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.1 "><p id="dli_08_0384__en-us_topic_0000001309855869_p94521636202112">TINYINT</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.2 "><p id="dli_08_0384__en-us_topic_0000001309855869_p1211974622411">new byte[] { val }</p>
<p id="dli_08_0384__en-us_topic_0000001309855869_p1119174610240">bytes[0] // returns first and only byte from bytes</p>
</td>
</tr>
<tr id="dli_08_0384__en-us_topic_0000001309855869_row1452183613212"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.1 "><p id="dli_08_0384__en-us_topic_0000001309855869_p1452133616212">SMALLINT</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.2 "><p id="dli_08_0384__en-us_topic_0000001309855869_p1454183510245">byte[] toBytes(short val)</p>
<p id="dli_08_0384__en-us_topic_0000001309855869_p17541435142410">short toShort(byte[] bytes)</p>
</td>
</tr>
<tr id="dli_08_0384__en-us_topic_0000001309855869_row445243617216"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.1 "><p id="dli_08_0384__en-us_topic_0000001309855869_p2452636112110">INT</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.2 "><p id="dli_08_0384__en-us_topic_0000001309855869_p1320111234249">byte[] toBytes(int val)</p>
<p id="dli_08_0384__en-us_topic_0000001309855869_p18201142392416">int toInt(byte[] bytes)</p>
</td>
</tr>
<tr id="dli_08_0384__en-us_topic_0000001309855869_row1945215360211"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.1 "><p id="dli_08_0384__en-us_topic_0000001309855869_p3452123622112">BIGINT</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.2 "><p id="dli_08_0384__en-us_topic_0000001309855869_p1154166122417">byte[] toBytes(long val)</p>
<p id="dli_08_0384__en-us_topic_0000001309855869_p1415418682418">long toLong(byte[] bytes)</p>
</td>
</tr>
<tr id="dli_08_0384__en-us_topic_0000001309855869_row194521236172116"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.1 "><p id="dli_08_0384__en-us_topic_0000001309855869_p1645219360213">FLOAT</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.2 "><p id="dli_08_0384__en-us_topic_0000001309855869_p109061555234">byte[] toBytes(float val)</p>
<p id="dli_08_0384__en-us_topic_0000001309855869_p29061155172318">float toFloat(byte[] bytes)</p>
</td>
</tr>
<tr id="dli_08_0384__en-us_topic_0000001309855869_row34521036162118"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.1 "><p id="dli_08_0384__en-us_topic_0000001309855869_p4452193617217">DOUBLE</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.2 "><p id="dli_08_0384__en-us_topic_0000001309855869_p1560994310231">byte[] toBytes(double val)</p>
<p id="dli_08_0384__en-us_topic_0000001309855869_p1060919435236">double toDouble(byte[] bytes)</p>
</td>
</tr>
<tr id="dli_08_0384__en-us_topic_0000001309855869_row245213365217"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.1 "><p id="dli_08_0384__en-us_topic_0000001309855869_p1545263612118">DATE</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.2 "><p id="dli_08_0384__en-us_topic_0000001309855869_p18452173612216">Stores the number of days since epoch as an int value.</p>
</td>
</tr>
<tr id="dli_08_0384__en-us_topic_0000001309855869_row1245215363215"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.1 "><p id="dli_08_0384__en-us_topic_0000001309855869_p134521336202116">TIME</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.2 "><p id="dli_08_0384__en-us_topic_0000001309855869_p845216364217">Stores the number of milliseconds of the day as an int value.</p>
</td>
</tr>
<tr id="dli_08_0384__en-us_topic_0000001309855869_row1445210368211"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.1 "><p id="dli_08_0384__en-us_topic_0000001309855869_p5452173632110">TIMESTAMP</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.2 "><p id="dli_08_0384__en-us_topic_0000001309855869_p7452103652111">Stores the milliseconds since epoch as a long value.</p>
</td>
</tr>
<tr id="dli_08_0384__en-us_topic_0000001309855869_row124521366214"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.1 "><p id="dli_08_0384__en-us_topic_0000001309855869_p84521436122116">ARRAY</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.2 "><p id="dli_08_0384__en-us_topic_0000001309855869_p1645233692113">Not supported</p>
</td>
</tr>
<tr id="dli_08_0384__en-us_topic_0000001309855869_row174521936172119"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.1 "><p id="dli_08_0384__en-us_topic_0000001309855869_p9452193611215">MAP/MULTISET</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.2 "><p id="dli_08_0384__en-us_topic_0000001309855869_p4452113616213">Not supported</p>
</td>
</tr>
<tr id="dli_08_0384__en-us_topic_0000001309855869_row174521363211"><td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.1 "><p id="dli_08_0384__en-us_topic_0000001309855869_p18452123618211">ROW</p>
</td>
<td class="cellrowborder" valign="top" width="50%" headers="mcps1.3.6.5.2.3.1.2 "><p id="dli_08_0384__en-us_topic_0000001309855869_p8452203682114">Not supported</p>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="dli_08_0384__en-us_topic_0000001309855869_section61832384211"><h4 class="sectiontitle">Example</h4><p id="dli_08_0384__en-us_topic_0000001309855869_p3790101743316">In this example, data is read from the HBase data source and written to the Print result table. The procedure is as follows (the HBase versions used in this example are 1.3.1, 2.1.1, and 2.2.3):</p>
<ol id="dli_08_0384__en-us_topic_0000001309855869_ol1653315113813"><li id="dli_08_0384__en-us_topic_0000001309855869_li6127741153217">Create an enhanced datasource connection in the VPC and subnet where HBase locates, and bind the connection to the required Flink queue. .</li><li id="dli_08_0384__en-us_topic_0000001309855869_li1233002211514">Set HBase cluster security groups and add inbound rules to allow access from the Flink job queue. Test the connectivity using the HBase address. If the connection is successful, the datasource is bound to the queue. Otherwise, the binding fails.</li><li id="dli_08_0384__en-us_topic_0000001309855869_li106531615133812">Use the HBase shell to create HBase table <strong id="dli_08_0384__en-us_topic_0000001309855869_b194515515300">order</strong> that has only one column family <strong id="dli_08_0384__en-us_topic_0000001309855869_b1295185573014">detail</strong>. The creation statement is as follows:<pre class="screen" id="dli_08_0384__en-us_topic_0000001309855869_screen46881014103714">create 'order', {NAME =&gt; 'detail'}</pre>
</li><li id="dli_08_0384__en-us_topic_0000001309855869_li465315151388">Run the following command in the HBase shell to insert a data record:<pre class="screen" id="dli_08_0384__en-us_topic_0000001309855869_screen14406444164511">put 'order', '202103241000000001', 'detail:order_channel','webShop'
put 'order', '202103241000000001', 'detail:order_time','2021-03-24 10:00:00'
put 'order', '202103241000000001', 'detail:pay_amount','100.00'
put 'order', '202103241000000001', 'detail:real_pay','100.00'
put 'order', '202103241000000001', 'detail:pay_time','2021-03-24 10:02:03'
put 'order', '202103241000000001', 'detail:user_id','0001'
put 'order', '202103241000000001', 'detail:user_name','Alice'
put 'order', '202103241000000001', 'detail:area_id','330106'</pre>
</li><li id="dli_08_0384__en-us_topic_0000001309855869_li1853617341421">Create a Flink OpenSource SQL job. Enter the following job script and submit the job. The job script uses the HBase data source and the Print result table.<div class="p" id="dli_08_0384__en-us_topic_0000001309855869_p1336815819121"><a name="dli_08_0384__en-us_topic_0000001309855869_li1853617341421"></a><a name="en-us_topic_0000001309855869_li1853617341421"></a>When you create a job, set <strong id="dli_08_0384__en-us_topic_0000001309855869_b1874753017383">Flink Version</strong> to <strong id="dli_08_0384__en-us_topic_0000001309855869_b474715309387">1.12</strong> on the <strong id="dli_08_0384__en-us_topic_0000001309855869_b4747183033814">Running Parameters</strong> tab. Select <strong id="dli_08_0384__en-us_topic_0000001309855869_b87481330103815">Save Job Log</strong>, and specify the OBS bucket for saving job logs. <strong id="dli_08_0384__en-us_topic_0000001309855869_b9469834123810">Change the values of the parameters in bold as needed in the following script.</strong><pre class="screen" id="dli_08_0384__en-us_topic_0000001309855869_screen16956411341">create table hbaseSource (
order_id string,-- Indicates the unique rowkey.
detail Row( -- Indicates the column family.
order_channel string,
order_time string,
pay_amount string,
real_pay string,
pay_time string,
user_id string,
user_name string,
area_id string),
primary key (order_id) not enforced
) with (
'connector' = 'hbase-2.2',
'table-name' = 'order',
'zookeeper.quorum' = '<em id="dli_08_0384__en-us_topic_0000001309855869_i166950418420"><strong id="dli_08_0384__en-us_topic_0000001309855869_b12695124114413">ZookeeperAddress</strong></em><strong id="dli_08_0384__en-us_topic_0000001309855869_b06951541244">:</strong><em id="dli_08_0384__en-us_topic_0000001309855869_i269594114418"><strong id="dli_08_0384__en-us_topic_0000001309855869_b26954411440">ZookeeperPort</strong></em>'
) ;
create table printSink (
order_id string,
order_channel string,
order_time string,
pay_amount string,
real_pay string,
pay_time string,
user_id string,
user_name string,
area_id string
) with (
'connector' = 'print'
);
insert into printSink select order_id, detail.order_channel,detail.order_time,detail.pay_amount,detail.real_pay,
detail.pay_time,detail.user_id,detail.user_name,detail.area_id from hbaseSource;</pre>
</div>
</li><li id="dli_08_0384__en-us_topic_0000001309855869_li196531315123812">Perform the following operations to view the data result in the <strong id="dli_08_0384__en-us_topic_0000001309855869_b2391055163912">taskmanager.out</strong> file:<ol type="a" id="dli_08_0384__en-us_topic_0000001309855869_ol864115198285"><li id="dli_08_0384__en-us_topic_0000001309855869_li10901621122819">Log in to the DLI console. In the navigation pane, choose <strong id="dli_08_0384__en-us_topic_0000001309855869_b34814415405">Job Management</strong> &gt; <strong id="dli_08_0384__en-us_topic_0000001309855869_b154820416409">Flink Jobs</strong>.</li><li id="dli_08_0384__en-us_topic_0000001309855869_li1912163912282">Click the name of the corresponding Flink job, choose <strong id="dli_08_0384__en-us_topic_0000001309855869_b1714397114017">Run Log</strong>, click <strong id="dli_08_0384__en-us_topic_0000001309855869_b514315711409">OBS Bucket</strong>, and locate the folder of the log you want to view according to the date.</li><li id="dli_08_0384__en-us_topic_0000001309855869_li0641191914285">Go to the folder of the date, find the folder whose name contains <strong id="dli_08_0384__en-us_topic_0000001309855869_b13575111074014">taskmanager</strong>, download the <strong id="dli_08_0384__en-us_topic_0000001309855869_b14581101016401">taskmanager.out</strong> file, and view result logs.</li></ol>
<p id="dli_08_0384__en-us_topic_0000001309855869_p1282118785912">The data result is as follows:</p>
<pre class="screen" id="dli_08_0384__en-us_topic_0000001309855869_screen362317445517">+I(202103241000000001,webShop,2021-03-24 10:00:00,100.00,100.00,2021-03-24 10:02:03,0001,Alice,330106)</pre>
</li></ol>
</div>
<div class="section" id="dli_08_0384__en-us_topic_0000001309855869_section2866161416556"><h4 class="sectiontitle">FAQ</h4><ul id="dli_08_0384__en-us_topic_0000001309855869_ul12997132085515"><li id="dli_08_0384__en-us_topic_0000001309855869_li3572331131019">Q: What should I do if the Flink job execution fails and the log contains the following error information?<pre class="screen" id="dli_08_0384__en-us_topic_0000001309855869_screen19962933175517">java.lang.IllegalArgumentException: offset (0) + length (8) exceed the capacity of the array: 6</pre>
<p id="dli_08_0384__en-us_topic_0000001309855869_p1953716291297">A: If data in the HBase table is imported in other modes, the data is represented in the string format. Therefore, this error is reported when other data formats are used. Change the type of the non-string fields in the HBase source table created by Flink to the string format.</p>
</li></ul>
</div>
<ul id="dli_08_0384__en-us_topic_0000001309855869_ul131735578596"><li id="dli_08_0384__en-us_topic_0000001309855869_li26441528151411">Q: What should I do if the Flink job execution fails and the log contains the following error information?<pre class="screen" id="dli_08_0384__en-us_topic_0000001309855869_screen791603201416">org.apache.zookeeper.ClientCnxn$SessionTimeoutException: Client session timed out, have not heard from server in 90069ms for connection id 0x0</pre>
<p id="dli_08_0384__en-us_topic_0000001309855869_p169161432181415">A: The datasource connection is not bound, the binding fails, or the security group of the HBase cluster is not configured to allow access from the network segment of the DLI queue. Configure the datasource connection or configure the security group of the HBase cluster to allow access from the DLI queue.</p>
</li></ul>
</div>
<div>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="dli_08_0381.html">Creating Source Tables</a></div>
</div>
</div>