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

fix: auto created table ttl check #5203

Merged
merged 2 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions src/operator/src/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,9 @@ impl Inserter {

for table in tables {
let table_info = table.table_info();
if table_info.is_ttl_instant_table() {
discord9 marked this conversation as resolved.
Show resolved Hide resolved
instant_table_ids.insert(table_info.table_id());
}
table_name_to_ids.insert(table_info.name.clone(), table_info.table_id());
}
}
Expand All @@ -596,6 +599,9 @@ impl Inserter {
.create_physical_table(create_table, ctx, statement_executor)
.await?;
let table_info = table.table_info();
if table_info.is_ttl_instant_table() {
instant_table_ids.insert(table_info.table_id());
}
table_name_to_ids.insert(table_info.name.clone(), table_info.table_id());
}
for alter_expr in alter_tables.into_iter() {
Expand Down
34 changes: 34 additions & 0 deletions tests-integration/tests/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,40 @@ async fn insert_with_hints_and_assert(db: &Database) {
+-------+-------------------------------------+\
";
assert_eq!(pretty, expected);

// testing data with ttl=instant and auto_create_table = true can be handled correctly
let (expected_host_col, expected_cpu_col, expected_mem_col, expected_ts_col) = expect_data();

let request = InsertRequest {
table_name: "demo1".to_string(),
columns: vec![
expected_host_col.clone(),
expected_cpu_col.clone(),
expected_mem_col.clone(),
expected_ts_col.clone(),
],
row_count: 4,
};
let result = db
.insert_with_hints(
InsertRequests {
inserts: vec![request],
},
&[("auto_create_table", "true"), ("ttl", "instant")],
)
.await;
assert_eq!(result.unwrap(), 0);

// check table is empty
let output = db.sql("SELECT * FROM demo1").await.unwrap();

let record_batches = match output.data {
OutputData::RecordBatches(record_batches) => record_batches,
OutputData::Stream(stream) => RecordBatches::try_collect(stream).await.unwrap(),
OutputData::AffectedRows(_) => unreachable!(),
};

assert!(record_batches.iter().all(|r| r.num_rows() == 0));
}

async fn insert_and_assert(db: &Database) {
Expand Down
Loading