Skip to content

Commit fcab541

Browse files
committed
fix(cubesql): Parse UDAF name in LogicalPlanLanguage
1 parent 07b52cf commit fcab541

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

rust/cubesql/cubesql/src/compile/rewrite/language.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,8 +261,12 @@ macro_rules! variant_field_struct {
261261

262262
impl FromStr for [<$variant $var_field:camel>] {
263263
type Err = $crate::compile::rewrite::language::LanguageParseError;
264-
fn from_str(_s: &str) -> Result<Self, Self::Err> {
265-
Err(Self::Err::NotSupported)
264+
fn from_str(s: &str) -> Result<Self, Self::Err> {
265+
const PREFIX: &'static str = concat!(std::stringify!([<$variant $var_field:camel>]), ":");
266+
if let Some(suffix) = s.strip_prefix(PREFIX) {
267+
return Ok([<$variant $var_field:camel>](suffix.to_string()));
268+
}
269+
Err(Self::Err::ShouldStartWith(PREFIX))
266270
}
267271
}
268272

rust/cubesql/cubesql/src/compile/rewrite/mod.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,9 +1419,13 @@ fn window_fun_expr_var_arg(
14191419
}
14201420

14211421
fn udaf_expr(fun_name: impl Display, args: Vec<impl Display>) -> String {
1422+
let prefix = if fun_name.to_string().starts_with("?") {
1423+
""
1424+
} else {
1425+
"AggregateUDFExprFun:"
1426+
};
14221427
format!(
1423-
"(AggregateUDFExpr {} {})",
1424-
fun_name,
1428+
"(AggregateUDFExpr {prefix}{fun_name} {})",
14251429
list_expr("AggregateUDFExprArgs", args),
14261430
)
14271431
}

0 commit comments

Comments
 (0)