Skip to content

Commit c16175b

Browse files
authored
fix(cubesql): Fix incorrect underscore truncation for aliases (#9716)
1 parent d68c804 commit c16175b

File tree

1 file changed

+10
-2
lines changed
  • rust/cubesql/cubesql/src/compile/engine/df

1 file changed

+10
-2
lines changed

rust/cubesql/cubesql/src/compile/engine/df/wrapper.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -415,8 +415,16 @@ impl Remapper {
415415
static NON_ID_REGEX: LazyLock<Regex> =
416416
LazyLock::new(|| Regex::new(r"[^a-zA-Z0-9_]").unwrap());
417417

418-
let alias = start_from;
419-
let mut truncated_alias = NON_ID_REGEX.replace_all(&alias, "_").to_lowercase();
418+
let alias_lower = start_from.clone().to_lowercase();
419+
let mut truncated_alias = if alias_lower != "__user" && alias_lower != "__cubejoinfield" {
420+
NON_ID_REGEX
421+
.replace_all(&alias_lower, "_")
422+
.trim_start_matches("_")
423+
.to_string()
424+
} else {
425+
alias_lower
426+
};
427+
420428
truncated_alias.truncate(16);
421429
let mut alias = truncated_alias.clone();
422430
for i in 1..10000 {

0 commit comments

Comments
 (0)