Skip to content

Commit

Permalink
feat(cubesql): Allow char_length function to be used with cubes
Browse files Browse the repository at this point in the history
  • Loading branch information
MazterQyou committed Sep 30, 2022
1 parent b345ade commit e99344f
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 0 deletions.
32 changes: 32 additions & 0 deletions rust/cubesql/cubesql/src/compile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12065,6 +12065,38 @@ ORDER BY \"COUNT(count)\" DESC"
)
}

#[tokio::test]
async fn test_thoughtspot_char_length() {
init_logger();

let logical_plan = convert_select_to_query_plan(
r#"
SELECT char_length("ta_1"."customer_gender")
FROM "db"."public"."KibanaSampleDataEcommerce" "ta_1";
"#
.to_string(),
DatabaseProtocol::PostgreSQL,
)
.await
.as_logical_plan();

assert_eq!(
logical_plan.find_cube_scan().request,
V1LoadRequestQuery {
measures: Some(vec![]),
dimensions: Some(vec![
"KibanaSampleDataEcommerce.customer_gender".to_string(),
]),
segments: Some(vec![]),
time_dimensions: None,
order: None,
limit: None,
offset: None,
filters: None,
}
)
}

#[tokio::test]
async fn test_in_filter() {
init_logger();
Expand Down
14 changes: 14 additions & 0 deletions rust/cubesql/cubesql/src/compile/rewrite/rules/split.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1265,6 +1265,20 @@ impl RewriteRules for SplitRules {
],
),
),
// CharacterLength
rewrite(
"split-push-down-char-length-inner-replacer",
inner_aggregate_split_replacer(fun_expr("CharacterLength", vec!["?expr"]), "?cube"),
inner_aggregate_split_replacer("?expr", "?cube"),
),
rewrite(
"split-push-down-char-length-outer-aggr-replacer",
outer_aggregate_split_replacer(fun_expr("CharacterLength", vec!["?expr"]), "?cube"),
fun_expr(
"CharacterLength",
vec![outer_aggregate_split_replacer("?expr", "?cube")],
),
),
]
}
}
Expand Down

0 comments on commit e99344f

Please sign in to comment.