Skip to content

Commit 4112c02

Browse files
committed
chore(cubestore): Upgrade DF: Remove redundant RewriteInListLiterals analysis pass
1 parent 6724cfc commit 4112c02

File tree

3 files changed

+44
-91
lines changed

3 files changed

+44
-91
lines changed

rust/cubestore/cubestore-sql-tests/src/tests.rs

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1175,12 +1175,31 @@ async fn numeric_cast(service: Box<dyn SqlClient>) {
11751175
"INSERT INTO foo.managers (id, department_id) VALUES ('a', 1), ('b', 3), ('c', 3), ('d', 5)"
11761176
).await.unwrap();
11771177

1178+
let query = "SELECT count(*) from foo.managers WHERE department_id in ('3', '5')";
11781179
let result = service
1179-
.exec_query("SELECT count(*) from foo.managers WHERE department_id in ('3', '5')")
1180+
.exec_query(query)
11801181
.await
11811182
.unwrap();
11821183

11831184
assert_eq!(result.get_rows()[0], Row::new(vec![TableValue::Int(3)]));
1185+
1186+
// Check that we're casting '3' to int and not department_id to Utf8, with our Cube-specific type_coercion changes in DF.
1187+
let plans = service.plan_query(query).await.unwrap();
1188+
let expected =
1189+
"Projection, [count(Int64(1))@0:count(*)]\
1190+
\n LinearFinalAggregate\
1191+
\n CoalescePartitions\
1192+
\n ClusterSend, partitions: [[1]]\
1193+
\n CoalescePartitions\
1194+
\n LinearPartialAggregate\
1195+
\n Projection, []\
1196+
\n Filter, predicate: department_id@0 = 3 OR department_id@0 = 5\
1197+
\n Scan, index: default:1:[1], fields: [department_id], predicate: department_id = Int64(3) OR department_id = Int64(5)\
1198+
\n Empty";
1199+
assert_eq!(
1200+
expected,
1201+
pp_phys_plan_ext(plans.router.as_ref(), &PPOptions{ traverse_past_clustersend: true, show_filters: true, ..PPOptions::none() }),
1202+
);
11841203
}
11851204

11861205
async fn cast_timestamp_to_utf8(service: Box<dyn SqlClient>) {
@@ -7562,12 +7581,34 @@ async fn filter_multiple_in_for_decimal(service: Box<dyn SqlClient>) {
75627581
.exec_query("INSERT INTO s.t(i) VALUES (1), (2), (3)")
75637582
.await
75647583
.unwrap();
7584+
let query = "SELECT count(*) FROM s.t WHERE i in ('2', '3')";
75657585
let r = service
7566-
.exec_query("SELECT count(*) FROM s.t WHERE i in ('2', '3')")
7586+
.exec_query(query)
75677587
.await
75687588
.unwrap();
75697589

75707590
assert_eq!(to_rows(&r), rows(&[(2)]));
7591+
7592+
// Verify we're casting '2' and '3' to decimal type and not casting i to Utf8, with Cube-specific DF comparison coercion changes.
7593+
let plans = service.plan_query(query).await.unwrap();
7594+
let expected =
7595+
"Projection, [count(Int64(1))@0:count(*)]\
7596+
\n LinearFinalAggregate\
7597+
\n CoalescePartitions\
7598+
\n ClusterSend, partitions: [[1]]\
7599+
\n CoalescePartitions\
7600+
\n LinearPartialAggregate\
7601+
\n Projection, []\
7602+
\n Filter, predicate: i@0 = Some(200000),18,5 OR i@0 = Some(300000),18,5\
7603+
\n Scan, index: default:1:[1], fields: *, predicate: i = Decimal128(Some(200000),18,5) OR i = Decimal128(Some(300000),18,5)\
7604+
\n Sort\
7605+
\n Empty";
7606+
7607+
assert_eq!(
7608+
expected,
7609+
pp_phys_plan_ext(plans.router.as_ref(), &PPOptions{ traverse_past_clustersend: true, show_filters: true, ..PPOptions::none() }),
7610+
);
7611+
75717612
}
75727613

75737614
async fn planning_aggregate_index(service: Box<dyn SqlClient>) {

rust/cubestore/cubestore/src/queryplanner/mod.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ pub mod serialized_plan;
1717
mod tail_limit;
1818
mod topk;
1919
pub mod trace_data_loaded;
20-
use rewrite_inlist_literals::RewriteInListLiterals;
2120
use serialized_plan::PreSerializedPlan;
2221
pub use topk::MIN_TOPK_STREAM_ROWS;
2322
use udfs::{registerable_aggregate_udfs, registerable_scalar_udfs};
@@ -26,7 +25,6 @@ pub mod info_schema;
2625
pub mod merge_sort;
2726
pub mod metadata_cache;
2827
pub mod providers;
29-
mod rewrite_inlist_literals;
3028
mod rolling;
3129
#[cfg(test)]
3230
mod test_utils;
@@ -283,7 +281,7 @@ impl QueryPlannerImpl {
283281

284282
impl QueryPlannerImpl {
285283
pub fn make_execution_context(mut config: SessionConfig) -> SessionContext {
286-
// The config parameter is from metadata_cache_factor (which we need to rename) but doesn't
284+
// The config parameter is from metadata_cache_factory (which we need to rename) but doesn't
287285
// include all necessary configs.
288286
config
289287
.options_mut()
@@ -297,7 +295,6 @@ impl QueryPlannerImpl {
297295
for udf in registerable_scalar_udfs() {
298296
context.register_udf(udf);
299297
}
300-
context.add_analyzer_rule(Arc::new(RewriteInListLiterals {}));
301298
context.add_optimizer_rule(Arc::new(RollingOptimizerRule {}));
302299

303300
// TODO upgrade DF

rust/cubestore/cubestore/src/queryplanner/rewrite_inlist_literals.rs

Lines changed: 0 additions & 85 deletions
This file was deleted.

0 commit comments

Comments
 (0)