[ 
https://issues.apache.org/jira/browse/CASSANDRA-20331?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17928392#comment-17928392
 ] 

Stefan Miklosovic commented on CASSANDRA-20331:
-----------------------------------------------

If a user goes to create a table like

create ks.tb (id int primary key, val int check val > 100 and val < 0)

 then this does not make sense. There is no such "val" where both constraints 
would be satisfied. So why should reach this server in the first place? We 
might check in driver as part of table creation.

Secondly, if there is this

create ks.tb (id int primary key, val text check json(val));
insert ks.tb (id, val) values (1, 'this_is_not_json');

and a user tries to insert a string which is not json, that is again something 
which might be done on driver's side, no? Sure, a server would "double check" 
but if something can be easily evaluated on client we can do that there so it 
will never reach server. Why would we want to "bombard" a server with invalid 
inserts if we can check them before.

> Expose constraints in system_schema.column_constraints
> ------------------------------------------------------
>
>                 Key: CASSANDRA-20331
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-20331
>             Project: Apache Cassandra
>          Issue Type: Task
>          Components: Feature/Constraints
>            Reporter: Stefan Miklosovic
>            Assignee: Bernardo Botella Corbi
>            Priority: Normal
>             Fix For: 5.x
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> There is already system_schema.column_masks 
> {code}
> CREATE TABLE system_schema.column_masks (
>     keyspace_name text,
>     table_name text,
>     column_name text,
>     function_argument_nulls frozen<list<boolean>>,
>     function_argument_types frozen<list<text>>,
>     function_argument_values frozen<list<text>>,
>     function_keyspace text,
>     function_name text,
>     PRIMARY KEY (keyspace_name, table_name, column_name)
> ) WITH CLUSTERING ORDER BY (table_name ASC, column_name ASC)
> {code}
> We need this table with constraints of each column, similar to masks. Right 
> now there is no programmatic way to realize what constraints a column has. 
> This will come handy when Java Driver will start to support this. They will 
> just scan system_schema.column_constraints and they can e.g. fail the query 
> on client side it will never reach the server ... 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to