-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(cubesql): Fix condition for joining two date range filters (#9113)
- Loading branch information
Showing
3 changed files
with
65 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
use cubeclient::models::{V1LoadRequestQuery, V1LoadRequestQueryFilterItem}; | ||
use pretty_assertions::assert_eq; | ||
|
||
use crate::compile::{ | ||
rewrite::rewriter::Rewriter, | ||
test::{convert_select_to_query_plan, init_testing_logger, utils::LogicalPlanTestUtils}, | ||
DatabaseProtocol, | ||
}; | ||
|
||
#[tokio::test] | ||
async fn test_filter_date_greated_and_not_null() { | ||
if !Rewriter::sql_push_down_enabled() { | ||
return; | ||
} | ||
init_testing_logger(); | ||
|
||
let query_plan = convert_select_to_query_plan( | ||
// language=PostgreSQL | ||
r#" | ||
SELECT | ||
dim_str0 | ||
FROM MultiTypeCube | ||
WHERE | ||
(dim_date0 IS NOT NULL) | ||
AND (dim_date0 > '2019-01-01 00:00:00') | ||
GROUP BY | ||
dim_str0 | ||
; | ||
"# | ||
.to_string(), | ||
DatabaseProtocol::PostgreSQL, | ||
) | ||
.await; | ||
|
||
let logical_plan = query_plan.as_logical_plan(); | ||
assert_eq!( | ||
logical_plan.find_cube_scan().request, | ||
V1LoadRequestQuery { | ||
measures: Some(vec![]), | ||
dimensions: Some(vec!["MultiTypeCube.dim_str0".to_string()]), | ||
segments: Some(vec![]), | ||
order: Some(vec![]), | ||
filters: Some(vec![ | ||
V1LoadRequestQueryFilterItem { | ||
member: Some("MultiTypeCube.dim_date0".to_string()), | ||
operator: Some("set".to_string()), | ||
values: None, | ||
or: None, | ||
and: None, | ||
}, | ||
V1LoadRequestQueryFilterItem { | ||
member: Some("MultiTypeCube.dim_date0".to_string()), | ||
operator: Some("afterDate".to_string()), | ||
values: Some(vec!["2019-01-01 00:00:00".to_string()]), | ||
or: None, | ||
and: None, | ||
}, | ||
],), | ||
..Default::default() | ||
} | ||
); | ||
} |