Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
picodata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
picodata
Commits
873cbeeb
Commit
873cbeeb
authored
3 years ago
by
Denis Smirnov
Browse files
Options
Downloads
Patches
Plain Diff
refactoring: move "add_proj" to Plan methods
Also make a "add_bool" test fixup
parent
8db540f1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1414
sbroad import
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/ir/distribution/tests.rs
+1
-3
1 addition, 3 deletions
src/ir/distribution/tests.rs
src/ir/operator.rs
+26
-25
26 additions, 25 deletions
src/ir/operator.rs
src/ir/operator/tests.rs
+5
-6
5 additions, 6 deletions
src/ir/operator/tests.rs
with
32 additions
and
34 deletions
src/ir/distribution/tests.rs
+
1
−
3
View file @
873cbeeb
...
...
@@ -23,9 +23,7 @@ fn proj_preserve_dist_key() {
plan
.add_rel
(
t
);
let
scan_id
=
plan
.add_scan
(
"t"
)
.unwrap
();
let
proj
=
Relational
::
new_proj
(
&
mut
plan
,
scan_id
,
&
[
"a"
,
"b"
])
.unwrap
();
let
proj_id
=
plan
.nodes
.push
(
Node
::
Relational
(
proj
));
let
proj_id
=
plan
.add_proj
(
scan_id
,
&
[
"a"
,
"b"
])
.unwrap
();
plan
.top
=
Some
(
proj_id
);
...
...
This diff is collapsed.
Click to expand it.
src/ir/operator.rs
+
26
−
25
View file @
873cbeeb
...
...
@@ -191,31 +191,6 @@ impl Relational {
}
}
// TODO: we need a more flexible projection constructor (constants, etc)
/// New `Projection` constructor.
///
/// # Errors
/// Returns `QueryPlannerError`:
/// - child node is not relational
/// - child output tuple is invalid
/// - column name do not match the ones in the child output tuple
pub
fn
new_proj
(
plan
:
&
mut
Plan
,
child
:
usize
,
col_names
:
&
[
&
str
],
)
->
Result
<
Self
,
QueryPlannerError
>
{
let
id
=
plan
.nodes
.next_id
();
let
children
:
Vec
<
usize
>
=
vec!
[
child
];
let
output
=
plan
.add_output_row
(
id
,
&
children
,
&
[
0
],
col_names
)
?
;
Ok
(
Relational
::
Projection
{
children
,
id
,
output
,
})
}
/// New `Selection` constructor
///
/// # Errors
...
...
@@ -347,6 +322,32 @@ impl Plan {
}
Err
(
QueryPlannerError
::
InvalidRelation
)
}
// TODO: we need a more flexible projection constructor (constants, etc)
/// New `Projection` constructor.
///
/// # Errors
/// Returns `QueryPlannerError`:
/// - child node is not relational
/// - child output tuple is invalid
/// - column name do not match the ones in the child output tuple
pub
fn
add_proj
(
&
mut
self
,
child
:
usize
,
col_names
:
&
[
&
str
],
)
->
Result
<
usize
,
QueryPlannerError
>
{
let
id
=
self
.nodes
.next_id
();
let
children
:
Vec
<
usize
>
=
vec!
[
child
];
let
output
=
self
.add_output_row
(
id
,
&
children
,
&
[
0
],
col_names
)
?
;
let
proj
=
Relational
::
Projection
{
children
,
id
,
output
,
};
Ok
(
self
.nodes
.push
(
Node
::
Relational
(
proj
)))
}
}
#[cfg(test)]
...
...
This diff is collapsed.
Click to expand it.
src/ir/operator/tests.rs
+
5
−
6
View file @
873cbeeb
use
super
::
*
;
use
crate
::
errors
::
QueryPlannerError
;
use
crate
::
ir
::
distribution
::
*
;
use
crate
::
ir
::
expression
::
*
;
use
crate
::
ir
::
relation
::
*
;
use
crate
::
ir
::
value
::
*
;
use
crate
::
ir
::
*
;
...
...
@@ -103,19 +102,19 @@ fn projection() {
// Invalid alias names in the output
assert_eq!
(
QueryPlannerError
::
InvalidRow
,
Relational
::
new_proj
(
&
mut
plan
,
scan_id
,
&
[
"a"
,
"e"
])
.unwrap_err
()
plan
.add_proj
(
scan_id
,
&
[
"a"
,
"e"
])
.unwrap_err
()
);
// Expression node instead of relational one
assert_eq!
(
QueryPlannerError
::
InvalidNode
,
Relational
::
new_proj
(
&
mut
plan
,
1
,
&
[
"a"
])
.unwrap_err
()
plan
.add_proj
(
1
,
&
[
"a"
])
.unwrap_err
()
);
// Try to build projection from the
invalid
node
// Try to build projection from the
non-existing
node
assert_eq!
(
QueryPlannerError
::
ValueOutOfRange
,
Relational
::
new_proj
(
&
mut
plan
,
42
,
&
[
"a"
])
.unwrap_err
()
plan
.add_proj
(
42
,
&
[
"a"
])
.unwrap_err
()
);
}
...
...
@@ -153,7 +152,7 @@ fn selection() {
let
ref_a_id
=
plan
.nodes
.add_ref
(
scan_id
+
1
,
Some
(
vec!
[
0
]),
0
);
let
a_id
=
plan
.nodes
.add_alias
(
"a"
,
ref_a_id
)
.unwrap
();
let
const_id
=
plan
.nodes
.add_const
(
Value
::
number_from_str
(
"10"
)
.unwrap
());
let
gt_id
=
plan
.nodes
.add_bool
(
a_id
,
Bool
::
Gt
,
const_id
)
?
;
let
gt_id
=
plan
.nodes
.add_bool
(
a_id
,
Bool
::
Gt
,
const_id
)
.unwrap
()
;
// Correct Selection operator
Relational
::
new_select
(
&
mut
plan
,
scan_id
,
gt_id
)
.unwrap
();
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment