Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: reserve internal column #2396

Merged
merged 4 commits into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/store-api/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ use snafu::{ensure, Location, OptionExt, ResultExt, Snafu};

use crate::region_request::{AddColumn, AddColumnLocation, AlterKind};
use crate::storage::{ColumnId, RegionId};
use crate::storage::consts::is_internal_column;

pub type Result<T> = std::result::Result<T, MetadataError>;

Expand Down Expand Up @@ -368,6 +369,16 @@ impl RegionMetadata {
);
}

ensure!(
!is_internal_column(&column_metadata.column_schema.name),
InvalidMetaSnafu {
evenyag marked this conversation as resolved.
Show resolved Hide resolved
reason: format!(
"{} is internal column name that can not be used",
column_metadata.column_schema.name
),
}
);

Ok(())
}
}
Expand Down
11 changes: 11 additions & 0 deletions src/store-api/src/storage/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,17 @@ pub const OP_TYPE_COLUMN_NAME: &str = "__op_type";
/// Name for reserved column: primary_key
pub const PRIMARY_KEY_COLUMN_NAME: &str = "__primary_key";

/// Internal Column Name
static INTERNAL_COLUMN_VEC: [&str; 3] = [
SEQUENCE_COLUMN_NAME,
OP_TYPE_COLUMN_NAME,
PRIMARY_KEY_COLUMN_NAME,
];

pub fn is_internal_column(name: &str) -> bool {
INTERNAL_COLUMN_VEC.iter().any(|&column| name.contains(column))
evenyag marked this conversation as resolved.
Show resolved Hide resolved
}

// -----------------------------------------------------------------------------

// ---------- Default options --------------------------------------------------
Expand Down