bereng commented on code in PR #2110:
URL: https://github.com/apache/cassandra/pull/2110#discussion_r1101112490
##########
src/java/org/apache/cassandra/cql3/statements/schema/AlterTableStatement.java:
##########
@@ -158,6 +161,73 @@ public KeyspaceMetadata apply(KeyspaceMetadata keyspace,
TableMetadata table)
}
}
+ /**
+ * ALTER TABLE [IF EXISTS] <table> ALTER [IF EXISTS] <column> ( MASKED
WITH <newMask> | DROP MASKED )
+ */
+ public static class MaskColumn extends AlterTableStatement
+ {
+ private final ColumnIdentifier columnName;
+ @Nullable
+ private final ColumnMask.Raw mask;
+ private final boolean ifColumnExists;
+
+ MaskColumn(String keyspaceName,
+ String tableName,
+ ColumnIdentifier columnName,
+ @Nullable ColumnMask.Raw mask,
+ boolean ifTableExists,
+ boolean ifColumnExists)
+ {
+ super(keyspaceName, tableName, ifTableExists);
+ this.columnName = columnName;
+ this.mask = mask;
+ this.ifColumnExists = ifColumnExists;
+ }
+
+ @Override
+ public void validate(ClientState state)
+ {
+ super.validate(state);
+ validateMasking(mask == null
+ ? "remove masking function from column"
+ : "add masking function to column");
+ }
+
+ @Override
+ public KeyspaceMetadata apply(KeyspaceMetadata keyspace, TableMetadata
table)
+ {
+ ColumnMetadata column = table.getColumn(columnName);
+
+ if (column == null)
+ {
+ if (!ifColumnExists)
+ throw ire("Column with name '%s' doesn't exist on table
'%s'", columnName, tableName);
+
+ return keyspace;
+ }
+
+ ColumnMask columnMask = mask == null ? null :
mask.prepare(keyspace.name, table.name, columnName, column.type);
Review Comment:
Do we need to proceed if `columnMask` is null?
`tableBuilder.alterColumnMask` would throw anyway iiuc
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]