Skip to content

Commit

Permalink
fix(cubesql): Metabase - substring __user (#5328)
Browse files Browse the repository at this point in the history
  • Loading branch information
gandronchik committed Sep 30, 2022
1 parent e99344f commit a25c8bf
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
31 changes: 31 additions & 0 deletions rust/cubesql/cubesql/src/compile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10907,6 +10907,37 @@ ORDER BY \"COUNT(count)\" DESC"
)
}

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

let logical_plan = convert_select_to_query_plan(
"SELECT \"source\".\"substring131715\" AS \"substring131715\"
FROM (
SELECT
\"public\".\"KibanaSampleDataEcommerce\".\"__user\" AS \"__user\",
SUBSTRING(\"public\".\"KibanaSampleDataEcommerce\".\"__user\" FROM 1 FOR 1234) AS \"substring131715\"
FROM \"public\".\"KibanaSampleDataEcommerce\"
) AS \"source\"
LIMIT 10000".to_string(),
DatabaseProtocol::PostgreSQL
).await.as_logical_plan();

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

#[tokio::test]
async fn test_select_asterisk_cross_join() {
init_logger();
Expand Down
1 change: 1 addition & 0 deletions rust/cubesql/cubesql/src/compile/rewrite/cost.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ impl CostFunction<LogicalPlanLanguage> for BestCubePlan {
let cube_members = match enode {
LogicalPlanLanguage::Measure(_) => 1,
LogicalPlanLanguage::Dimension(_) => 1,
LogicalPlanLanguage::ChangeUser(_) => 1,
LogicalPlanLanguage::LiteralMember(_) => 1,
LogicalPlanLanguage::TimeDimensionGranularity(TimeDimensionGranularity(Some(_))) => 1,
LogicalPlanLanguage::MemberError(_) => 1,
Expand Down

0 comments on commit a25c8bf

Please sign in to comment.