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: grpc writing supports TTL hint #4651

Merged
Merged
Changes from all commits
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
22 changes: 16 additions & 6 deletions src/operator/src/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use store_api::metric_engine_consts::{
};
use store_api::mito_engine_options::{APPEND_MODE_KEY, MERGE_MODE_KEY};
use store_api::storage::{RegionId, TableId};
use table::requests::InsertRequest as TableInsertRequest;
use table::requests::{InsertRequest as TableInsertRequest, TTL_KEY};
use table::table_reference::TableReference;
use table::TableRef;

Expand Down Expand Up @@ -650,7 +650,12 @@ impl Inserter {
create_type: AutoCreateTableType,
) -> Result<TableRef> {
let mut hint_options = vec![];
let options: &[(&str, &str)] = match create_type {

if let Some(ttl) = ctx.extension(TTL_KEY) {
hint_options.push((TTL_KEY, ttl));
}

match create_type {
AutoCreateTableType::Logical(_) => unreachable!(),
AutoCreateTableType::Physical => {
if let Some(append_mode) = ctx.extension(APPEND_MODE_KEY) {
Expand All @@ -659,13 +664,18 @@ impl Inserter {
if let Some(merge_mode) = ctx.extension(MERGE_MODE_KEY) {
hint_options.push((MERGE_MODE_KEY, merge_mode));
}
hint_options.as_slice()
}
// Set append_mode to true for log table.
// because log tables should keep rows with the same ts and tags.
AutoCreateTableType::Log => &[(APPEND_MODE_KEY, "true")],
AutoCreateTableType::LastNonNull => &[(MERGE_MODE_KEY, "last_non_null")],
};
AutoCreateTableType::Log => {
hint_options.push((APPEND_MODE_KEY, "true"));
}
AutoCreateTableType::LastNonNull => {
hint_options.push((MERGE_MODE_KEY, "last_non_null"));
}
}
let options: &[(&str, &str)] = hint_options.as_slice();

self.create_table_with_options(req, ctx, statement_executor, options)
.await
}
Expand Down