Skip to content

Commit a87c174

Browse files
authored
feat(query): make product name configurable (#20129)
1 parent c77b77a commit a87c174

4 files changed

Lines changed: 18 additions & 2 deletions

File tree

src/query/config/src/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1632,6 +1632,10 @@ pub struct QueryConfig {
16321632
#[clap(long, value_name = "VALUE", default_value = "admin")]
16331633
pub tenant_id: String,
16341634

1635+
/// Product name used in user-visible server version strings.
1636+
#[clap(long, value_name = "VALUE", default_value = "Databend Query")]
1637+
pub product_name: String,
1638+
16351639
/// ID for construct the cluster.
16361640
#[clap(long, value_name = "VALUE", default_value_t)]
16371641
pub cluster_id: String,

src/query/service/src/sessions/query_ctx.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,18 @@ impl QueryContext {
211211
pub fn create_from_shared(shared: Arc<QueryContextShared>) -> Arc<QueryContext> {
212212
debug!("Creating new QueryContext instance");
213213

214-
let tenant = GlobalConfig::instance().query.tenant_id.clone();
214+
let query_config = &GlobalConfig::instance().query;
215+
let tenant = query_config.tenant_id.clone();
215216
let query_settings = Settings::create(tenant);
217+
let product_name = query_config.common.product_name.trim();
218+
let version = if product_name.is_empty() {
219+
shared.version.commit_detail.to_string()
220+
} else {
221+
format!("{} {}", product_name, shared.version.commit_detail)
222+
};
216223
Arc::new(QueryContext {
217224
partition_queue: Arc::new(RwLock::new(VecDeque::new())),
218-
version: format!("Databend Query {}", shared.version.commit_detail),
225+
version,
219226
mysql_version: format!("{MYSQL_VERSION}-{}", shared.version.commit_detail),
220227
shared,
221228
query_settings,

src/query/service/tests/it/configs.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ fn test_env_config_s3() -> anyhow::Result<()> {
8484
("STORAGE_WEBHDFS_ENDPOINT_URL", Some("endpoint_url")),
8585
("STORAGE_WEBHDFS_ROOT", Some("/path/to/root")),
8686
("QUERY_TABLE_ENGINE_MEMORY_ENABLED", Some("true")),
87+
("QUERY_PRODUCT_NAME", Some("Cloud Query")),
8788
("CONFIG_FILE", None),
8889
],
8990
|| {
@@ -94,6 +95,7 @@ fn test_env_config_s3() -> anyhow::Result<()> {
9495
assert_eq!("DEBUG", configured.log.level);
9596

9697
assert_eq!("tenant-1", configured.query.tenant_id);
98+
assert_eq!("Cloud Query", configured.query.product_name);
9799
assert_eq!("cluster-1", configured.query.cluster_id);
98100
assert_eq!("127.0.0.1", configured.query.mysql_handler_host);
99101
assert_eq!(3306, configured.query.mysql_handler_port);
@@ -677,6 +679,7 @@ fn test_override_config() -> anyhow::Result<()> {
677679
678680
[query]
679681
tenant_id = "tenant_id_from_file"
682+
product_name = "Cloud Query"
680683
cluster_id = ""
681684
num_cpus = 0
682685
mysql_handler_host = "127.0.0.1"
@@ -811,6 +814,7 @@ path = "_cache"
811814
assert!(!cfg.log.query.log_query_on);
812815

813816
assert_eq!("tenant_id_from_env", cfg.query.tenant_id);
817+
assert_eq!("Cloud Query", cfg.query.product_name);
814818
assert_eq!("access_key_id_from_env", cfg.storage.s3.access_key_id);
815819
assert_eq!("s3", cfg.storage.typ);
816820

src/query/service/tests/it/storages/testdata/configs_table_basic.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,7 @@ DB.Table: 'system'.'configs', Table: configs-table_id:1, ver:0, Engine: SystemCo
224224
| 'query' | 'network_policy_whitelist' | '' | '' |
225225
| 'query' | 'num_cpus' | '0' | '' |
226226
| 'query' | 'parquet_fast_read_bytes' | 'null' | '' |
227+
| 'query' | 'product_name' | 'Databend Query' | '' |
227228
| 'query' | 'quota' | 'null' | '' |
228229
| 'query' | 'resources_management' | 'null' | '' |
229230
| 'query' | 'rpc_client_timeout_secs' | '0' | '' |

0 commit comments

Comments
 (0)