Skip to content

Commit 1500d69

Browse files
committed
chore(cubestore): Upgrade DF: Use lowercase names for UDAF registry
1 parent d84d4a4 commit 1500d69

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

rust/cubestore/cubestore/src/queryplanner/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -502,18 +502,18 @@ impl ContextProvider for MetaStoreSchemaProvider {
502502
return Some(scalar_udf_by_kind(kind));
503503
}
504504

505-
fn get_aggregate_meta(&self, name: &str) -> Option<Arc<AggregateUDF>> {
505+
fn get_aggregate_meta(&self, name_param: &str) -> Option<Arc<AggregateUDF>> {
506506
// HyperLogLog.
507507
// TODO: case-insensitive names.
508+
/*
508509
let (_kind, name) = match name {
509510
"merge" | "MERGE" => (CubeAggregateUDFKind::MergeHll, "MERGE"),
510511
_ => return None,
511512
};
513+
*/
514+
let name = name_param.to_ascii_lowercase();
512515

513-
let aggregate_udf_by_registry = self.session_state.aggregate_functions().get(name);
514-
515-
// TODO upgrade DF: Remove this assertion (and/or remove the kind lookup above).
516-
assert!(aggregate_udf_by_registry.is_some(), "MERGE is not registered in SessionState");
516+
let aggregate_udf_by_registry: Option<&Arc<AggregateUDF>> = self.session_state.aggregate_functions().get(&name);
517517

518518
aggregate_udf_by_registry.map(|arc| arc.clone())
519519
}

rust/cubestore/cubestore/src/queryplanner/udfs.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ pub fn scalar_kind_by_name(n: &str) -> Option<CubeScalarUDFKind> {
7878
if n == "DATE_BIN" {
7979
return Some(CubeScalarUDFKind::DateBin);
8080
}
81+
// TODO upgrade DF: Remove this (once we are no longer in flux about naming casing of UDFs and UDAFs).
82+
if ["CARDINALITY", /* "COALESCE", "NOW", */ "UNIX_TIMESTAMP", "DATE_ADD", "DATE_SUB", "DATE_BIN"].contains(&(&n.to_ascii_uppercase() as &str)) {
83+
panic!("scalar_kind_by_name failing on '{}' due to uppercase/lowercase mixup", n);
84+
}
8185
return None;
8286
}
8387

@@ -109,7 +113,7 @@ pub fn aggregate_udf_by_kind(k: CubeAggregateUDFKind) -> AggregateUDF {
109113

110114
/// Note that only full match counts. Pass capitalized names.
111115
pub fn aggregate_kind_by_name(n: &str) -> Option<CubeAggregateUDFKind> {
112-
if n == "MERGE" {
116+
if n == "merge" {
113117
return Some(CubeAggregateUDFKind::MergeHll);
114118
}
115119
return None;
@@ -642,7 +646,7 @@ impl HllMergeUDF {
642646
impl AggregateUDFImpl for HllMergeUDF {
643647

644648
fn name(&self) -> &str {
645-
return "MERGE";
649+
return "merge";
646650
}
647651

648652
fn as_any(&self) -> &dyn Any {

0 commit comments

Comments
 (0)