blerer commented on code in PR #2110:
URL: https://github.com/apache/cassandra/pull/2110#discussion_r1111710617
##########
src/java/org/apache/cassandra/cql3/statements/schema/AlterTableStatement.java:
##########
@@ -158,6 +162,77 @@ 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;
Review Comment:
Nit: We should may be name it `rawMask`. T prepare call on the `mask`
variable is a bit confusing otherwise.
##########
src/java/org/apache/cassandra/schema/SchemaKeyspace.java:
##########
@@ -688,15 +695,58 @@ private static void
addColumnToSchemaMutation(TableMetadata table, ColumnMetadat
{
AbstractType<?> type = column.type;
if (type instanceof ReversedType)
- type = ((ReversedType) type).baseType;
+ type = ((ReversedType<?>) type).baseType;
- builder.update(Columns)
+ Row.SimpleBuilder rowBuilder = builder.update(Columns)
.row(table.name, column.name.toString())
.add("column_name_bytes", column.name.bytes)
.add("kind", column.kind.toString().toLowerCase())
.add("position", column.position())
.add("clustering_order",
column.clusteringOrder().toString().toLowerCase())
.add("type", type.asCQL3Type().toString());
+
+ // Dynamic data masking functions shouldn't be attached to columns
during rolling upgrades
+ // to avoid sending mutations with columns that are unknown to the old
nodes.
+ ColumnMask mask = column.getMask();
+ if (ColumnMask.clusterSupportsMaskedColumns())
+ {
+ if (mask == null)
+ {
+ rowBuilder.delete("mask_keyspace")
+ .delete("mask_name")
+ .delete("mask_argument_types")
+ .delete("mask_argument_values")
+ .delete("mask_argument_nulls");
+ }
+ else
+ {
+ FunctionName maskFunctionName = mask.function.name();
+
+ // Some arguments of the masking function can be null, but the
CQL's list type that stores them doesn't
Review Comment:
Why not storing the elements as their CQL string? It will make the table
more readable and allow us to store null within the same collection if I am not
missing anything.
##########
src/java/org/apache/cassandra/schema/SchemaKeyspace.java:
##########
@@ -688,15 +695,58 @@ private static void
addColumnToSchemaMutation(TableMetadata table, ColumnMetadat
{
AbstractType<?> type = column.type;
if (type instanceof ReversedType)
- type = ((ReversedType) type).baseType;
+ type = ((ReversedType<?>) type).baseType;
- builder.update(Columns)
+ Row.SimpleBuilder rowBuilder = builder.update(Columns)
.row(table.name, column.name.toString())
.add("column_name_bytes", column.name.bytes)
.add("kind", column.kind.toString().toLowerCase())
.add("position", column.position())
.add("clustering_order",
column.clusteringOrder().toString().toLowerCase())
.add("type", type.asCQL3Type().toString());
+
+ // Dynamic data masking functions shouldn't be attached to columns
during rolling upgrades
+ // to avoid sending mutations with columns that are unknown to the old
nodes.
+ ColumnMask mask = column.getMask();
+ if (ColumnMask.clusterSupportsMaskedColumns())
+ {
+ if (mask == null)
+ {
+ rowBuilder.delete("mask_keyspace")
Review Comment:
I agree.
##########
src/java/org/apache/cassandra/cql3/statements/schema/AlterTableStatement.java:
##########
@@ -595,6 +684,10 @@ public static final class Raw extends CQLStatement.Raw
// ADD
private final List<AddColumns.Column> addedColumns = new ArrayList<>();
+ // ALTER MASK
+ private ColumnIdentifier maskedColumn = null;
+ private ColumnMask.Raw maskedColumnMask = null;
Review Comment:
`rawMask `instead of `maskedColumnMask `?
--
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]