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

Stefan Miklosovic edited comment on CASSANDRA-20268 at 3/20/25 1:27 PM:
------------------------------------------------------------------------

This already works as expected:

{code}
CREATE TABLE ks.patients (
    id timeuuid PRIMARY KEY,
    name text MASKED WITH system.mask_default() CHECK NOT_NULL(name) AND 
LENGTH(name) > 1
) 
{code}

However, what does not work is when we specify "MASK" _after_ checks:

{code}
cassandra@cqlsh> CREATE TABLE ks.patients (id timeuuid primary key, name text 
check length(name) > 10 masked with system.mask_default());
SyntaxException: line 1:85 mismatched input 'masked' expecting ')' (... 
length(name) > 10 [masked]...)
cassandra@cqlsh> CREATE TABLE ks.patients (id timeuuid primary key, name text 
check length(name) > 10 and masked with system.mask_default());
SyntaxException: line 1:96 no viable alternative at input 'with' (...(name) > 
10 and [masked] with...)
{code}

I would be OK if "masked" had to be specified first but we have to document 
that.

What does not seem to work is when we ALTER a column:

{code}
cassandra@cqlsh> ALTER TABLE ks.patients ALTER name MASKED WITH 
system.mask_default() CHECK NOT_NULL(name) AND LENGTH(name) > 1;
SyntaxException: line 1:69 mismatched input 'CHECK' expecting EOF (...MASKED 
WITH system.mask_default() [CHECK]...)

cassandra@cqlsh> ALTER TABLE ks.patients ALTER name MASKED WITH mask_default() 
CHECK NOT_NULL(name) AND LENGTH(name) > 1;
SyntaxException: line 1:62 mismatched input 'CHECK' expecting EOF (...name 
MASKED WITH mask_default() [CHECK]...)

ALTER TABLE ks.patients ALTER name MASKED WITH mask_default() AND CHECK 
NOT_NULL(name) AND LENGTH(name) > 1;
SyntaxException: line 1:62 mismatched input 'AND' expecting EOF (...name MASKED 
WITH mask_default() [AND]...)
{code}

Altering that column individually works. I would focus on why the combination 
of it does not work.


was (Author: smiklosovic):
This already works as expected:

{code}
CREATE TABLE ks.patients (
    id timeuuid PRIMARY KEY,
    name text MASKED WITH system.mask_default() CHECK NOT_NULL(name) AND 
LENGTH(name) > 1
) 
{code}

However, what does not work is when we specify "MASK" _after_ checks:

{code}
cassandra@cqlsh> CREATE TABLE ks.patients (id timeuuid primary key, name text 
check length(name) > 10 masked with system.mask_default());
SyntaxException: line 1:85 mismatched input 'masked' expecting ')' (... 
length(name) > 10 [masked]...)
cassandra@cqlsh> CREATE TABLE ks.patients (id timeuuid primary key, name text 
check length(name) > 10 and masked with system.mask_default());
SyntaxException: line 1:96 no viable alternative at input 'with' (...(name) > 
10 and [masked] with...)

I would be OK if "masked" had to be specified first but we have to document 
that.

{code}

What does not seem to work is when we ALTER a column:

{code}
cassandra@cqlsh> ALTER TABLE ks.patients ALTER name MASKED WITH 
system.mask_default() CHECK NOT_NULL(name) AND LENGTH(name) > 1;
SyntaxException: line 1:69 mismatched input 'CHECK' expecting EOF (...MASKED 
WITH system.mask_default() [CHECK]...)

cassandra@cqlsh> ALTER TABLE ks.patients ALTER name MASKED WITH mask_default() 
CHECK NOT_NULL(name) AND LENGTH(name) > 1;
SyntaxException: line 1:62 mismatched input 'CHECK' expecting EOF (...name 
MASKED WITH mask_default() [CHECK]...)

ALTER TABLE ks.patients ALTER name MASKED WITH mask_default() AND CHECK 
NOT_NULL(name) AND LENGTH(name) > 1;
SyntaxException: line 1:62 mismatched input 'AND' expecting EOF (...name MASKED 
WITH mask_default() [AND]...)
{code}

Altering that column individually works. I would focus on why the combination 
of it does not work.

> Add constraints support to be used with MASKED statements
> ---------------------------------------------------------
>
>                 Key: CASSANDRA-20268
>                 URL: https://issues.apache.org/jira/browse/CASSANDRA-20268
>             Project: Apache Cassandra
>          Issue Type: Improvement
>          Components: Feature/Constraints
>            Reporter: Bernardo Botella Corbi
>            Priority: Normal
>
> Currently, constraints CHECK keyword and MASKED keyword can't go together. We 
> need to find a way of supporting both at the same time.



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

---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org
For additional commands, e-mail: commits-h...@cassandra.apache.org

Reply via email to