diff --git a/src/client/src/database.rs b/src/client/src/database.rs index 528c57632e3b..80dc51df2ef6 100644 --- a/src/client/src/database.rs +++ b/src/client/src/database.rs @@ -144,7 +144,7 @@ impl Database { let mut request = tonic::Request::new(request); let metadata = request.metadata_mut(); for (key, value) in hints { - let key = AsciiMetadataKey::from_bytes(format!("x-greptime-hint:{}", key).as_bytes()) + let key = AsciiMetadataKey::from_bytes(format!("x-greptime-hint-{}", key).as_bytes()) .map_err(|_| { InvalidAsciiSnafu { value: key.to_string(), diff --git a/src/servers/src/grpc/database.rs b/src/servers/src/grpc/database.rs index ae7660f3226b..4c3cf2c72b0d 100644 --- a/src/servers/src/grpc/database.rs +++ b/src/servers/src/grpc/database.rs @@ -26,7 +26,7 @@ use tonic::{Request, Response, Status, Streaming}; use crate::grpc::greptime_handler::GreptimeRequestHandler; use crate::grpc::{cancellation, TonicResult}; -pub const GREPTIME_DB_HEADER_HINT_PREFIX: &str = "x-greptime-hint:"; +pub const GREPTIME_DB_HEADER_HINT_PREFIX: &str = "x-greptime-hint-"; pub(crate) struct DatabaseService { handler: GreptimeRequestHandler, @@ -177,7 +177,11 @@ mod tests { #[test] fn test_extract_hints() { let mut metadata = MetadataMap::new(); - metadata.insert("x-greptime-hint:append_mode", "true".parse().unwrap()); + let prev = metadata.insert( + "x-greptime-hint-append_mode", + MetadataValue::from_static("true"), + ); + assert!(prev.is_none()); let hints = extract_hints(&metadata); assert_eq!(hints, vec![("append_mode".to_string(), "true".to_string())]); } @@ -186,7 +190,7 @@ mod tests { fn extract_hints_ignores_non_ascii_metadata() { let mut metadata = MetadataMap::new(); metadata.insert_bin( - "x-greptime-hint:merge_mode", + "x-greptime-hint-merge_mode-bin", MetadataValue::from_bytes(b"last_non_null"), ); let hints = extract_hints(&metadata); diff --git a/tests-integration/tests/grpc.rs b/tests-integration/tests/grpc.rs index c3a979d7bfb3..4649bb103835 100644 --- a/tests-integration/tests/grpc.rs +++ b/tests-integration/tests/grpc.rs @@ -410,13 +410,13 @@ async fn insert_with_hints_and_assert(db: &Database) { InsertRequests { inserts: vec![request], }, - &[("append_mode", "true"), ("merge_mode", "last_non_null")], + &[("append_mode", "true")], ) .await; assert_eq!(result.unwrap(), 4); // show table - let output = db.sql("SHOW CREATE TABLE demo").await.unwrap(); + let output = db.sql("SHOW CREATE TABLE demo;").await.unwrap(); let record_batches = match output.data { OutputData::RecordBatches(record_batches) => record_batches, @@ -426,16 +426,23 @@ async fn insert_with_hints_and_assert(db: &Database) { let pretty = record_batches.pretty_print().unwrap(); let expected = "\ -+-------+------+--------+-------------------------+ -| host | cpu | memory | ts | -+-------+------+--------+-------------------------+ -| host1 | 0.31 | 0.1 | 1970-01-01T00:00:00.100 | -| host2 | | 0.2 | 1970-01-01T00:00:00.101 | -| host3 | 0.41 | | 1970-01-01T00:00:00.102 | -| host4 | 0.2 | 0.3 | 1970-01-01T00:00:00.103 | -| host5 | 66.6 | 1024.0 | 2022-12-28T04:17:07 | -| host6 | 88.8 | 333.3 | 2022-12-28T04:17:08 | -+-------+------+--------+-------------------------+\ ++-------+-------------------------------------+ +| Table | Create Table | ++-------+-------------------------------------+ +| demo | CREATE TABLE IF NOT EXISTS \"demo\" ( | +| | \"host\" STRING NULL, | +| | \"cpu\" DOUBLE NULL, | +| | \"memory\" DOUBLE NULL, | +| | \"ts\" TIMESTAMP(3) NOT NULL, | +| | TIME INDEX (\"ts\"), | +| | PRIMARY KEY (\"host\") | +| | ) | +| | | +| | ENGINE=mito | +| | WITH( | +| | append_mode = 'true' | +| | ) | ++-------+-------------------------------------+\ "; assert_eq!(pretty, expected); }