When creating a table in the China-domestically developed GBase 8a MPP database from GBASE, the hash distribution column accepts integer (int, bigint), character (varchar) and decimal types. This post verifies that on two builds, 8.6.2.43-R35.5 and 9.5.3.28.18, with every statement run from the gbase client.

Integer distribution columns

In principle, stick to int and bigint. smallint and tinyint are accepted by the parser without an error, but they are not recommended for production based on field experience.

int

gbase> create table td_int(id int,name varchar(100))distributed by('id'); Query OK, 0 rows affected (Elapsed: 00:00:00.23) gbase> show create table td_int; +--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | td_int | CREATE TABLE "td_int" ( "id" int(11) DEFAULT NULL, "name" varchar(100) DEFAULT NULL ) ENGINE=EXPRESS DISTRIBUTED BY('id') DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' | +--------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (Elapsed: 00:00:00.00) 

bigint

gbase> create table td_bigint(id bigint,name varchar(100))distributed by('id'); Query OK, 0 rows affected (Elapsed: 00:00:00.21) gbase> show create table td_bigint; +-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | td_bigint | CREATE TABLE "td_bigint" ( "id" bigint(20) DEFAULT NULL, "name" varchar(100) DEFAULT NULL ) ENGINE=EXPRESS DISTRIBUTED BY('id') DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' | +-----------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (Elapsed: 00:00:00.00) 

smallint

Accepted, but not advised:

gbase> create table td_smallint(id smallint,name varchar(100))distributed by('id'); Query OK, 0 rows affected (Elapsed: 00:00:00.24) gbase> show create table td_smallint; +-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | td_smallint | CREATE TABLE "td_smallint" ( "id" smallint(6) DEFAULT NULL, "name" varchar(100) DEFAULT NULL ) ENGINE=EXPRESS DISTRIBUTED BY('id') DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' | +-------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (Elapsed: 00:00:00.00) 

Character distribution columns

Only varchar works. char and text are rejected with the same error:

gbase> create table td_char(id tinyint,name char(100))distributed by('name'); ERROR 1721 (HY000): (GBA-02DD-0003) Type of distributed column 'name' is incorrect. gbase> gbase> create table td_text(id tinyint,name text)distributed by('name'); ERROR 1721 (HY000): (GBA-02DD-0003) Type of distributed column 'name' is incorrect. gbase> 

varchar

gbase> create table td_varchar(id tinyint,name varchar(100))distributed by('name'); Query OK, 0 rows affected (Elapsed: 00:00:00.20) gbase> show create table td_varchar; +------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | td_varchar | CREATE TABLE "td_varchar" ( "id" tinyint(4) DEFAULT NULL, "name" varchar(100) DEFAULT NULL ) ENGINE=EXPRESS DISTRIBUTED BY('name') DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' | +------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (Elapsed: 00:00:00.00) 

decimal distribution columns

decimal is supported too:

gbase> create table td_decimal(id decimal(18,3),name text)distributed by('id'); Query OK, 0 rows affected (Elapsed: 00:00:00.22) gbase> show create table td_decimal; +------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Table | Create Table | +------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | td_decimal | CREATE TABLE "td_decimal" ( "id" decimal(18,3) DEFAULT NULL, "name" text ) ENGINE=EXPRESS DISTRIBUTED BY('id') DEFAULT CHARSET=utf8 TABLESPACE='sys_tablespace' | +------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1 row in set (Elapsed: 00:00:00.00) 

Going forward, the practical rule is short: use int or bigint for the distribution key, varchar when the key really is a string, and decimal when the business key is already numeric with scale. A char/text key will fail at create time with GBA-02DD-0003, and the small integer types, while legal, are a poor choice for a production gbase cluster. Choosing the distribution column is one of the few schema decisions in a distributed database that is expensive to change later, so it is worth getting right on the first create.