Composite key in Ignite

1k views Asked by At

I've created a Ignite table via defining two columns as primary key (PK). When I tried to insert the data its failing with duplicate key error. PK defined on type and id column.

0: jdbc:ignite:thin://node1.example.com> insert into balance (type,amount,currency,asof,id) values ('Current Balance',20000.1,'INR','2020-04-07 00:00:00.000','1009230183926');
1 row affected (0.036 seconds)

0: jdbc:ignite:thin://node1.example.com> insert into balance (type,amount,currency,asof,id) values ('Current Balance',30000,'INR','2020-04-07 00:00:00.000','1009230183926');
Error: Duplicate key during INSERT [key=SQL_PUBLIC_BALANCE_4791140f_63cb_4663_8c02_58f14073ff0c_KEY [idHash=1321771843, hash=-1614321497, TYPE=Current Balance, ID=1009230183926]] (state=23000,code=4001)
java.sql.SQLException: Duplicate key during INSERT [key=SQL_PUBLIC_BALANCE_4791140f_63cb_4663_8c02_58f14073ff0c_KEY [idHash=1321771843, hash=-1614321497, TYPE=Current Balance, ID=1009230183926]]

Does Ignite support composite key like any other RDBMS? How I can resolve this.

1

There are 1 answers

0
Valentin Kulichenko On

Composite keys are supported by Ignite, and in this case, it looks to be configured corrected with both type and id included in the key.

The exception is expected as well, as both inserts have the same values for type and id columns (Current Balance and 1009230183926 respectively).