schema_tables: make comment more precise
`maybe_fix_legacy_secondary_index_mv_schema` function has this piece of
code:
```
// If the first clustering key part of a view is a column with name not found in base schema,
// it implies it might be backing an index created before computed columns were introduced,
// and as such it must be recreated properly.
if (!base_schema->columns_by_name().contains(first_view_ck.name())) {
schema_builder builder{schema_ptr(v)};
builder.mark_column_computed(first_view_ck.name(), std::make_unique<legacy_token_column_computation>());
if (preserve_version) {
builder.with_version(v->version());
}
return view_ptr(builder.build());
}
```
The comment uses the phrase "it might be".
However, the code inside the `if` assumes that it "must be": once we
determined that the first column in this materialized view does not have
a corresponding name in the base table, we set it to be computed using
`legacy_token_column_computation`, so we assumed that the column was
indeed storing the token. Doing that for a column which is not the token
column would be a small disaster.
Assuming that the code is correct, we can make the comment more precise.
I checked the documentation and I don't see any other way how we could
have such a column other than the token column which is internally
created by Scylla when creating a secondary index (for example, it is
forbidden to use an alias in select statement when creating materialized
views, which I checked experimentally).
This commit is contained in:
@@ -3680,8 +3680,8 @@ view_ptr maybe_fix_legacy_secondary_index_mv_schema(replica::database& db, const
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the first clustering key part of a view is a column with name not found in base schema,
|
// If the first clustering key part of a view is a column with name not found in base schema,
|
||||||
// it implies it might be backing an index created before computed columns were introduced,
|
// and the column is not computed (which we checked above), then it must be backing an index
|
||||||
// and as such it must be recreated properly.
|
// created before computed columns were introduced, and as such it must be recreated properly.
|
||||||
if (!base_schema->columns_by_name().contains(first_view_ck.name())) {
|
if (!base_schema->columns_by_name().contains(first_view_ck.name())) {
|
||||||
schema_builder builder{schema_ptr(v)};
|
schema_builder builder{schema_ptr(v)};
|
||||||
builder.mark_column_computed(first_view_ck.name(), std::make_unique<legacy_token_column_computation>());
|
builder.mark_column_computed(first_view_ck.name(), std::make_unique<legacy_token_column_computation>());
|
||||||
|
|||||||
Reference in New Issue
Block a user