risingwave_frontend::handler::alter_source_with_sr

Function columns_minus

source
fn columns_minus(
    columns_a: &[ColumnCatalog],
    columns_b: &[ColumnCatalog],
) -> Vec<ColumnCatalog>
Expand description

Returns the columns in columns_a but not in columns_b.

Note:

  • The comparison is done by name and data type, without checking ColumnId.
  • Hidden columns and INCLUDE ... AS ... columns are ignored. Because it’s only for the special handling of alter sr. For the newly resolved columns_from_resolve_source (created by bind_columns_from_source), it doesn’t contain hidden columns (_row_id) and INCLUDE ... AS ... columns. This is fragile and we should really refactor it later.
  • Column with the same name but different data type is considered as a different column, i.e., altering the data type of a column will be treated as dropping the old column and adding a new column. Note that we don’t reject here like we do in ALTER TABLE REFRESH SCHEMA, because there’s no data persistence (thus compatibility concern) in the source case.