⼀、创建
hyperdrive表时候添加
split key
创建表的时候在
tblproperties中使⽤hyperdrive.table.splitkey配置项指定split key
1. 对于struct类型row key, 每个split key都是⼀个Row key对应的⼀个JSON格式的值。在值中的
{、
}和
“ 符号是需要转义的。
⽐如:
{"name":"张三","age":51,"birth":"2004-12-11"}
指定多个split key需要使⽤逗号隔开。
注意:
1) struct类型值中的每个字段顺序都是需要和表中schema的顺序对⻬的。
2) struct类型的值可以指定前缀, 后缀可以省略。
2. 对于原始类型的row key, 每个split key需要使⽤双引号,在值中的
“符号是需要转义的。 多个split key使⽤逗号相隔
示例
1. struct row key预分region
drop table
if exists split_key_test;
create table split_key_test(
key struct<name:string,birth:date>,
name string,
age
int,
birth date
)
row format delimited collection items terminated by '|'
stored by 'io.transwarp.hyperdrive.HyperdriveStorageHandler'
with serdeproperties('hbase.columns.mapping'=':key,f:a1,f:a2,f:a3',
'hyperdrive.structstring.length.default'='10'
)
tblproperties('COMPRESSION'='SNAPPY',
'hyperdrive.table.splitkey'='
{"name":"1000","age":51,"birth":"2004-12-11"},
{"name":"2000","age":51,"birth":"2004-12-11"},
{"name":"3000","age":51,"birth":"2004-12-11"},
{"name":"4000","age":51,"birth":"2004-12-11"},
{"name":"5000","age":51,"birth":"2004-12-11"},
{"name":"6000","age":51,"birth":"2004-12-11"},
{"name":"7000","age":51,"birth":"2004-12-11"},
{"name":"8000","age":51,"birth":"2004-12-11"},
{"name":"9000","age":51,"birth":"2004-12-11"}');
原始类型key预分region
drop table if exists split_key_test;
create table split_key_test (
key bigint,
sv0
bigint
)
stored
by 'io.transwarp.hyperdrive.HyperdriveStorageHandler'
tblproperties('COMPRESSION'='SNAPPY',
'hyperdrive.table.splitkey'='"10000","20000","30000","40000","50000"');