Skip to content
Snippets Groups Projects
Commit 4f13ef13 authored by Denis Smirnov's avatar Denis Smirnov
Browse files

test: no motions for the local sub-query

parent e04c8037
No related branches found
No related tags found
1 merge request!1414sbroad import
......@@ -185,3 +185,49 @@ fn full_motion_non_segment_outer_for_sub_query() {
let expected_plan = Plan::from_yaml(&s).unwrap();
assert_eq!(plan, expected_plan);
}
#[test]
fn local_sub_query() {
// t1(a int) key [a]
// t2(a int, b int) key [a]
// select * from t1 where a = (select a from t2)
let mut plan = Plan::new();
let mut children: Vec<usize> = Vec::new();
let t1 = Table::new_seg("t1", vec![Column::new("a", Type::Integer)], &["a"]).unwrap();
plan.add_rel(t1);
let scan_t1_id = plan.add_scan("t1").unwrap();
children.push(scan_t1_id);
let t2 = Table::new_seg("t2", vec![Column::new("a", Type::Integer)], &["a"]).unwrap();
plan.add_rel(t2);
let scan_t2_id = plan.add_scan("t2").unwrap();
let proj_id = plan.add_proj(scan_t2_id, &["a"]).unwrap();
let sq_id = plan.add_sub_query(proj_id, None).unwrap();
children.push(sq_id);
let id = plan.nodes.next_id();
let inner_a_id = plan
.add_row_from_sub_query(id, &children[..], children.len() - 1, &["a"])
.unwrap();
let outer_a_id = plan.add_row_from_child(id, scan_t1_id, &["a"]).unwrap();
let eq_id = plan.add_bool(outer_a_id, Bool::Eq, inner_a_id).unwrap();
let select_id = plan.add_select(&children[..], eq_id, id).unwrap();
plan.set_top(select_id).unwrap();
plan.add_motions().unwrap();
// Check the modified plan
plan.nodes.add_new_equalities().unwrap();
let path = Path::new("")
.join("tests")
.join("artifactory")
.join("ir")
.join("transformation")
.join("redistribution")
.join("local_sub_query.yaml");
let s = fs::read_to_string(path).unwrap();
let expected_plan = Plan::from_yaml(&s).unwrap();
assert_eq!(plan, expected_plan);
}
---
nodes:
arena:
- Expression:
Reference:
targets: ~
position: 0
parent: 0
- Expression:
Alias:
name: a
child: 0
- Expression:
Row:
list:
- 1
distribution:
Segment:
keys:
- positions:
- 0
- Relational:
ScanRelation:
output: 2
id: 0
relation: t1
- Expression:
Reference:
targets: ~
position: 0
parent: 4
- Expression:
Alias:
name: a
child: 4
- Expression:
Row:
list:
- 5
distribution:
Segment:
keys:
- positions:
- 0
- Relational:
ScanRelation:
output: 6
id: 4
relation: t2
- Expression:
Reference:
targets:
- 0
position: 0
parent: 8
- Expression:
Alias:
name: a
child: 8
- Expression:
Row:
list:
- 9
distribution:
Segment:
keys:
- positions:
- 0
- Relational:
Projection:
children:
- 7
id: 8
output: 10
- Expression:
Reference:
targets:
- 0
position: 0
parent: 12
- Expression:
Alias:
name: a
child: 12
- Expression:
Row:
list:
- 13
distribution:
Segment:
keys:
- positions:
- 0
- Relational:
ScanSubQuery:
alias: ~
children:
- 11
id: 12
output: 14
- Expression:
Reference:
targets:
- 1
position: 0
parent: 16
- Expression:
Row:
list:
- 16
distribution:
Segment:
keys:
- positions:
- 0
- Expression:
Reference:
targets:
- 0
position: 0
parent: 16
- Expression:
Row:
list:
- 18
distribution:
Segment:
keys:
- positions:
- 0
- Expression:
Bool:
left: 19
op: Eq
right: 17
- Expression:
Reference:
targets:
- 0
position: 0
parent: 16
- Expression:
Alias:
name: a
child: 21
- Expression:
Row:
list:
- 22
distribution:
Segment:
keys:
- positions:
- 0
- Relational:
Selection:
children:
- 3
- 15
filter: 20
id: 16
output: 23
relations:
t1:
Segment:
columns:
- name: a
type: integer
key:
positions:
- 0
name: t1
t2:
Segment:
columns:
- name: a
type: integer
key:
positions:
- 0
name: t2
slices: ~
top: 24
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment