Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/cubejs-schema-compiler/src/adapter/BaseQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -3693,6 +3693,10 @@ export class BaseQuery {
}
// TODO: https://github.com/cube-js/cube.js/issues/4019
// use single underscore for pre-aggregations to avoid fail of pre-aggregation name replace
const lowercaseName = name.toLowerCase();
if (lowercaseName === '__user' || lowercaseName === '__cubejoinfield') {
return name;
}
return inflection.underscore(name).replace(/\./g, isPreAggregationName ? '_' : '__');
}

Expand Down
5 changes: 1 addition & 4 deletions rust/cubesql/cubesql/src/compile/engine/df/wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -416,10 +416,7 @@ impl Remapper {
LazyLock::new(|| Regex::new(r"[^a-zA-Z0-9_]").unwrap());

let alias = start_from;
let mut truncated_alias = NON_ID_REGEX
.replace_all(&alias, "_")
.trim_start_matches("_")
.to_lowercase();
let mut truncated_alias = NON_ID_REGEX.replace_all(&alias, "_").to_lowercase();
truncated_alias.truncate(16);
let mut alias = truncated_alias.clone();
for i in 1..10000 {
Expand Down
4 changes: 2 additions & 2 deletions rust/cubesql/cubesql/src/compile/test/test_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -925,9 +925,9 @@ async fn test_case_wrapper_with_system_fields() {
.wrapped_sql
.sql
.contains(
"\\\"cubeName\\\":\\\"KibanaSampleDataEcommerce\\\",\\\"alias\\\":\\\"user\\\""
"\\\"cubeName\\\":\\\"KibanaSampleDataEcommerce\\\",\\\"alias\\\":\\\"__user\\\""
),
r#"SQL contains `\"cubeName\":\"KibanaSampleDataEcommerce\",\"alias\":\"user\"` {}"#,
r#"SQL contains `\"cubeName\":\"KibanaSampleDataEcommerce\",\"alias\":\"__user\"` {}"#,
logical_plan.find_cube_scan_wrapped_sql().wrapped_sql.sql
);

Expand Down
Loading