
# 创建Hbase维表
#### 功能描述
创建Hbase维表用于与输入流连接。
#### 前提条件
- 该场景作业需要运行在DLI的独享队列上，因此要与HBase建立增强型跨源连接，且用户可以根据实际所需设置相应安全组规则。
  - 如何建立增强型跨源连接，请参考《数据湖探索用户指南》中[增强型跨源连接](https://support.huaweicloud.com/usermanual-dli/dli_01_0426.html)章节。
  
  - 如何设置安全组规则，请参见[《虚拟私有云用户指南》](https://support.huaweicloud.com/usermanual-vpc/zh-cn_topic_0073379079.html)中"安全组"章节。
   
- **若使用MRS HBase，请在增强型跨源的主机信息中添加MRS集群所有节点的主机ip信息。**
  详细操作请参考《数据湖探索用户指南》中的"[修改主机信息](https://support.huaweicloud.com/usermanual-dli/dli_01_0013.html)"章节描述。
  
 
#### 语法格式
```
create table hbaseSource (
  attr_name attr_type 
  (',' attr_name attr_type)* 
 )
with (
  'connector.type' = 'hbase',
  'connector.version' = '1.4.3',
  'connector.table-name' = '',
  'connector.zookeeper.quorum' = ''
);
```
#### 参数说明
表1参数说明 
| 参数                               | 是否必选 | 说明                       |
|:---|:---|:---|
| connector.type                   | 是    | connector的类型，只能为hbase    |
| connector.version                | 是    | 该值只能为1.4.3               |
| connector. table-name            | 是    | hbase中的表名                |
| connector.zookeeper.quorum       | 是    | Zookeeper的地址             |
| connector.zookeeper.znode.parent | 否    | Zookeeper中的根目录，默认是/hbase |
   
#### 示例
```
create table hbaseSource(
  id string,
  i Row<score string>
 ) with (
   'connector.type' = 'hbase',
   'connector.version' = '1.4.3',
   'connector.table-name' = 'user',
   'connector.zookeeper.quorum' = 'xxxx:2181'
 );
create table source1(
  id string,
  name string,
  geneder string,
  age int,
  address string,
  proctime as PROCTIME()
) with (
  "connector.type" = "dis",
  "connector.region" = "cn-north-1",
  "connector.channel" = "read",
  "connector.ak" = "xxxxxx",
  "connector.sk" = "xxxxxx",
  "format.type" = 'csv'
);
 create table hbaseSink(
  rowkey string,
  i Row<name string, geneder string, age int, address string>,
  j ROW<score string>
 ) with (
   'connector.type' = 'hbase',
   'connector.version' = '1.4.3',
   'connector.table-name' = 'score',
   'connector.write.buffer-flush.max-rows' = '1',
   'connector.zookeeper.quorum' = 'xxxx:2181'
 );
 insert into hbaseSink select d.id, ROW(name, geneder,age,address), ROW(score) from source1 as d join hbaseSource for system_time as of d.proctime as h on d.id = h.id;
```
