Hi Mike

I have created a table called CITY

: jdbc:ignite:thin://127.0.0.1> CREATE TABLE City (  city_id LONG PRIMARY
KEY, name VARCHAR)  WITH "template=replicated";
No rows affected (0.224 seconds)

Creating a table called Person with affinity key as city_id

0: jdbc:ignite:thin://127.0.0.1> CREATE TABLE IF NOT EXISTS Person ( age
int, id int, city_id LONG , name varchar, company varchar,  PRIMARY KEY
(name, id)) WITH "template=partitioned,backups=1,affinitykey=city_id,
key_type=PersonKey, value_type=MyPerson";

This is the exception I get 

Error: Affinity key column must be one of key columns: CITY_ID
(state=42000,code=0)
java.sql.SQLException: Affinity key column must be one of key columns:
CITY_ID
        at
org.apache.ignite.internal.jdbc.thin.JdbcThinConnection.sendRequest(JdbcThinConnection.java:671)
        at
org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.execute0(JdbcThinStatement.java:130)
        at
org.apache.ignite.internal.jdbc.thin.JdbcThinStatement.execute(JdbcThinStatement.java:299)
        at sqlline.Commands.execute(Commands.java:823)
        at sqlline.Commands.sql(Commands.java:733)
        at sqlline.SqlLine.dispatch(SqlLine.java:795)
        at sqlline.SqlLine.begin(SqlLine.java:668)
        at sqlline.SqlLine.start(SqlLine.java:373)
        at sqlline.SqlLine.main(SqlLine.java:265)
0: jdbc:ignite:thin://127.0.0.1>

And, when I change the primary key to include affinity id, below DDL is
working fine.
0: jdbc:ignite:thin://127.0.0.1> CREATE TABLE IF NOT EXISTS Person ( age
int, id int, city_id LONG , name varchar, company varchar,  PRIMARY KEY
(name, id,city_id)) WITH
"template=partitioned,backups=1,affinitykey=city_id, key_type=PersonKey,
value_type=MyPerson";

This is what I was trying to explain, is affinity key to be part of the
primary key ??

If this is the case, whole my data model will change drastically.

Thanks
Naveen



--
Sent from: http://apache-ignite-users.70518.x6.nabble.com/

Reply via email to